GRGlobalRouter Docs
Console

Audio / POST

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 list

Request parameters

FieldTypeRequiredDescription
modelstringYesSpeech model ID, such as qwen-audio-3.0-tts-flash.
inputstringYesText to read aloud.
voicestring | { id: string }YesPreset voice name or a voice_id returned by the voice creation endpoint (send { id: voice_id }).
providerstringYesProvider ID; use ali for Qwen models.
response_formatstringNoOutput format: aac, flac, mp3, opus, pcm, or wav; defaults to mp3.
formatstringNoCompatibility alias for response_format; both fields must match when supplied together.
speednumberNoSpeech speed, from 0.25 to 4; defaults to 1.
instructionsstringNoDelivery or voice style instructions; support depends on provider capability.

Request examples

Create speech 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

FieldTypeRequiredDescription
Content-TypeheaderYesOutput audio MIME type.
X-Generation-IdheaderYesGeneration record ID for troubleshooting.
bodybinaryYesBinary audio stream; save to a file according to response_format.

Response example

Response example
HTTP/1.1 200 OK
Content-Type: audio/mpeg
X-Generation-Id: gen_123

<binary audio stream>

Errors

HTTPCodeDescription
401UNAUTHORIZEDMissing or invalid Authorization Bearer token.
403FORBIDDENThe current API key is not allowed to call this scope or model.
429RATE_LIMITEDRequests 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: "..." }.