Skip to main content
POST
openai-python

Authorizations

Authorization
string
header
required

An account API key. Send it as Authorization: Bearer <key>.

Body

application/json

The request body of POST /v1/audio/speech, answered with audio.

model
string
required

The speech model to synthesise with, named by its id or alias.

input
string
required

The text to read aloud, at most 32768 Unicode characters.

voice
string
required

The voice to read in, by the name the model knows it under.

models
string[] | null

Fallback models, tried in order when model cannot answer: none of its providers served it before the first audio byte. At most 3, and only the model that answered is billed. A NagaAI extension in OpenRouter's shape.

Maximum array length: 3
routing
object

How NagaAI picks the providers for this request: max_price removes the dearer ones and can fail the request. Takes no strategy. A NagaAI extension.

speed
number<double> | null

How fast to read, as a multiplier of the model's normal pace. Zero or less draws a 400.

instructions
string | null

Free-form direction for how the text should be delivered.

response_format
enum<string> | null

The audio container to synthesise into, which also sets the answer's Content-Type.

Available options:
mp3,
opus,
aac,
flac,
wav,
pcm
voice_sample
string | null

An https URL of a short recording of the voice to read in, for a model that clones a voice from a sample. A model that needs one answers 400 without it; a model with its own voices only reads in those. A NagaAI extension.

Maximum string length: 2048
speakers
object[] | null

The voices of a conversation, for a model that reads one: entry N reads the lines of input that start with Speaker N:. When set, it takes the place of voice and voice_sample. At most 4. A NagaAI extension.

Maximum array length: 4

Response

The synthesised audio itself, streamed as it is produced. Content-Type names the container response_format asked for, or audio/mpeg when the key was left out and the provider named none of its own.