Create speech
Synthesize speech from text and return a binary audio stream directly.
POST /v1/audio/speech
OpenAI-style speech synthesis. Requests must select a provider; Qwen TTS currently uses ali.
Back to Audio endpoint listRequest parameters
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Speech model ID, such as qwen-audio-3.0-tts-flash. |
input | string | Yes | Text to read aloud. |
voice | string | { id: string } | Yes | Preset voice name or a voice_id returned by the voice creation endpoint (send { id: voice_id }). |
provider | string | Yes | Provider ID; use ali for Qwen models. |
response_format | string | No | Output format: aac, flac, mp3, opus, pcm, or wav; defaults to mp3. |
format | string | No | Compatibility alias for response_format; both fields must match when supplied together. |
speed | number | No | Speech speed, from 0.25 to 4; defaults to 1. |
instructions | string | No | Delivery or voice style instructions; support depends on provider capability. |
Request examples
curl -X POST "https://api.globalrouter.com/v1/audio/speech" \
-H "Authorization: Bearer $GR_API_KEY" \
-H "Content-Type: application/json" \
-o speech.mp3 \
-d '{
"model": "qwen-audio-3.0-tts-flash",
"input": "GlobalRouter 统一模型接入。",
"voice": "longanlingxi",
"provider": "ali",
"response_format": "mp3",
"speed": 1
}'Response fields
| Field | Type | Required | Description |
|---|---|---|---|
Content-Type | header | Yes | Output audio MIME type. |
X-Generation-Id | header | Yes | Generation record ID for troubleshooting. |
body | binary | Yes | Binary audio stream; save to a file according to response_format. |
Response example
HTTP/1.1 200 OK Content-Type: audio/mpeg X-Generation-Id: gen_123 <binary audio stream>
Errors
| HTTP | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid Authorization Bearer token. |
| 403 | FORBIDDEN | The current API key is not allowed to call this scope or model. |
| 429 | RATE_LIMITED | Requests are too frequent or the asynchronous task queue is full; reduce concurrency or retry later. |
Notes
- Both preset voice names and voice.id are routed by provider; qwen-audio-3.0-tts-flash currently uses ali.
- For a custom voice, call POST /v1/audio/voices first, then send the returned id as voice: { id: "..." }.