Text-to-Speech
Text-to-Speech
OpenRouter supports text-to-speech (TTS) via a dedicated /api/v1/audio/speech endpoint that is compatible with the OpenAI Audio Speech API. Send text and receive a raw audio byte stream in your chosen format.
Model Discovery
You can find TTS models in several ways:
Via the API
Use the output_modalities query parameter on the Models API to discover TTS models:
On the Models Page
Visit the Models page and filter by output modalities to find models capable of speech synthesis. Look for models that list "speech" in their output modalities.
API Usage
Send a POST request to /api/v1/audio/speech with the text you want to synthesize. The response is a raw audio byte stream — not JSON — so you can pipe it directly to a file or audio player.
Basic Example
Request Parameters
Provider-Specific Options
You can pass provider-specific options using the provider parameter. Options are keyed by provider slug, and only the options for the matched provider are forwarded:
Response Format
The TTS endpoint returns a raw audio byte stream, not JSON. The response includes the following headers:
Output Formats
Pricing
TTS models are priced per character of input text. Pricing varies by model and provider. You can check the per-character cost for each model on the Models page or via the Models API.
OpenAI SDK Compatibility
The TTS endpoint is fully compatible with the OpenAI SDK. You can use the OpenAI client libraries by pointing them at OpenRouter’s base URL:
Best Practices
- Choose the right format: Use
mp3for storage and general playback. Usepcmfor real-time streaming pipelines where latency matters - Voice selection: Different providers offer different voices. Check the model’s documentation or experiment with available voices to find the best fit for your use case
- Input length: For very long texts, consider splitting the input into smaller segments and concatenating the audio output. This can improve reliability and reduce latency for the first audio chunk
- Speed parameter: The
speedparameter is only supported by certain providers (e.g., OpenAI). It is silently ignored by providers that don’t support it
Troubleshooting
Empty or corrupted audio file?
- Verify the
response_formatmatches how you’re saving the file (e.g., don’t savepcmoutput with a.mp3extension) - Check the response status code — non-200 responses return JSON error bodies, not audio
Model not found?
- Use the Models page to find available TTS models
- Verify the model slug is correct (e.g.,
openai/gpt-4o-mini-tts-2025-12-15, notgpt-4o-mini-tts)
Voice not available?
- Available voices vary by provider. Check the provider’s documentation for supported voice identifiers
- Each model has its own set of voices — check the model’s page on the Models page for the full list