Esta página está en inglés.

Music

POST /v1/music/generations takes { model, prompt } and answers { created, data: [{ url, format }] }, one entry per track. The model is <provider>/<model>.

ModelHow it renders
openrouter/google/lyria-3-clip-preview, openrouter/google/lyria-3-pro-preview, gemini/lyria-3-clip-previewOne track in one call, answered in about 15 seconds. url is a data:audio/mpeg;base64,… URI.
gemini/lyria-3.5One song of a couple of minutes, in one call. Needs a held request (below).
elevenlabs/eleven_text_to_sound_v2One sound effect, in one call, sold by length. url is a data:audio/mpeg;base64,… URI.
elevenlabs/music_v1, elevenlabs/music_v2, elevenlabs/music_v2_5One song of the length you pick, 1 to 5 minutes. Needs a held request (below). url is a data:audio/mpeg;base64,… URI.
kie/suno-v4.0, kie/suno-v3.5A render job, two tracks. url is the provider's own link, with the provider's expiry.
cURLcurl
1curl https://api.aile.sh/v1/music/generations \
2-H "Authorization: Bearer $AILE_KEY" \
3-H "Content-Type: application/json" \
4-d '{ "model": "openrouter/google/lyria-3-clip-preview", "prompt": "calm piano at night" }'
  • instrumental defaults to true. Send false for vocals.
  • Lyria and ElevenLabs make one track and a Suno job two. n may be omitted or match that count; anything else is a 400.
  • ElevenLabs models are sold by length. Send duration_seconds: 60, 120, 180, 240 or 300 on the three music models (60 when you send none), 5, 10, 15 or 30 on elevenlabs/eleven_text_to_sound_v2 (5 when you send none). Any other value is a 400, and so is duration_seconds on any other model.
  • Aile keeps no copy of the audio.

On chat

/v1/chat/completions naming a Lyria model returns a chat.completion whose message.audio.data is the MP3 in base64 (delta.audio when stream: true). The user messages' text is the prompt, sent as written. gemini/lyria-3.5 on chat needs stream: true, which keeps the request open while it renders; without it the request is a 400.

  • Billed per track exactly as /v1/music/generations. The response carries no token usage.
  • An API key is required. Send the model id itself: a named route does not reach it.
  • Text parts only. Tools, and an audio.format other than mp3, are a 400.
  • A price ceiling (x-aile-max-price, or the key's price limit) is a 400, because a per-track price cannot be checked against it.
  • /v1/messages and /v1/responses do not serve music models, and ElevenLabs models are served on /v1/music/generations only.

Billing

  • Per track. The hold is the tracks the model makes, and you pay for the tracks that arrive.
  • An ElevenLabs track is billed at the price of the length you pick: music $0.15 a minute, sound effects $0.12 a minute (list; a sharer may charge less). 60 seconds of music is $0.15, 300 seconds $0.75, 5 seconds of sound $0.01, 30 seconds $0.06.
  • A failed job, or one that returns no audio, is a 502 and is not charged.
  • A slow render on a keyed request is kept open: after 25 seconds the response is committed to 200 and sent a space every 15 seconds until the tracks arrive, up to 8 minutes. It carries x-aile-edge-hold, x-aile-capacity: nodeless and x-aile-blind: false in place of the other x-aile-* headers (the stake-funded discount's are kept, even on a failure, which is not charged), and a failure after that is a 200 carrying the error body.
  • A Suno render, gemini/lyria-3.5 and Eleven Music need a held request, so MCP's generate_music tool refuses them with a 400 before anything is charged: call POST /v1/music/generations instead. A deployment that does not hold requests refuses them the same way.
  • A provider refusal you can fix (400, 404, 413, 422 …) passes through. One about the sharer's account is a 502 saying you were not charged. A 502 or 504 arrives as 503 with the real code in x-aile-status.
  • A key's pins and the routing headers choose the sharer here too. x-aile-provider must match the model's prefix, and on /v1/music/generations x-aile-max-price does not apply to a per-track price.
  • Where the deployment enables it, the one-call Lyria models and ElevenLabs sound effects on /v1/music/generations also take keyless x402. Suno, gemini/lyria-3.5 and Eleven Music need an API key.