Speech Synthesis API Reference
OpenAI-compatible text-to-speech: one request synthesizes the whole audio clip and the response is raw audio bytes. Works with OpenAI TTS, Bailian Qwen-Audio-TTS, MiniMax and Volcengine speech models.
Note: The response is not JSON but raw audio; Content-Type follows response_format: mp3 → audio/mpeg, wav → audio/wav, pcm → audio/pcm, opus → audio/ogg. Valid voices depend on the model: Bailian Qwen-Audio-TTS uses voices such as longanhuan_v3.6, OpenAI TTS uses alloy / nova, so check the model's voice list. Provider-specific parameters can be passed through metadata.
Example model
Examples below use qwen-audio-3.0-tts-plus (Qwen Audio TTS Plus). Replace model and adjust size, quality, etc. per console docs when switching models.
Create speech
POST
https://token.easyapi.com/v1/audio/speechSynthesize the input text and return audio bytes directly. Streaming is not supported yet: stream_format=sse is answered with the complete clip.
Request parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
Authorization | header | string | Yes | EasyAPI API Key. Format: Bearer `API_KEY` |
Content-Type | header | string | Yes | Always application/json |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Speech model ID, e.g. qwen-audio-3.0-tts-plus, gpt-4o-mini-tts, tts-1 |
input | string | Yes | Text to synthesize; SSML / LaTeX supported where the model allows it |
voice | string | Yes | Voice name, model-specific; Bailian defaults to longanhuan_v3.6 |
response_format | string | No | Audio encoding: mp3 (default), wav, pcm, opus |
speed | number | No | Speed multiplier, mapped to Bailian rate (0.5–2.0) and clamped to that range |
instructions | string | No | Synthesis instruction for dialect, emotion or role, mapped to Bailian instruction |
metadata | object | No | Provider-native parameters passed through: volume(0-100), pitch(0.5-2.0), bit_rate(6-510, opus only), sample_rate, enable_ssml, word_timestamp_enabled, seed, language_hints, hot_fix, enable_aigc_tag; keys matching standard fields take precedence |
Example
{
"model": "qwen-audio-3.0-tts-plus",
"input": "你好,欢迎使用 EasyAPI 语音合成。",
"voice": "longanhuan_v3.6",
"response_format": "mp3",
"speed": 1.0,
"instructions": "用轻松自然的语气朗读"
}Response example
HTTP/1.1 200 OK
Content-Type: audio/mpeg
Content-Length: 258048
<二进制音频数据>Status codes
| Status code | Meaning | Description | Data model |
|---|---|---|---|
200 | OK | Audio bytes; Content-Type depends on response_format | audio/* |
400 | Bad request | Invalid parameter or rejected by upstream, e.g. unknown voice or empty text | ErrorResponse |
401 | Unauthorized | Missing or invalid API key | ErrorResponse |
402 | Insufficient quota | Account balance cannot cover this synthesis | ErrorResponse |
429 | Rate limited | Too many requests, retry later | ErrorResponse |
500 | Server error | Upstream or gateway failure, safe to retry | ErrorResponse |
Response: The gateway measures the audio duration: billing uses input characters and output audio duration, falling back to audio size when the duration cannot be parsed.