Skip to content

Speech (Text-to-Speech)

Uses the standard Speech protocol format.

POST https://wrouter.ai/v1/audio/speech

Body

ParameterTypeRequiredNotes
modelstringe.g. tts-1, tts-1-hd, gpt-4o-mini-tts, cosyvoice-v1
inputstringText, ≤ 4096 chars
voicestringalloy, echo, fable, onyx, nova, shimmer, or vendor voices
response_formatstringmp3 (default), opus, aac, flac, wav, pcm
speednumber0.25–4.0, default 1.0

Response

Binary audio stream; Content-Type matches the chosen format (e.g. audio/mpeg).

Examples

bash
curl https://wrouter.ai/v1/audio/speech \
  -H "Authorization: Bearer $WROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"tts-1","input":"Hello, this is WRouter.","voice":"nova"}' \
  --output hello.mp3
python
from pathlib import Path
from openai import OpenAI
client = OpenAI(api_key="sk-...", base_url="https://wrouter.ai/v1")

resp = client.audio.speech.create(
    model="tts-1-hd",
    voice="alloy",
    input="Welcome to WRouter text-to-speech.",
)
Path("welcome.mp3").write_bytes(resp.content)