Skip to main content
POST https://gateway.llm-stats.com/v1/tts/synthesize
Sends raw audio bytes back in the response — no polling, no follow-up requests.

Quickstart

import requests

response = requests.post(
    "https://gateway.llm-stats.com/v1/tts/synthesize",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "model_id": "eleven_v3",
        "text": "Hello, this is a test.",
        "format": "mp3",
        "sample_rate": 24000,
    },
)

with open("output.mp3", "wb") as f:
    f.write(response.content)

Request body

model_id
string
required
TTS model ID (e.g. eleven_v3, cartesia-sonic-2).
text
string
required
Text to synthesize.
voice_id
string
Provider-specific voice ID. Falls back to the model’s default voice when omitted.
format
"mp3" | "wav" | "opus" | "flac" | "aac"
default:"\"mp3\""
Container / codec for the returned audio.
sample_rate
integer
default:"24000"
Output sample rate in Hz.
speed
number
default:"1.0"
Playback speed multiplier where supported.

Response

The body is the raw audio file. Inspect Content-Type to confirm the codec:
formatContent-Type
mp3audio/mpeg
wavaudio/wav
opusaudio/opus
flacaudio/flac
aacaudio/aac

Streaming

For low-latency playback, open a WebSocket to wss://gateway.llm-stats.com/v1/tts/stream and follow the protocol described in the dashboard’s TTS playground. The HTTP endpoint above is the right choice for short, batch synthesis.

Errors

Failures use the shared error envelope. Common ones:
Statuserror.codeWhen
400invalid_inputMissing text, unsupported format, …
401unauthenticatedMissing or invalid API key.
402insufficient_quotaOut of credit.
429rate_limitedQuota exceeded — back off using Retry-After.
502provider_unavailableEvery TTS provider for this model errored.