ModelGo Unified Speech API Integration Guide & Examples

MethodPathPurpose
POST/v1/modelgo/audio/speechText 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

bash
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.mp3

A success returns 200 and the audio file itself as the body (not JSON, not SSE):

Response headerMeaning
Content-TypeSet 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-CharactersThe number of characters this call is billed for; see Billing for how they are counted
X-Request-IdThe request ID (gw_ + UUID), generated by the gateway; an X-Request-ID you send is only recorded for correlation

Request fields

FieldTypeDescription
modelstringRequired. Logical model name
inputstringRequired. Text to synthesize; see the model limits for the maximum length
voicestringVoice ID from the model's voice list; may be omitted when the model declares a default voice
response_formatstringOutput format, such as mp3, wav, flac, pcm
sample_rateintegerSample rate in Hz, such as 16000, 24000, 44100
speednumberSpeaking rate; 1.0 is normal
volumenumberVolume
pitchnumberPitch
languagestringLanguage hint
instructionsstringStyle instructions
extensionsobjectModel-specific parameters the model declares, such as {"stability": 0.5}
userstringAccepted 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

ParameterSupportedDefault
input1–1000 characters with mp3; 1–250 characters with pcm, wav, flac (Unicode characters)—
voiceVoices in the table belowmale-qn-qingse (fresh-faced young man)
response_formatmp3, pcm, flac, wav, all 32 kHz monomp3
speed0.5–2Channel 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 IDNameVoice IDName
male-qn-qingseFresh-faced young manmale-qn-jingyingElite young man
male-qn-badaoDomineering young manmale-qn-daxueshengYoung male college student
female-shaonvYoung girlfemale-yujiePoised, mature woman
female-chengshuMature womanfemale-tianmeiSweet woman
presenter_maleMale presenterpresenter_femaleFemale presenter
audiobook_male_1Male audiobook narrator 1audiobook_female_1Female audiobook narrator 1
English_Graceful_LadyGraceful Lady (English)English_Insightful_SpeakerInsightful Speaker (English)
English_radiant_girlRadiant Girl (English)English_expressive_narratorExpressive 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.

ParameterSupportedDefault
input1–5000 characters (Unicode characters)—
voiceVoices in the table belowJBFqnCBsd6RMkjVDRZzb (George)
response_formatmp3, pcm, wavmp3
sample_rate16000, 22050, 24000, 44100; mp3 supports only 22050, 24000, 4410044100
speed0.7–1.2Channel default (1.0)
extensions.stability0–1Voice default
extensions.similarity_boost0–1Voice 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 IDNameVoice IDName
JBFqnCBsd6RMkjVDRZzbGeorge21m00Tcm4TlvDq8ikWAMRachel
9BWtsMINqrJLrRacOk9xAriaCwhRBWXzGAHq8TQ4Fs17Roger
EXAVITQu4vr4xnSDxMaLSarahFGY2WhTYpPnrIDTdsKH5Laura
IKne3meq5aSn9XLyUdCDCharlieN2lVS1w4EtoT3dr4eOWOCallum
SAz9YHcvj6GT2YYXdXwwRiverTX3LPaxmHKxFdv7VOQHJLiam
XB0fDUnXU5powFXDhCwaCharlotteXb7hH8MSUJpSbSDYk0k2Alice
XrExE9yKIg1WjnnlVkGXMatildabIHbv24MWmeRgasZH58oWill
cgSgspJ2msm6clMCkdW9JessicacjVigY5qzO86Huf0OWalEric
iP95p4xoKVk53GoZ742BChrisnPczCjzI2devNBz1zQrbBrian
onwK4e9ZLuTAKqWW03F9DanielpFZP5JQG7iQjIQuC4BkuLily
pqHfZKP75CvOlQylNhV4Bill

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:

json
{
  "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.

codeMeaning
unknown_parameterThe field is not part of the unified protocol
unsupported_parameterThe platform or this model does not accept the parameter, including stream
unsupported_valueThe 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_combinationThe model does not allow this combination, such as MiniMax wav with an input over 250 characters, or ElevenLabs mp3 with 16000
unsupported_extensionextensions contains a parameter the model does not declare
invalid_request_structureWrong type or structure, model or input missing, or input empty

Other responses:

HTTPMeaning
400 model_protocol_not_offeredThe model does not offer the unified API
401 / 402 / 403 / 429Authentication, balance or budget, policy, or rate limit; see Errors and rate limits
503No channel can currently serve every parameter and voice the model offers; retry later
502 / 504The 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, 你好,ModelGo counts 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-Characters header.
  • 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.