/v1/audio/speechGenerate speech (sync, short text)
Generate speech synchronously (fast lane). Returns 200 OK with audio bytes.
Sync limits: text up to 300 billable credits; voice (preset) or design mode only — clone returns 400 clone_not_supported_sync and srt: true returns 400 srt_not_supported_sync (both: use the async POST /v1/audio/jobs).
Billing: this endpoint is the realtime voice API and charges ceil(text characters × 1.3) credits (X-Credits-Charged includes the multiplier); the realtime WebSocket (per-utterance streaming) charges ceil(characters × 1.5).
Fast-lane semantics (first come, first served): the request is only accepted when the generation pool is completely idle — it then waits inside the same request for completion (typically ~5–15 s) and returns the bytes directly. When the pool is busy the endpoint fails closed with `503 {"error":"pool_cold"}` (nothing is billed) — use the async path. If the wait exceeds ~45 s the job is cooperatively cancelled and refunded — the endpoint returns 503 sync_timeout (with Retry-After; X-Request-Id kept for reconciliation). For guaranteed delivery use the async path.
Choose exactly one voice mode — they are mutually exclusive:
voice— a preset voice slug fromGET /v1/voices(recommended; all preset voices are Cantonese-optimized 香港聲線). Requires thetts:generatescope.design— describe a synthetic voice bygender+age. Accepted with thetts:generatescope or the finer-grainedtts:designscope (either one suffices, so existingtts:generatekeys keep working unchanged).clone— clone a voice from a base64reference_audiosample (requires thetts:clonekey scope). Onlyreference_audiois needed; the legacyprompt_textfield is retired (any value is ignored).
Sending more than one of voice / design / clone returns 400 voice_mode_conflict.
Request body · SpeechRequest (required)
| Field | Type | Required | Description |
|---|---|---|---|
modelstring · enum(1) · no | string · enum(1) | no | The TTS model. Currently only enum: cantogen-tts default: cantogen-tts |
voicestring · no | string | no | Preset voice slug from |
textstring · yes | string | yes | The text to speak (1–500 characters on the async endpoint; the sync |
pitchinteger · no | integer | no | DEPRECATED (2026-09-20) — no effect under raw audio delivery. Still accepted with unchanged range validation (−12…+12 semitones, default 0), but the value is ignored. default: 0 |
volumenumber · no | number | no | DEPRECATED (2026-09-20) — no effect under raw audio delivery. Still accepted with unchanged range validation (0–10, default 1), but the value is ignored. default: 1 |
emotionstring · enum(11) · no | string · enum(11) | no | Speaking emotion — one of the 11 prod canonical values (happy / angry / sad / surprise / fear / disgust / neutral / confused / anxious / affection / whisper). Legacy MiniMax values (fearful / disgusted / surprised / excited / gentle) are accepted and normalized. The Creator UI's Chinese emotion presets (雀躍 / 冷靜 …) are a separate gallery layer and are not API enum values. enum: happy · angry · sad · surprise · fear · disgust · neutral · confused · anxious · affection · whisper |
stylestring · no | string | no | Delivery style. Canonical values are English slugs — rhythm: steady / composed / rapid / slow / drawl / brisk / dynamic / staccato; timbre: mellow / cute / sharp / lazy / breathy / hoarse / deep / crisp / feeble / trembling; scene: corporate / promo / wedding / guide / expo / ad / tutorial / news / travel / audiobook / latenight / product / fairytale / podcast / storytelling / sports; character: animation-hero / stylish-uncle / astronaut / support-agent / boss / grandma / lottery-host / news-anchor / sage / late-dj / teacher / storyteller / market-commentator / sports-commentator / girl-next-door / smart-kid. The original Chinese preset values (明快 / 圓潤 / 講古 …) are still accepted as aliases — both are normalized internally to the same canonical value before reaching the engine. Any other free text also passes through. Merged into the engine style slot (order: style → emotion → instruction). |
instructionstring · no | string | no | Free-text delivery direction in Cantonese, Chinese or English — e.g. 「用興奮嘅語氣講,好似慶祝生日咁」. Applied after |
response_formatstring · enum(2) · no | string · enum(2) | no | Audio container format. Other formats return enum: mp3 · wav default: mp3 |
srtboolean · no | boolean | no | Also generate SRT subtitles. When default: false |
seedinteger · no | integer | no | Reserved. Accepted and validated as an integer but not yet used for reproducibility. |
sample_rateinteger · no | integer | no | Reserved. Accepted and validated as an integer but not yet applied. |
designDesignObject · no | DesignObject | no | |
cloneCloneObject · no | CloneObject | no |
curl -X POST "https://api.canto-gen.com/v1/audio/speech" \
-H "Authorization: Bearer $CANTOGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"cantogen-tts","voice":"sum","text":"你好,歡迎使用港嘢!","response_format":"mp3"}'Examples
{
"model": "cantogen-tts",
"voice": "sum",
"text": "你好,歡迎使用港嘢!",
"response_format": "mp3"
}{
"model": "cantogen-tts",
"design": {
"gender": "female",
"age": "young"
},
"text": "今日天氣幾好,一齊去行山啦。",
"style": "brisk",
"emotion": "happy"
}{
"model": "cantogen-tts",
"voice": "sum",
"text": "生日快樂!祝你心想事成!",
"instruction": "用興奮嘅語氣講,好似慶祝生日咁"
}Responses
Audio generated successfully. Body contains raw audio bytes.
Invalid request. See the error code for the reason.
{
"error": "invalid_model",
"message": "model must be \"cantogen-tts\"."
}{
"error": "voice_mode_conflict",
"message": "voice is mutually exclusive with design and clone."
}{
"error": "text_required",
"message": "text is required."
}{
"error": "text_too_long",
"message": "text exceeds 500 characters."
}{
"error": "unsupported_format",
"message": "response_format supports mp3 and wav (MVP)."
}{
"error": "invalid_emotion",
"message": "emotion must be one of: happy/angry/sad/surprise/fear/disgust/neutral/confused/anxious/affection/whisper."
}{
"error": "invalid_instruction",
"message": "instruction exceeds 500 characters."
}{
"error": "reference_audio_required",
"message": "clone.reference_audio is required."
}{
"error": "design_gender_and_age_required",
"message": "design.gender and design.age are required."
}{
"error": "invalid_srt",
"message": "srt must be a boolean."
}{
"error": "clone_not_supported_sync",
"hint": "use POST /v1/audio/jobs (async)"
}{
"error": "srt_not_supported_sync",
"hint": "use POST /v1/audio/jobs (async)"
}Missing, malformed, invalid or expired API key.
{
"error": "invalid_or_expired_token"
}Forbidden — the key lacks the required scope (clone requests need tts:clone; design requests accept tts:generate or tts:design), or the key's monthly credit cap is reached.
{
"error": "insufficient_scope",
"scope": "tts:clone"
}{
"error": "monthly_cap_reached",
"used": 100000
}Rate limit exceeded (per user per minute; all keys on the account count together, so creating extra keys does not raise the limit). Wait Retry-After seconds and retry.
{
"error": "rate_limit_exceeded",
"retry_after": 42
}The sync fast lane is unavailable, by error code: pool_cold = queue busy, request not accepted (nothing billed, no silent async fallback); sync_generation_failed = the job failed or was cancelled during the sync wait (already refunded); sync_timeout = the synchronous wait exceeded ~45 s — the job was cooperatively cancelled and will be refunded within seconds (response carries Retry-After; retry or go async; X-Request-Id is kept for reconciliation); jobs_unavailable = transient enqueue outage; service_unavailable = the voice engine is temporarily offline (maintenance or backend not ready), request not accepted and nothing billed (response carries Retry-After, default 60 s); rate_limit_unavailable = the rate-limit infrastructure is temporarily unavailable and the request was refused rather than letting ungoverned traffic through — likewise not accepted and nothing billed (Retry-After, default 5 s). For long text or guaranteed delivery submit via POST /v1/audio/jobs instead.
{
"error": "pool_cold",
"hint": "use POST /v1/audio/jobs (async)"
}