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 Music Generation on the web — pay with any Lightning wallet, no setup needed.

Using the L402 Music Generation API

Create original songs with AI-composed music and vocals from a style prompt and lyrics.

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

Step 1: Initial Request

Send your music parameters. You will receive a 402 Payment Required response.

curl -X POST https://sats4ai.com/api/l402/generate-music \
-H "Content-Type: application/json" \
-d '{"prompt":"upbeat pop song about summer vibes","lyrics":"Walking on the beach, sun is shining bright, every day feels right","sample_rate":44100,"bitrate":256000,"audio_format":"mp3"}' \
-i

Expected Response Headers:

www-authenticate: L402 macaroon="<YOUR_MACAROON>", invoice="<LIGHTNING_INVOICE>"

Step 2: Pay the Lightning Invoice

Pay the invoice and save the preimage.

Step 3: Final Request

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-music \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON_STRING_HERE>:<YOUR_PREIMAGE_HERE>" \
-d '{"prompt":"upbeat pop song about summer vibes","lyrics":"Walking on the beach, sun is shining bright, every day feels right","sample_rate":44100,"bitrate":256000,"audio_format":"mp3"}'

Expected Successful Response:

{ "audioUrl": "https://..." }

Request Body Parameters

prompt: string (required)

Music style description. 10-300 characters.

lyrics: string (required)

Song lyrics. 10-600 characters.

modelId: number or string (optional)

Omit for the best default model. See available models.

sample_rate: integer

Audio sample rate. Default: 44100

bitrate: integer

Audio bitrate. Default: 256000

audio_format: string

Accepted Values: "mp3", "wav", "pcm". Default: "mp3"