v2

latestOpenAPI 3.1.02026-08-0514431.6 KB

Synthesize speech

OpenAI-compatible TTS input. Speko maps the request into each eligible adapter's wire format and normalizes every provider to signed 16-bit mono PCM at 24 kHz. response_format selects raw PCM or a WAV container at the Speko edge. Model and voice are optional so a language-tagged accent route can supply them. The legacy gemini:gemini-3.1-flash-tts-preview model id remains accepted as an alias for google-tts:gemini-3.1-flash-tts-preview.

post/v1/audio/speech

Headers

X-Speko-Objective'latency' | 'quality' | 'cost' | 'balanced'

Routing objective. Defaults to the route policy.

X-Speko-Languagestring

BCP 47 language tag used for benchmark selection and provider transcription.

X-Speko-Allowstring

Comma-separated providers or provider:model ids to allow.

X-Speko-Denystring

Comma-separated providers or provider:model ids to exclude.

X-Speko-Max-Pricenumber

Maximum published benchmark price for the request stage: STT in USD per minute, LLM in USD per 1M tokens, or TTS in USD per 1M characters. Candidates without a published price are excluded when this constraint is set.

Request body

modelstring

Optional. Defaults to auto so a language-tagged accent route can supply the model. Legacy alias ids are accepted as input only; the route header and /v1/models report the canonical id.

instructionsstring

Optional TTS delivery direction. Used by Gemini TTS to control speaking style or accent without changing the transcript.

voicestring

Optional provider voice id or compatibility preset. Omit it when an X-Speko-Language accent route supplies the voice.

inputstring required
response_format'pcm' | 'pcm16' | 'wav'

Caller-facing container. pcm and pcm16 return raw signed 16-bit mono PCM at 24 kHz; wav adds a RIFF/WAVE header and buffers the complete response. Encoded formats are rejected before any upstream request.

Example request

{
  "model": "gpt-4o-mini-tts"
}

Response

Signed 16-bit mono PCM at 24 kHz, either raw or in a WAV container according to response_format.