Generate speech from text
Alpha
POST
https://api.voxrouter.ai/v1/audio/speechSynthesize speech by routing to the provider implied by `model` (formatted `"{provider}/{model_id}"`, e.g. `"elevenlabs/eleven_turbo_v2_5"`). The response body is the raw audio stream — `audio/mpeg` for `mp3`, `audio/l16` (16-bit LE PCM @ 24 kHz) for `pcm`. The actual provider that served the request is returned in the `X-VoxRouter-Provider` response header.
bash
curl -X POST https://api.voxrouter.ai/v1/audio/speech \
-H "Authorization: Bearer $VOXROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "elevenlabs/eleven_turbo_v2_5",
"input": "string",
"voice": "EXAVITQu4vr4xnSDxMaL"
}'Headers
AuthorizationstringRequiredBearer token. Send as
Authorization: Bearer pk_....Content-TypestringRequiredMust be
application/json.Body
modelstringRequiredProvider-prefixed model id, `"{provider}/{model_id}"`.
inputstringRequiredText to synthesize.
voicestringRequiredProvider-local voice id. Use `/v1/voices` to discover.
response_formatenum (mp3 | pcm)OptionalDefaults to "mp3"Output encoding. `mp3` returns `audio/mpeg`. `pcm` returns raw
16-bit little-endian PCM at 24 kHz (`audio/l16`).
provider_optionsobjectOptionalPassthrough provider-specific options. Shape depends on the
provider; consult the provider adapter for supported keys.
Response
Audio stream.
Returns raw audio/mpeg bytes.
Errors
Non-2xx responses return a JSON body with a machine-readable error code and an optional details string.
| Status | Meaning |
|---|---|
| 400 | Request body failed validation or model string is malformed. |
| 401 | Missing or invalid API key. |
| 402 | Wallet has insufficient credit (`insufficient_credit`) **or** the API key has tripped a per-key daily/monthly spend cap (`spend_limit_exceeded`). The `error` field on the JSON body distinguishes the two; see [`InsufficientCredit`](#/components/responses/InsufficientCredit) and [`SpendLimitExceeded`](#/components/responses/SpendLimitExceeded) for the specific shapes. |
| 429 | Per-key rate limit or per-key concurrency limit exceeded. The `code` field on the body distinguishes the two (`rate_limit_exceeded` vs `concurrency_limit_exceeded`). `Retry-After` is seconds-from-now: a hard value until the rate-limit window resets, or a soft `1` hint for concurrency (slots free on request completion). |
| 500 | Unexpected server error. |
| 502 | The chosen provider returned an error or an unrecoverable response after automatic retries. The raw upstream body is never surfaced; the `code` field on the JSON body describes the failure category. |
| 503 | The chosen provider is unavailable. If the per-provider circuit breaker is open, the `X-VoxRouter-Breaker-State` header is present and `Retry-After` indicates when the breaker is expected to transition to half-open. |
| 504 | The upstream provider did not respond within the per-attempt deadline. |