Speko Docs
Text to speech

Synthesize speech

POST /v1/tts/speech — synthesize audio from text in one request.

Request

POST https://relay.speko.dev/v1/tts/speech

curl -s https://relay.speko.dev/v1/tts/speech \
  -H "Authorization: Bearer $SPEKO_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "routing": { "mode": "explicit", "provider": "cartesia", "model": "sonic-3" },
    "input": "Your order has shipped and will arrive on Thursday.",
    "audio": { "encoding": "pcm_s16le", "sample_rate_hz": 24000, "channels": 1 }
  }' \
  --output speech.pcm
routingobject

The routing object. Omit for auto/balanced.

inputstringrequired

The text to synthesize. Must be non-empty.

voicestring

Optional provider voice ID. When omitted, the route's default voice is used — useful in auto mode, where you cannot know which provider's voice ID space applies.

audioobjectrequired

Output format: encoding (pcm_s16le or opus), sample_rate_hz (8000–192000), channels (1–8).

Response

The response body is the raw audio stream (Content-Type: application/octet-stream). Route and usage information travel in headers:

HeaderMeaning
Speko-Usage-CharactersCharacters metered for this synthesis
Speko-Provider, Speko-Model, Speko-RegionThe route that served you
Speko-Request-ID, Speko-Attempt-IDCorrelation IDs

Language

Relay TTS is currently English-only. The speech request carries no language field, and routes are synthesized with language en. Speko's TTS quality boards are measured on English; other languages will arrive with a language field on the request shape.

Metering

TTS bills characters accepted for synthesis. A one-shot request accepts its entire input, so the metered quantity is the character count of input — reported back in Speko-Usage-Characters.

On this page