Search docs

Find any page, endpoint, or guide.

Generate speech from text

Alpha
POSThttps://api.voxrouter.ai/v1/audio/speech

Synthesize 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

AuthorizationstringRequired
Bearer token. Send as Authorization: Bearer pk_....
Content-TypestringRequired
Must be application/json.

Body

modelstringRequired
Provider-prefixed model id, `"{provider}/{model_id}"`.
inputstringRequired
Text to synthesize.
voicestringRequired
Provider-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_optionsobjectOptional
Passthrough 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.

StatusMeaning
400Request body failed validation or model string is malformed.
401Missing or invalid API key.
402Wallet 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.
429Per-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).
500Unexpected server error.
502The 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.
503The 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.
504The upstream provider did not respond within the per-attempt deadline.