GRGlobalRouter Docs
Console

Audio / POST

Create speech

Convert text into a binary audio stream, with optional voice cloning from reference audio in the same request.

POST /api/v1/audio/speech

Generate audio with Qwen Audio 3.0 TTS Flash. When input_references is supplied, GlobalRouter first creates a one-time voice from the reference audio, then synthesizes speech. The response is a file stream, not a JSON object.

Back to Audio endpoint list

Request parameters

FieldTypeRequiredDescription
modelstringYesAlways qwen-audio-3.0-tts-flash.
inputstringYesText to synthesize into speech.
voicestringNoPreset voice when input_references is omitted; otherwise a one-time voice is generated from the reference audio.
input_referencesarrayNoReference input array; input_audio enables voice cloning within the same request.
input_references[].typestringYes (when input_references is supplied)Always input_audio.
input_references[].input_audio.datastringYes (when input_references is supplied)Reference audio as a Base64 Data URI: data:audio/wav;base64,<BASE64>, data:audio/mpeg;base64,<BASE64>, or data:audio/mp4;base64,<BASE64>.
response_formatstringNoOutput format: mp3, pcm, wav, or opus; defaults to pcm.
speednumberNoSpeech speed, from 0.5 to 2; defaults to 1.
provider.provider_idstringYes when input_references is suppliedProvider selection; currently only ali is supported.
provider.options.ali.sample_rateintegerNoSample rate: 8000, 16000, 22050, 24000, 44100, or 48000.
provider.options.ali.volumeintegerNoVolume, from 0 to 100.
provider.options.ali.pitchnumberNoPitch, from 0.5 to 2.
provider.options.ali.seedintegerNoRandom seed, from 0 to 65535.
provider.options.ali.language_hintsstring[]NoSingle language hint, such as ["zh"].
provider.options.ali.instructionstringNoVoice style or delivery instructions.

Request examples

Create speech request examples
curl -X POST "https://api.globalrouter.com/api/v1/audio/speech" \
  -H "Authorization: Bearer $GR_API_KEY" \
  -H "Content-Type: application/json" \
  -o response.mp3 \
  -d '{
    "model": "qwen-audio-3.0-tts-flash",
    "input": "你好,欢迎使用 GlobalRouter。",
    "input_references": [
      {
        "type": "input_audio",
        "input_audio": {
          "data": "data:audio/wav;base64,<BASE64_AUDIO>"
        }
      }
    ],
    "response_format": "mp3",
    "speed": 1,
    "provider": {
      "provider_id": "ali"
    }
  }'

Response fields

FieldTypeRequiredDescription
Content-TypeheaderYesAudio MIME type: audio/mpeg, audio/pcm, audio/wav, or audio/ogg.
Content-DispositionheaderYesDownload filename with an extension matching response_format.
X-Generation-IdheaderYesGlobalRouter generation record ID for troubleshooting.
bodybinaryYesBinary audio file stream.

Response example

Response example
HTTP/1.1 200 OK
Content-Type: audio/mpeg
Content-Disposition: attachment; filename="speech.mp3"
X-Generation-Id: gen_123

<binary audio stream>

Errors

HTTPCodeDescription
400ROUTER_AUDIO_MODEL_UNSUPPORTEDmodel is not a currently supported TTS model.
400ROUTER_AUDIO_PROVIDER_UNSUPPORTEDprovider_id is not ali.
422validation_errorInvalid request format, such as an unsupported response_format or an out-of-range speed.

Notes

  • The endpoint requires an API key with tasks scope and permission to use the requested model.
  • Save the response file according to response_format; this endpoint does not return an audio URL in JSON.
  • input_references[].input_audio.data must be a complete Base64 Data URI, not bare Base64, a file path, or a remote URL. Supported formats are WAV, MP3, and M4A (audio/wav, audio/mpeg, audio/mp4), up to 10 MiB after decoding.
  • Voice cloning and synthesis complete in one request without returning a reusable voice_id. Use clear, continuous speech: at least 5 seconds is required, 10 to 20 seconds is recommended, and the maximum is 60 seconds.