L402 API
Pay with Bitcoin, get AI results. Copy-paste the commands below.
Choose a service:
Before You Start
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 full songs (up to 6 minutes) with natural AI vocals, BPM/key control (99%+ accuracy), and 14+ section tags for precise arrangement. Powered by Music-2.6. 300 sats per song.
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","is_instrumental":false,"lyrics_optimizer":false,"sample_rate":44100,"bitrate":256000,"audio_format":"mp3"}' \
-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","is_instrumental":false,"lyrics_optimizer":false,"sample_rate":44100,"bitrate":256000,"audio_format":"mp3"}'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].
is_instrumental: boolean (optional)
Set to true for instrumental-only tracks (no vocals). When true, prompt is required and lyrics are ignored. Default: false
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.
sample_rate: integer
Audio sample rate. Options: 16000, 24000, 32000, 44100. Default: 44100
bitrate: integer
Audio bitrate. Options: 32000, 64000, 128000, 256000. Default: 256000
audio_format: string
Accepted Values: "mp3", "wav", "pcm". Default: "mp3"