Skip to main content

L402 API

Pay with Bitcoin, get AI results. Copy-paste the commands below.

Before You Start

Lightning Wallet

Phoenix, Muun, Wallet of Satoshi, Alby, or any LN wallet. Agents: CLW

Terminal or Tool

A command line, Postman, or lnget (recommended)

Private & No Signup

No account, no subscription, no personal data. Pay only when you use it

Want to try this without a terminal? Use Video Generation on the web — pay with any Lightning wallet, no setup needed.

Using the L402 Video Generation API

Generate videos from text prompts by sending a POST request to the L402-protected video endpoint.

API Endpoint: https://sats4ai.com/api/l402/generate-video

Step 1: Initial Request (to get Macaroon and Invoice)

Send your video generation parameters. You will receive a 402 Payment Required response with a macaroon and Lightning invoice.

curl -X POST https://sats4ai.com/api/l402/generate-video \
-H "Content-Type: application/json" \
-d '{"prompt":"A cat walking on the surface of the moon","duration":5,"mode":"pro","generate_audio":false}' \
-i

Expected Response Headers:

www-authenticate: L402 macaroon="<YOUR_MACAROON_STRING_HERE>", invoice="<YOUR_LIGHTNING_INVOICE_HERE>"

Step 2: Pay the Lightning Invoice

Pay the Lightning invoice using any Lightning-enabled wallet. Save the preimage (proof of payment).

Step 3: Final Request (to get the Video)

Send the exact same request with the Authorization header.

Important: The JSON payload must be identical to Step 1.

curl -X POST https://sats4ai.com/api/l402/generate-video \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON_STRING_HERE>:<YOUR_PREIMAGE_HERE>" \
-d '{"prompt":"A cat walking on the surface of the moon","duration":5,"mode":"pro","generate_audio":false}'

Expected Successful Response:

{ "videoUrl": "https://..." }

Request Body Parameters

prompt: string (required)

Text description of the video to generate.

modelId: number or string (optional)

Omit for the best default model. See available video models.

duration: integer

Duration of the video in seconds. Range: 3 to 15. Default: 5

mode: string

Quality mode. Accepted values: "standard" or "pro". Default: "pro"

generate_audio: boolean

Whether to include an AI-generated audio track. Default: false

Pricing

Price = duration × sats_per_second. Rates per second:

ModeNo AudioWith Audio
Standard300 sats/sec400 sats/sec
Pro450 sats/sec550 sats/sec

Example: 5 sec, pro mode, with audio = 5 × 550 = 2,750 sats