Generate Music
lab_generate_musicGenerate a MUSIC track for a project — the first step of the rhythm chain, and the only one that costs credits. Default engine: ElevenLabs Music v2.5 (produced, contemporary instrumental beds, 3-300 s, priced per second). Stable Audio stays selectable with tool 'stable_audio' (flat per run, up to 190 s, noticeably dated sound). ElevenLabs refuses prompts that name artists, bands or song lyrics; the failed row then carries its suggested rewording in metadata.error. ASYNCHRONOUS: the call returns immediately with a row whose audio_url is null and metadata.status is 'pending'. Nothing is playable and nothing can be bound yet. Poll lab_list_audio (audio_type 'music') until that row's status is 'completed' and audio_url is set — usually under a minute, and the backend gives up after five (status turns 'failed', metadata.error carries the reason, and the credits are refunded). PUT THE TEMPO IN THE PROMPT if you intend to cut on the beat. This is measured, not assumed: a soft swing track measured at confidence 0.164 (unusable), an ordered hard pulse ('techno, 128 bpm, four-on-the-floor') at 0.621. The tempo detector is autocorrelation over an onset envelope — it finds a hard pulse and shrugs at drone, ambient and rubato. Then: lab_bind_audio, lab_beatgrid, lab_apply_rhythm.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tool | No | Music engine. Default 'elevenlabs_music' (ElevenLabs Music v2.5, per second, 3-300 s). 'stable_audio' is the older flat-priced engine (1-190 s) | |
| prompt | Yes | What the music should be. Name genre, instrumentation, mood AND the tempo in bpm if the cut is supposed to sit on the beat — e.g. 'driving techno, four-on-the-floor kick, 128 bpm, no vocals'. A prompt without a stated pulse is the usual reason lab_beatgrid comes back unreliable | |
| get_cost | No | `true` preflights the credit price and your balance WITHOUT generating anything and without spending quota. | |
| scene_ref | No | Optional scene label, stored on the row. Useful to tell several tracks of one project apart | |
| project_id | Yes | Project id (from lab_list_projects) — positive integer as string | |
| duration_seconds | No | Track length in seconds (default 30). ElevenLabs takes 3-300 s (shorter is raised to 3), Stable Audio up to 190 s. Make it at least as long as the sequence you want to cut — lab_apply_rhythm computes durations for the clips that exist and neither adds nor deletes any, so a short track under a long timeline stays a short track |