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/text-generation 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/text-generation

{
    "input": [
        {
            "role": "User",
            "content": "Tell me a story of a bird"
        },
        {
            "role": "Assistant",
            "content": "..."
        },
        ...
    ],
    "model": "Best"
}

The answer will be the AI model answer

Request Data:

model: string

The quality of the model used for inference: Standard | Best

input: array of objects

The input array contains objects that represent the conversation between the User and the Assistant. Each object has a role and content field.

role: string

User | Assistant

content: string

Message