audiogen
The command Agents use to make speech, sound effects and music as local audio files, and to look up voices and speech models.
audiogen makes audio files: speech in a chosen voice, sound effects from a description, and music from a brief. It also lists voices and speech models, runs many requests from one file, shows the Team’s AI usage, and checks its own setup.
Where it runs
The same command is available to Agents on a cloud Team and on a Mac Team. Sign-in and Agent attribution come from the Agent’s environment, so there is nothing to set up. It needs curl and jq. See Choose where your Agents run.
Synopsis
audiogen <resource> <method> [flags]
audiogen batch [--keep-going] [--dry-run] <spec.json>
audiogen balance
audiogen docs [--topic <name>]
audiogen doctor
audiogen --help | --version
audiogen <resource> <method> --help| Command | What it does |
|---|---|
text-to-speech convert (alias tts convert) |
Text to speech in a voice. Writes an audio file. |
text-to-sound-effects convert (alias sfx convert) |
A description to a sound effect. Writes an audio file. |
music compose |
A brief (or a composition plan) to music. Writes an audio file. |
music composition-plan create |
A brief to a structured plan, printed as JSON, that music compose can take. |
voices search |
Lists voices. |
voices get |
One voice’s details. |
models list |
The speech models, with their text limits and languages. |
batch |
Runs many requests from one JSON file. |
balance |
This period’s AI usage against the plan’s AI allowance. |
docs |
Prints the bundled reference docs. |
doctor |
Checks the environment, sign-in and that the audio service answers. |
Flags on every request
These work on text-to-speech convert, text-to-sound-effects convert, music compose and music composition-plan create. Every flag that takes a value also accepts --flag=value.
| Flag | Value | Default | Meaning |
|---|---|---|---|
--json |
A JSON object, or - to read it from stdin |
{} |
The whole request body. Field flags given after it override its members. |
-p, --param |
key=value |
— | Adds one more body field. Repeatable. true, false, null, numbers and JSON arrays or objects are typed; anything else is a string. |
--output-format |
The service’s codec string, for example mp3_44100_128, mp3_44100_192, mp3_48000_192, wav_24000, wav_44100, pcm_…, opus_…, ulaw_8000 |
mp3_44100_128 for speech and sound effects; auto (per model) for music |
The audio format. It also sets the file extension: mp3_* and auto → .mp3, wav_* → .wav, pcm_* → .pcm, opus_* → .opus, ulaw_*/alaw_* → .raw. |
--output |
A file path | A new folder $TMPDIR/audiogen.XXXXXX/ |
Where to write the audio. Missing folders are created. An existing file is never overwritten. |
--quiet |
— | Off | Less on stderr. |
--yes, --no-open |
— | — | Accepted and ignored. |
The body is built from --json, the field flags and -p in the order they are given: a later one overrides an earlier one for the same field.
text-to-speech convert
audiogen text-to-speech convert --voice-id <id> --text "…" [--output <file>] [flags]| Flag | Value | Meaning |
|---|---|---|
--voice-id |
A voice id (letters and digits) | Required, unless --voice-name is given. Get ids from audiogen voices search. |
--voice-name |
A voice name | Looks the voice up by name instead. The match ignores case and also matches the part of the name before -. |
--text |
Text | Required, unless --text-file is given. |
--text-file |
A path | Reads the text from a file. |
--model-id |
An id that audiogen models list lists |
The speech model. Leave it out for the service’s default. |
--language-code |
An ISO 639-1 code | For models that support it. |
--seed |
A number | Best-effort repeatability. |
--voice-settings |
JSON with stability, similarity_boost, style, speed, use_speaker_boost |
The voice settings in one go. |
--stability, --similarity-boost, --style, --speed, --use-speaker-boost |
A value each | One voice setting each. |
--apply-text-normalization |
auto, on, off |
How numbers and abbreviations are read out. |
--previous-text, --next-text |
Text | The text that comes before or after, for continuity between clips. |
The default file name is text-to-speech.<ext>.
text-to-sound-effects convert
audiogen text-to-sound-effects convert --text "…" [--output <file>] [flags]| Flag | Value | Default | Meaning |
|---|---|---|---|
--text |
A description | Required | What the sound is. |
--duration-seconds |
0.5–30 | The model picks | The length. |
--prompt-influence |
0–1 | 0.3 | Higher follows the words more literally. |
--loop |
— | Off | Makes a seamless loop. |
--model-id |
A sound model id | The service’s default | The sound model. |
The default file name is text-to-sound-effects.<ext>.
music compose and music composition-plan create
audiogen music compose --prompt "…" [--output <file>] [flags]
audiogen music composition-plan create --prompt "…" [--music-length-ms <n>]music compose:
| Flag | Value | Meaning |
|---|---|---|
--prompt |
A brief | Required, unless --composition-plan is given. |
--composition-plan |
JSON | A plan from music composition-plan create. |
--music-length-ms |
3000–600000 | The length in milliseconds. |
--force-instrumental |
— | No vocals. |
--model-id |
A music model id (the ids are in audiogen music compose --help) |
The music model. Leave it out for the service’s default. |
--seed |
A number | Repeatability. |
--finetune-id |
An id | Passed to the service as finetune_id. |
The default file name is music-compose.<ext>.
music composition-plan create takes --prompt (required), --music-length-ms, --model-id and --source-composition-plan, and prints the plan as JSON instead of writing audio.
voices and models
audiogen voices search [--search <text>] [--page-size <n>] [--next-page-token <t>]
[--category <c>] [--voice-type <t>] [--sort <s>] [--sort-direction <d>]
audiogen voices get --voice-id <id>
audiogen models listvoices search and voices get print the service’s JSON as it comes, including each voice’s voice_id, name, category, labels and preview_url. Use next_page_token from one page to get the next.
models list prints, in a terminal, one line per speech model: its id, its text limit per request, how many languages it supports, and its name. Piped, it prints the full JSON. Sound-effect and music models are not listed.
batch
audiogen batch [--keep-going] [--dry-run] <spec.json>Runs the items of one JSON file in order. The file is an object with an items array that is not empty:
{
"output_dir": "App/Resources/Sounds",
"defaults": { "output_format": "wav_24000" },
"items": [
{ "command": "text-to-sound-effects convert", "output": "tap.wav",
"body": { "text": "short soft click", "duration_seconds": 0.5 } },
{ "command": "text-to-speech convert", "output": "welcome.mp3", "output_format": "mp3_44100_128",
"voice_name": "VOICE_NAME", "body": { "text": "Welcome back." } }
]
}| Key | Where | Meaning |
|---|---|---|
output_dir |
Top level, optional | Relative output paths are placed in this folder. |
defaults.output_format |
Top level, optional | The format for items that set none. |
command |
Item | text-to-speech convert, text-to-sound-effects convert or music compose. |
body |
Item | The request body, with the service’s field names (as with --json). |
output |
Item | The file to write. |
output_format |
Item | This item’s format. |
voice_id, voice_name |
Item | The voice, for text-to-speech convert. |
| Flag | Meaning |
|---|---|
--keep-going |
Carries on after a failed item. Without it, the first failure stops the batch. A sign-in failure (exit 3) or exhausted AI allowance (exit 4) always stops it. |
--dry-run |
Prints the audiogen command each item would run, and runs nothing. |
stdout is one JSON object: items (each with index, ok, and either the item’s result or exit_code), ok, generated, failed and total_cost_usd. In a terminal it prints a summary line and one line per file. With --keep-going, the batch exits 6 if any item failed; without it, the batch stops at the first failure with that item’s exit code.
balance
Shows this period’s AI usage against the plan’s AI allowance. The allowance is shared with Agent chat. In a terminal:
AI usage: <percent>% of this period's plan allowance (<n> credits beyond the plan)
credits left: <n> (<n> credits owed)When the plan has no AI allowance, the first line reads AI usage: the plan includes no AI allowance, paid with credits. When both the allowance and the credits are used up, it adds ! AI allowance and credits exhausted — ask your user to add credits or upgrade the plan. Piped, it prints JSON with used_usd, included_usd, overage_usd, credit_balance_usd, used_percent, overage_credits, credits_left, credits_owed, has_capacity and period_end. Plans are listed on air.build/pricing; see Settings › Plan & Usage for the Team’s usage in the app.
docs and doctor
audiogen docs prints the bundled guide. --topic prints one bundled doc instead: commands/<resource>, recipes, models or common-errors. It works without sign-in.
audiogen doctor checks, one line each with ✓, ✗ or !: curl, jq, the backend address, the Team sign-in, the Agent identity, whether the audio service answers, the bundled docs, and whether the terminal is interactive. Piped, it prints {"ok":…,"checks":[{"name","ok","detail","critical"}]}. It exits 1 if a critical check fails.
Output
stdout carries only the result; progress and errors go to stderr. In a terminal the result is readable text; when stdout is piped, it is one JSON line.
For a request that writes audio, the terminal shows the file’s absolute path, and vendor credits: <n> when the service reports credits. Piped:
{"file":"/tmp/audiogen.Xy12/text-to-speech.mp3","output_format":"default","bytes":48213,"credits":<n>,"cost_usd":<n>,"request_id":"…","request":{…}}credits, cost_usd and request_id appear only when the service reports them. output_format is default when no format was given. Before saving, audiogen checks that a WAV or MP3 file really is one.
Exit codes and errors
| Exit code | Meaning | What to do |
|---|---|---|
0 |
Success. | — |
1 |
Unexpected error, or a failed doctor check. |
Run audiogen doctor. |
2 |
Invalid usage or parameters (also what the service rejects as invalid). | Read the message and fix the flag or body field. |
3 |
Sign-in failed, or the command is not running in an AirBuild Agent’s environment. | Run it from an Agent. |
4 |
The AI allowance and credits are used up. | Ask the Team’s owner to add credits or change the plan. |
5 |
The request was refused by the content policy. | Change the text or prompt. |
6 |
Generation failed: no audio, not audio, or, with batch --keep-going, an item failed. |
Try again, or change the request. |
7 |
Network or service error, including a format or feature the service does not allow. | Try again later, or use another format. |
8 |
Not found: a voice, a model or a doc topic. | Check the id with voices search or models list. |
9 |
The service is busy. | Wait and try again. |
Messages start with Error:. Common ones:
| Message | Exit |
|---|---|
--text (or --text-file) is required. |
2 |
--voice-id (or --voice-name) is required; "audiogen voices search" lists them. |
2 |
--prompt or --composition-plan is required. |
2 |
--json must be a JSON object (or - for stdin). |
2 |
--param expects key=value. |
2 |
output already exists: PATH |
2 |
the request body is larger than 1 MB. |
2 |
unknown flag: … (see audiogen … --help) |
2 |
no voice is named "NAME"; run "audiogen voices search". |
8 |
the service returned no audio. / the service answered JSON instead of audio… / the service returned something that is not a WAV file (…) |
6 |
could not reach the Airbuild creative service: … |
7 |
The service’s own error text is passed through as the message. Short network failures and busy answers are retried a few times on their own before audiogen gives up.
Examples
# Find a voice, then speak a line with it
audiogen voices search --search "calm"
audiogen text-to-speech convert --voice-name "VOICE_NAME" --text "Welcome back." --output App/Resources/welcome.mp3
# A half-second UI sound as WAV
audiogen text-to-sound-effects convert --text "soft wooden tap, dry" --duration-seconds 0.5 \
--output-format wav_24000 --output App/Resources/tap.wav
# A one-minute instrumental loop
audiogen music compose --prompt "calm lo-fi loop, 80 BPM" --music-length-ms 60000 \
--force-instrumental
# Check a batch file, then run it
audiogen batch --dry-run sounds.json && audiogen batch sounds.json