L402 API
Pay with Bitcoin, get AI results. Copy-paste the commands below.
Choose a service:
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)
No Account Profile
No account or subscription. We keep minimal payment, delivery, refund, and abuse-prevention records. Providers process inputs when required.
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
Generate a full song with AI vocals from a style prompt plus lyrics. You choose the length: 15–300 seconds at 5 sats per second (75–1500 sats). Returns 44.1 kHz 16-bit stereo WAV. Powered by MiniMax Music-3.
Each structure tag must be alone on its own line, with the words on the lines after it — text sharing a line with a tag is dropped by the model and the song comes out short. Send only tags and no words for an instrumental. Don't want to write lyrics? Set lyricsAddon: true (+25 sats) and optionally lyricsAbout to say what they should be about.
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":"E minor, 90 BPM, acoustic guitar ballad, male vocal, emotional","lyrics":"[verse]\nWalking through the rain tonight\nEvery drop a memory falling down\n\n[chorus]\nBut I still remember you\nIn every song that plays","duration":60}' \
-iExpected 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":"E minor, 90 BPM, acoustic guitar ballad, male vocal, emotional","lyrics":"[verse]\nWalking through the rain tonight\nEvery drop a memory falling down\n\n[chorus]\nBut I still remember you\nIn every song that plays","duration":60}'Expected Successful Response:
{ "audioUrl": "https://..." }Request Body Parameters
prompt: string (required)
Music style description. Include BPM, key, genre, mood, and instruments for best results. Up to 2,000 characters.
lyrics: string (optional)
Song lyrics with section tags. Up to 3,500 characters. Supported tags: [Intro], [Verse], [Pre Chorus], [Chorus], [Interlude], [Bridge], [Outro], [Post Chorus], [Transition], [Break], [Hook], [Build Up], [Inst], [Solo].
duration: integer (optional)
Song length in seconds, 15–300. This is the price at 5 sats per second, and it is bound to the invoice — a request longer than the one you paid for is refused rather than silently billed. Defaults to 15.
lyricsAddon: boolean (optional)
Set true and we write the lyrics for you, +25 sats on the same invoice as the song. Pair it with lyricsAbout to say what they should be about, or leave that empty and the subject is taken from your music prompt.
lyrics_optimizer: boolean (optional)
Set to true to auto-generate lyrics from your prompt when no lyrics are provided. Default: false
modelId: number or string (optional)
Omit for the best default model. See available models.