Speech (Text-to-Speech)
Uses the standard Speech protocol format.
POST https://wrouter.ai/v1/audio/speechBody
| Parameter | Type | Required | Notes |
|---|---|---|---|
model | string | ✓ | e.g. tts-1, tts-1-hd, gpt-4o-mini-tts, cosyvoice-v1 |
input | string | ✓ | Text, ≤ 4096 chars |
voice | string | ✓ | alloy, echo, fable, onyx, nova, shimmer, or vendor voices |
response_format | string | mp3 (default), opus, aac, flac, wav, pcm | |
speed | number | 0.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.mp3python
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)