Audio

Generate speech audio from text

Generates audio from the provided text using the OpenAI-compatible Audio API. Mirrors the OpenAI POST /v1/audio/speech request body. The response is the synthesized audio as raw binary bytes; the actual Content-Type header of the response reflects the requested response_format (e.g. audio/mpeg for mp3).

Not every provider implements the Audio API. Requests routed to a provider that does not support it return 400 Bad Request with an explanatory error message; use /chat/completions for those providers.

post/audio/speech

Query parameters

provider'ollama' | 'ollama_cloud' | 'groq' | 'llamacpp' | 'openai' | 'cloudflare' | 'cohere' | 'anthropic' | 'deepseek' | 'google' | 'mistral' | 'minimax' | 'moonshot' | 'nvidia' | 'zai'

Specific provider to use (default determined by model)

Request body

modelstring required

Model ID to use for speech synthesis (e.g. gpt-4o-mini-tts or tts-1).

inputstring required

The text to synthesize into audio (4096 characters maximum).

instructionsstring

Control the voice of your generated audio with additional instructions. Does not work with tts-1 or tts-1-hd.

voicestring required

The voice to use when generating the audio. OpenAI built-in voices are alloy, ash, ballad, coral, echo, fable, onyx, nova, sage, shimmer, verse, marin, and cedar. Other providers accept their own voice identifiers.

response_format'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm'

The audio format of the response.

speednumber

The speed of the generated audio.

languagestring

ISO 639-1 code for the language of the generated speech. Non-standard extension: OpenAI's speech API has no language field (the name matches its transcription API). Forwarded to the provider as-is; the gateway's built-in local engine (local/qwen3-tts) supports zh, en, de, it, pt, es, ja, ko, fr and ru, and rejects other codes.

reference_audiostring byte

Base64-encoded audio sample for zero-shot voice cloning. The generated speech mimics the voice in the sample. Best results with a clean mono recording between 1 and 30 seconds; WAV is the safest container. Forwarded to the provider as-is - only providers with voice-cloning support honor it (e.g. Qwen3-TTS-compatible backends); others ignore or reject it. Not supported by OpenAI.

Response

The synthesized audio as raw binary bytes. The actual Content-Type header of the response reflects the requested response_format.

Changes

Changed in 2 of the 59 revisions of this API.2