L402

How to use it as an API

What is L402:

L402s are essentially APIs on a Bitcoin Standard. It enables software/apps to talk to each other but without the need for logins, passwords and associated credit cards as it uses a secure authentication mechanism that combines Macaroons and the Lightning Network.More Info

    How to use our L402 service:

  • Request Access to the resource

    • Make your initial request to the service. You'll receive a 402 response with a header containing: A macaroon (like a ticket) An invoice (payment request)
    • www-authenticate: L402 macaroon="<macaroon>", invoice="<invoice>"
    • Pay the Lightning invoice to obtain the preimage
    • Once the payment is completed, send another POST request to https://sats4ai.com/api/l402/image with the macaroon obtained in Step 1 and the Preimage from Step 2.
    • Authorization: L402 <macaroon>:<preimage>
    • The body data of both requests must be the same or the request after will fail
    • *This service is not returning as a Stream currently
  • Serve the resource

Send the L402 POST request to: https://sats4ai.com/api/l402/image

{
    "input": {
        "prompt": "Bird flying high on the clouds",
        "width": 1024,
        "height": 1024
    },
    "model": "Best"
}

The answer will be a base64 image

data:image/jpeg;base64,...

Request data:

model: string

Quality of model of inference: Standard | Best | Better

input: object

prompt: string

Text prompt for image generation

width: integer

The width of the generated image in text-to-image mode. The value must be a multiple of 32 (if it's not, it will be rounded to the nearest multiple of 32).

Minimum256
Maximum1440

height: integer

The height of the generated image in text-to-image mode. The value must be a multiple of 32 (if it's not, it will be rounded to the nearest multiple of 32).

Minimum256
Maximum1440