ModelGo Unified Speech API Integration Guide & Examples
| Method | Path | Purpose |
|---|---|---|
POST | /v1/modelgo/audio/speech | Text to speech; on success the response body is the audio |
The Unified Speech API uses a shared set of parameter names. ModelGo translates them for each channel. The response body contains the synthesized audio.
Choose a model that lists modelgo_audio_speech in the Model Catalog for the site you are calling. The models below illustrate the request and response format. A model that does not offer the protocol returns 400 model_protocol_not_offered. If the catalog lists no eligible models, use an existing entrypoint such as OpenAI Speech, MiniMax, or ElevenLabs.
1. Synthesize speech
curl https://api.modelgo.ai/v1/modelgo/audio/speech \
-H "Authorization: Bearer $MODELGO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "speech-2.8-hd",
"input": "Hello, welcome to ModelGo.",
"voice": "English_Graceful_Lady",
"response_format": "mp3"
}' \
--output speech.mp3A success returns 200 and the audio file itself as the body (not JSON, not SSE):
| Response header | Meaning |
|---|---|
Content-Type | Set by the effective response_format: mp3 → audio/mpeg, wav → audio/wav, flac → audio/flac, pcm → audio/pcm (16-bit signed little-endian, mono) |
X-ModelGo-Usage-Characters | The number of characters this call is billed for; see Billing for how they are counted |
X-Request-Id | The request ID (gw_ + UUID), generated by the gateway; an X-Request-ID you send is only recorded for correlation |
Request fields
| Field | Type | Description |
|---|---|---|
model | string | Required. Logical model name |
input | string | Required. Text to synthesize; see the model limits for the maximum length |
voice | string | Voice ID from the model's voice list; may be omitted when the model declares a default voice |
response_format | string | Output format, such as mp3, wav, flac, pcm |
sample_rate | integer | Sample rate in Hz, such as 16000, 24000, 44100 |
speed | number | Speaking rate; 1.0 is normal |
volume | number | Volume |
pitch | number | Pitch |
language | string | Language hint |
instructions | string | Style instructions |
extensions | object | Model-specific parameters the model declares, such as {"stability": 0.5} |
user | string | Accepted and ignored; never forwarded to a channel |
stream is refused (unsupported_parameter), and any other top-level field not listed here is refused (unknown_parameter). JSON null counts as absent.
Each model accepts only the parameters it declares. A model declares which parameters it accepts, their allowed values and defaults, and which combinations are allowed. Requests are checked against the model before anything is reserved or any channel is called, and all problems are returned at once; for a voice or any other value outside a list, the allowed values come back in allowed (see Errors). Parameters you leave out take the model's defaults.
2. Model limits
These limits apply when the model offers the unified protocol.
MiniMax: speech-2.8-hd, speech-2.8-turbo
| Parameter | Supported | Default |
|---|---|---|
input | 1–1000 characters with mp3; 1–250 characters with pcm, wav, flac (Unicode characters) | — |
voice | Voices in the table below | male-qn-qingse (fresh-faced young man) |
response_format | mp3, pcm, flac, wav, all 32 kHz mono | mp3 |
speed | 0.5–2 | Channel default (1.0) |
With pcm, wav, or flac, an input longer than 250 characters is refused (400 invalid_parameter_combination). sample_rate, volume, pitch, language, instructions, and extensions are not supported. pcm is 16-bit signed little-endian. The length limits count Unicode characters, so a Chinese character counts as one; the billed count follows MiniMax's own rule, see Billing.
| Voice ID | Name | Voice ID | Name |
|---|---|---|---|
male-qn-qingse | Fresh-faced young man | male-qn-jingying | Elite young man |
male-qn-badao | Domineering young man | male-qn-daxuesheng | Young male college student |
female-shaonv | Young girl | female-yujie | Poised, mature woman |
female-chengshu | Mature woman | female-tianmei | Sweet woman |
presenter_male | Male presenter | presenter_female | Female presenter |
audiobook_male_1 | Male audiobook narrator 1 | audiobook_female_1 | Female audiobook narrator 1 |
English_Graceful_Lady | Graceful Lady (English) | English_Insightful_Speaker | Insightful Speaker (English) |
English_radiant_girl | Radiant Girl (English) | English_expressive_narrator | Expressive Narrator (English) |
The voices other than the four English_ voices are Chinese voices. Both models share these limits and this voice list, so a voice ID works unchanged when you switch models.
ElevenLabs: eleven-flash-v2.5, eleven-v4-turbo
If the model does not offer the unified protocol, use the ElevenLabs vendor endpoints.
| Parameter | Supported | Default |
|---|---|---|
input | 1–5000 characters (Unicode characters) | — |
voice | Voices in the table below | JBFqnCBsd6RMkjVDRZzb (George) |
response_format | mp3, pcm, wav | mp3 |
sample_rate | 16000, 22050, 24000, 44100; mp3 supports only 22050, 24000, 44100 | 44100 |
speed | 0.7–1.2 | Channel default (1.0) |
extensions.stability | 0–1 | Voice default |
extensions.similarity_boost | 0–1 | Voice default |
volume, pitch, language, and instructions are not supported. The mp3 bitrate follows the sample rate: 32 kbps at 22050 Hz, 48 kbps at 24000 Hz, and 128 kbps at 44100 Hz.
| Voice ID | Name | Voice ID | Name |
|---|---|---|---|
JBFqnCBsd6RMkjVDRZzb | George | 21m00Tcm4TlvDq8ikWAM | Rachel |
9BWtsMINqrJLrRacOk9x | Aria | CwhRBWXzGAHq8TQ4Fs17 | Roger |
EXAVITQu4vr4xnSDxMaL | Sarah | FGY2WhTYpPnrIDTdsKH5 | Laura |
IKne3meq5aSn9XLyUdCD | Charlie | N2lVS1w4EtoT3dr4eOWO | Callum |
SAz9YHcvj6GT2YYXdXww | River | TX3LPaxmHKxFdv7VOQHJ | Liam |
XB0fDUnXU5powFXDhCwa | Charlotte | Xb7hH8MSUJpSbSDYk0k2 | Alice |
XrExE9yKIg1WjnnlVkGX | Matilda | bIHbv24MWmeRgasZH58o | Will |
cgSgspJ2msm6clMCkdW9 | Jessica | cjVigY5qzO86Huf0OWal | Eric |
iP95p4xoKVk53GoZ742B | Chris | nPczCjzI2devNBz1zQrb | Brian |
onwK4e9ZLuTAKqWW03F9 | Daniel | pFZP5JQG7iQjIQuC4Bku | Lily |
pqHfZKP75CvOlQylNhV4 | Bill |
Both models share this voice list, so a voice ID works unchanged when you switch models.
3. Idempotent retries
Requests you may retry can carry an Idempotency-Key. Under the same API key, the same key with the same request body replays the last successful audio for 24 hours without calling the channel again or charging again; the same key with a different body returns 422. A failed request does not use up the key, so you can retry with the same key.
4. Errors
Request problems are returned together, before anything is reserved or any channel is called:
{
"error": {
"details": [
{ "param": "emotion", "code": "unknown_parameter", "reason": "parameter is not part of the unified speech protocol" },
{ "param": "stream", "code": "unsupported_parameter", "reason": "platform does not provide this capability" }
],
"message": "Parameter 'emotion': parameter is not part of the unified speech protocol",
"type": "invalid_request_error",
"param": "emotion",
"code": "unknown_parameter",
"metadata": {
"app_error_id": 4001,
"error_class": "client_unsupported_parameter",
"request_id": "gw_6b8e9d85-0584-4aea-a95c-93b113466259"
}
},
"trace_id": "291f2969d22a7ad70777b97a1ab6617e"
}error.param and error.code describe the first problem; error.details lists all of them.
code | Meaning |
|---|---|
unknown_parameter | The field is not part of the unified protocol |
unsupported_parameter | The platform or this model does not accept the parameter, including stream |
unsupported_value | The value is outside the model's list or range (including a voice not in the voice list, or input too long); list problems include allowed |
invalid_parameter_combination | The model does not allow this combination, such as MiniMax wav with an input over 250 characters, or ElevenLabs mp3 with 16000 |
unsupported_extension | extensions contains a parameter the model does not declare |
invalid_request_structure | Wrong type or structure, model or input missing, or input empty |
Other responses:
| HTTP | Meaning |
|---|---|
400 model_protocol_not_offered | The model does not offer the unified API |
401 / 402 / 403 / 429 | Authentication, balance or budget, policy, or rate limit; see Errors and rate limits |
503 | No channel can currently serve every parameter and voice the model offers; retry later |
502 / 504 | The channel failed or timed out; you are not charged |
5. Billing
- Billing is by the characters of
input, counted the way the model's supplier counts them: MiniMax counts a Chinese (Han) character as 2 and every other character, punctuation included, as 1; ElevenLabs counts Unicode characters. For example,你好,ModelGocounts as 12 characters on a MiniMax model (the two Chinese characters count 4, the other eight characters count 8). - The output format, sample rate, and audio length do not change the count. See "Model list" in the console for the unit price. The billed count is returned in the
X-ModelGo-Usage-Charactersheader. - The same count is reserved when the request arrives and charged once on success.
- Refused requests, failed syntheses, and timeouts are not charged; idempotent replays are not charged again.