Canto-X1 情緒控制升級 — 11 種情緒,更傳神
廣東話出圖、剪輯、Gen片一條龍!1/1 截止
港嘢

Machine layer

API Reference

v1.0.0Last updated OpenAPI specllms.txtdocs.mdStep-by-step guide

The Canto-Gen public REST API for text-to-speech and audio transcription.

Canto-Gen (港嘢) turns Cantonese text into natural, native-sounding speech. Preset voices are Cantonese-optimized (廣東話為本).

Getting started

  1. Create an API key in Creator (「API 金鑰」).
  2. List available voices with GET /v1/voices.

Sync generation — one call returns the audio directly (short text, ≤300 billable chars):

bash
curl -X POST https://api.canto-gen.com/v1/audio/speech \
  -H "Authorization: Bearer sk_live_…" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "cantogen-tts",
    "voice": "sum",
    "text": "The weather is lovely today, let us go for a hike.",
    "response_format": "mp3"
  }'

Async generation — submit a job and poll (any size, bulk ≤25):

bash
# 1) Submit a job — returns 202 Accepted with a job_id
curl -X POST https://api.canto-gen.com/v1/audio/jobs \
  -H "Authorization: Bearer sk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"model":"cantogen-tts","voice":"sum","text":"The weather is lovely today, let us go for a hike."}'

# 2) Poll every 2–5 s until status becomes completed
curl -H "Authorization: Bearer sk_live_…" \
  https://api.canto-gen.com/v1/audio/jobs/{job_id}

# 3) Download the audio from the response's audio_url
curl -o speech.mp3 "$AUDIO_URL"

For the full step-by-step guide (keys, pricing, bulk, SRT subtitles), see the guide: [/v1/docs/en](/v1/docs/en).

All endpoints require an API key passed as a Bearer token, except GET /v1/voices (the public voice catalog, anonymous access allowed):

text
Authorization: Bearer sk_live_…

Create and manage keys in Creator under 「API 金鑰」 (API Keys). All keys share the sk_live_… prefix; free-plan keys are also subject to a daily generation limit, and any key can carry an optional monthly credit cap (unset = unlimited). Two complementary patterns:

  1. Sync (short text) — POST /v1/audio/speech returns 200 OK with the audio bytes directly in the response body while the sync queue is fully idle. Limited to 300 billable credits, voice/design modes only (no clone, no srt). While the sync queue is busy, requests honestly fail closed with 503 {"error":"pool_cold"} (nothing billed, no silent async fallback) — use the async endpoint instead; if a request was accepted but the wait exceeds ~45 s, the job is cooperatively cancelled and refunded — the endpoint returns 503 sync_timeout (with Retry-After). For guaranteed delivery use the async endpoint instead (since 2026-10-20, C3).
  2. Async (any size) — POST /v1/audio/jobs returns 202 Accepted with a job_id; poll GET /v1/audio/jobs/{id} every 2–5 s until completed, then download the pre-signed audio_url. Also accepts bulk submissions ({"items":[…]}, up to 25).

Errors

Errors use a stable error code with an optional message:

json
{ "error": "text_too_long", "message": "text exceeds 500 characters." }

Rate-limited requests return 429 with a Retry-After header (seconds).

Argument limits (REST)

  • text: async ≤ 500 characters; sync POST /v1/audio/speech ≤ 300 billable credits.
  • instruction ≤ 500 characters; synthesis order style → emotion → instruction (instruction has the final say).
  • style: English slugs (Chinese presets accepted as aliases); emotion: closed 11-value enum.
  • clone needs only reference_audio (base64; one request is capped at 4.4 MB ≈ 3 MB of audio — samples of at least 3 s) — prompt_text is retired (ignored); design uses gender + age; speed was removed (ignored).

Realtime WebSocket

wss://api.canto-gen.com/v1/audio/realtime

Canto-Gen also exposes a WebSocket realtime endpoint for text-in → streamed PCM audio-out. The protocol is based on OpenAI Realtime; Canto-Gen extension events/fields are marked as such.

js
// npm i ws
const WebSocket = require("ws");
const ws = new WebSocket("wss://api.canto-gen.com/v1/audio/realtime", {
  headers: { Authorization: `Bearer ${process.env.CANTOGEN_API_KEY}` },
});
ws.on("open", () => {
  ws.send(JSON.stringify({ type: "session.update", session: { voice: "sum", max_session_chars: 500 } }));
  ws.send(JSON.stringify({ type: "conversation.item.create",
    item: { type: "message", content: [{ type: "input_text", text: "你好,歡迎使用港嘢!" }] } }));
});
ws.on("message", (raw) => {
  const ev = JSON.parse(raw.toString());
  if (ev.type === "response.output_audio.delta") play(Buffer.from(ev.delta, "base64")); // PCM16 @ 48 kHz
  if (ev.type === "response.done") ws.close();
});

Realtime limits

  • idle_timeout_seconds: 120
  • max_session_duration_seconds: 300 (free) / unlimited (paid)
  • max_sessions_per_user: free 1 / lite 2 / starter 3 / pro 4 / studio 5 / enterprise 5
  • max_sessions_global: 8
  • max_session_chars_default: free 2000 / paid 20000
  • max_in_flight_utterances: 3
  • raw_chars_per_session: 20000
  • raw_chars_per_minute: 5000
  • utterance_lease_seconds: 60
  • max_frame_bytes: 65536

Beyond REST, a realtime WebSocket endpoint (OpenAI Realtime base + Canto-Gen extensions) is available: wss://api.canto-gen.com/v1/audio/realtime — see the x-realtime-websocket extension and the Realtime WebSocket section of /v1/docs/en. An ASR realtime transcription WebSocket is also available: wss://api.canto-gen.com/v1/asr/realtime (audio-in → transcript-out, HK$1.40/audio-hour) — see x-asr-realtime-websocket.

Authentication

Base URL: https://api.canto-gen.com

All endpoints require an API key passed as a Bearer token, except GET /v1/voices (the public voice catalog, anonymous access allowed):

text
Authorization: Bearer sk_live_…

Create and manage keys in Creator under 「API 金鑰」 (API Keys). All keys share the sk_live_… prefix; free-plan keys are also subject to a daily generation limit, and any key can carry an optional monthly credit cap (unset = unlimited).

Authorization
Authorization: Bearer $CANTOGEN_API_KEY

Speech

Text-to-speech generation
POST/v1/audio/speech

Generate 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 from GET /v1/voices (recommended; all preset voices are Cantonese-optimized 香港聲線). Requires the tts:generate scope.
  • design — describe a synthetic voice by gender + age. Accepted with the tts:generate scope or the finer-grained tts:design scope (either one suffices, so existing tts:generate keys keep working unchanged).
  • clone — clone a voice from a base64 reference_audio sample (requires the tts:clone key scope). Only reference_audio is needed; the legacy prompt_text field is retired (any value is ignored).

Sending more than one of voice / design / clone returns 400 voice_mode_conflict.

Request body · SpeechRequest (required)

FieldDescription
modelstring · enum(1) · no

The TTS model. Currently only cantogen-tts exists; other values return 400 invalid_model.

enum: cantogen-tts

default: cantogen-tts

voicestring · no

Preset voice slug from GET /v1/voices. Required unless design or clone is used.

textstring · yes

The text to speak (1–500 characters on the async endpoint; the sync POST /v1/audio/speech caps at 300 billable credits). Cantonese text works best — 廣東話字正腔圓. Supports inline tone tags: insert [label] in the script, e.g. [笑聲]你好[唷!] — closed set of 15 tags (see the API guide, Inline tone tags). Unknown bracket tokens pass through untouched.

pitchinteger · 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

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

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

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

Free-text delivery direction in Cantonese, Chinese or English — e.g. 「用興奮嘅語氣講,好似慶祝生日咁」. Applied after style and emotion, so it has the final say on how the line is delivered. Values over 500 characters return 400 invalid_instruction.

response_formatstring · enum(2) · no

Audio container format. Other formats return 400 unsupported_format.

enum: mp3 · wav

default: mp3

srtboolean · no

Also generate SRT subtitles. When true, a completed job's srt field carries the subtitle content (billed at a higher credit rate).

default: false

seedinteger · no

Reserved. Accepted and validated as an integer but not yet used for reproducibility.

sample_rateinteger · no

Reserved. Accepted and validated as an integer but not yet applied.

designDesignObject · no
cloneCloneObject · no
cURL
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

Preset voice (simplest usage)
{
  "model": "cantogen-tts",
  "voice": "sum",
  "text": "你好,歡迎使用港嘢!",
  "response_format": "mp3"
}
Designed voice by gender + age (tts:generate or tts:design scope)
{
  "model": "cantogen-tts",
  "design": {
    "gender": "female",
    "age": "young"
  },
  "text": "今日天氣幾好,一齊去行山啦。",
  "style": "brisk",
  "emotion": "happy"
}
Free-text delivery direction
{
  "model": "cantogen-tts",
  "voice": "sum",
  "text": "生日快樂!祝你心想事成!",
  "instruction": "用興奮嘅語氣講,好似慶祝生日咁"
}

Responses

200

Audio generated successfully. Body contains raw audio bytes.

400

Invalid request. See the error code for the reason.

invalid_model
{
  "error": "invalid_model",
  "message": "model must be \"cantogen-tts\"."
}
voice_mode_conflict
{
  "error": "voice_mode_conflict",
  "message": "voice is mutually exclusive with design and clone."
}
text_required
{
  "error": "text_required",
  "message": "text is required."
}
text_too_long
{
  "error": "text_too_long",
  "message": "text exceeds 500 characters."
}
unsupported_format
{
  "error": "unsupported_format",
  "message": "response_format supports mp3 and wav (MVP)."
}
invalid_emotion
{
  "error": "invalid_emotion",
  "message": "emotion must be one of: happy/angry/sad/surprise/fear/disgust/neutral/confused/anxious/affection/whisper."
}
invalid_instruction
{
  "error": "invalid_instruction",
  "message": "instruction exceeds 500 characters."
}
reference_audio_required
{
  "error": "reference_audio_required",
  "message": "clone.reference_audio is required."
}
design_gender_and_age_required
{
  "error": "design_gender_and_age_required",
  "message": "design.gender and design.age are required."
}
invalid_srt
{
  "error": "invalid_srt",
  "message": "srt must be a boolean."
}
clone_not_supported_sync
{
  "error": "clone_not_supported_sync",
  "hint": "use POST /v1/audio/jobs (async)"
}
srt_not_supported_sync
{
  "error": "srt_not_supported_sync",
  "hint": "use POST /v1/audio/jobs (async)"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
403

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.

insufficient_scope
{
  "error": "insufficient_scope",
  "scope": "tts:clone"
}
monthly_cap_reached
{
  "error": "monthly_cap_reached",
  "used": 100000
}
429

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.

application/json
{
  "error": "rate_limit_exceeded",
  "retry_after": 42
}
503

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.

application/json
{
  "error": "pool_cold",
  "hint": "use POST /v1/audio/jobs (async)"
}

Jobs

Speech job status
GET/v1/audio/jobs

List your generation records

List your own speech generation records (newest first) — an API-only customer can review what they submitted without logging into the web console.

  • Owner-scoped: only records belonging to your key are returned (other accounts are never exposed).
  • Pagination: limit (1–100, default 20) and before (the cursor = the id of the last record on the previous page). next_before is the cursor for the next page; null means there is no further page.
  • `status` filter (optional): queued / processing / cancelling / done / error / cancelled.
  • `text_preview`: a bounded preview (max 120 characters) of the text you generated — read the full text from GET /v1/audio/jobs/{id} or keep your own copy.
  • `duration_ms`: the audio duration in milliseconds (null until the job has produced audio).

⚠️ status uses the raw job status values (done / error / …), while the polling surface GET /v1/audio/jobs/{id} uses the public names (completed / failed / …) — check which endpoint you are reading.

Path & query parameters

FieldDescription
limitinteger · no

Records per page (1–100, default 20).

default: 20

beforestring · uuid · no

Cursor — the id of the last record on the previous page; older records resume from here.

statusstring · enum(6) · no

Return only records in this state (optional; raw job status values).

enum: queued · processing · cancelling · done · error · cancelled

cURL
curl "https://api.canto-gen.com/v1/audio/jobs" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

Your generation records (newest first).

application/json
{
  "jobs": [
    {
      "id": "b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b",
      "status": "done",
      "created_at": "2026-10-29T09:12:00.000Z",
      "voice_slug": "sum",
      "duration_ms": 4200,
      "text_preview": "你好,歡迎使用港嘢!"
    }
  ],
  "next_before": null
}
400

Invalid parameter — invalid_limit (limit is not an integer between 1 and 100) / invalid_cursor (before is not one of your job ids) / invalid_status (status is outside the allowed set).

invalid_limit
{
  "error": "invalid_limit"
}
invalid_cursor
{
  "error": "invalid_cursor"
}
invalid_status
{
  "error": "invalid_status"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
403

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.

application/json
{
  "error": "insufficient_scope",
  "scope": "tts:generate | tts:design"
}
503

Transient backend issue (queue/billing infrastructure). Retry with backoff.

application/json
{
  "error": "jobs_unavailable"
}
POST/v1/audio/jobs

Submit a speech job (async)

Submit a speech job for asynchronous generation. Returns 202 Accepted with a job_id and poll_url; poll GET /v1/audio/jobs/{id} until the job completes.

Bulk: send {"items": [ …up to 25 request bodies… ]} to submit a batch — validation is all-or-nothing (any invalid item rejects the whole request with 400 invalid_items); after enqueue, failures are per-item and the 202 body reports each entry ({index, job_id, …} or {index, status: "failed", error}).

Choose exactly one voice mode — they are mutually exclusive:

  • voice — a preset voice slug from GET /v1/voices (recommended; all preset voices are Cantonese-optimized 香港聲線). Requires the tts:generate scope.
  • design — describe a synthetic voice by gender + age. Accepted with the tts:generate scope or the finer-grained tts:design scope (either one suffices, so existing tts:generate keys keep working unchanged).
  • clone — clone a voice from a base64 reference_audio sample (requires the tts:clone key scope). Only reference_audio is needed; the legacy prompt_text field is retired (any value is ignored).

Sending more than one of voice / design / clone returns 400 voice_mode_conflict.

Path & query parameters

FieldDescription
Idempotency-Keystring · no

Retry-safety key. Replaying the same value returns 409 duplicate_request (nothing resubmitted, nothing re-billed); any string works (UUIDs are used as the job id, other strings are mapped deterministically via UUIDv5). Omit it and every request is a fresh submission.

Request body · SpeechRequest (required)

FieldDescription
modelstring · enum(1) · no

The TTS model. Currently only cantogen-tts exists; other values return 400 invalid_model.

enum: cantogen-tts

default: cantogen-tts

voicestring · no

Preset voice slug from GET /v1/voices. Required unless design or clone is used.

textstring · yes

The text to speak (1–500 characters on the async endpoint; the sync POST /v1/audio/speech caps at 300 billable credits). Cantonese text works best — 廣東話字正腔圓. Supports inline tone tags: insert [label] in the script, e.g. [笑聲]你好[唷!] — closed set of 15 tags (see the API guide, Inline tone tags). Unknown bracket tokens pass through untouched.

pitchinteger · 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

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

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

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

Free-text delivery direction in Cantonese, Chinese or English — e.g. 「用興奮嘅語氣講,好似慶祝生日咁」. Applied after style and emotion, so it has the final say on how the line is delivered. Values over 500 characters return 400 invalid_instruction.

response_formatstring · enum(2) · no

Audio container format. Other formats return 400 unsupported_format.

enum: mp3 · wav

default: mp3

srtboolean · no

Also generate SRT subtitles. When true, a completed job's srt field carries the subtitle content (billed at a higher credit rate).

default: false

seedinteger · no

Reserved. Accepted and validated as an integer but not yet used for reproducibility.

sample_rateinteger · no

Reserved. Accepted and validated as an integer but not yet applied.

designDesignObject · no
cloneCloneObject · no
cURL
curl -X POST "https://api.canto-gen.com/v1/audio/jobs" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"cantogen-tts","voice":"sum","text":"你好,歡迎使用港嘢!","response_format":"mp3"}'

Examples

Preset voice (simplest usage)
{
  "model": "cantogen-tts",
  "voice": "sum",
  "text": "你好,歡迎使用港嘢!",
  "response_format": "mp3"
}
Voice clone (requires tts:clone scope)
{
  "model": "cantogen-tts",
  "clone": {
    "reference_audio": "data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQAAAAA="
  },
  "text": "用我把聲講呢句嘢。"
}
Bulk submission (up to 25 items)
{
  "items": [
    {
      "model": "cantogen-tts",
      "voice": "sum",
      "text": "第一句。"
    },
    {
      "model": "cantogen-tts",
      "design": {
        "gender": "male",
        "age": "adult"
      },
      "text": "第二句。"
    }
  ]
}

Responses

202

Job accepted. Single request → {job_id, status, poll_url, srt_requested}; bulk → {jobs: [{index, job_id, status, poll_url, srt_requested} | {index, status: "failed", error}]}.

application/json
{
  "job_id": "b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b",
  "status": "queued",
  "poll_url": "/v1/audio/jobs/b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b",
  "srt_requested": false
}
400

Invalid request — translation-layer codes, or too_many_items (>25) / invalid_items (bulk all-or-nothing validation).

too_many_items
{
  "error": "too_many_items",
  "max": 25,
  "got": 26
}
invalid_items
{
  "error": "invalid_items",
  "items": [
    {
      "index": 1,
      "error": "text_required"
    }
  ]
}
voice_mode_conflict
{
  "error": "voice_mode_conflict",
  "message": "voice is mutually exclusive with design and clone."
}
text_too_long
{
  "error": "text_too_long",
  "message": "text exceeds 500 characters."
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
402

The account's credit pool is exhausted.

application/json
{
  "error": "character_limit_reached",
  "remaining": 0
}
403

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.

insufficient_scope
{
  "error": "insufficient_scope",
  "scope": "tts:clone"
}
monthly_cap_reached
{
  "error": "monthly_cap_reached",
  "used": 100000
}
429

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.

application/json
{
  "error": "rate_limit_exceeded",
  "retry_after": 42
}
503

Transient backend issue (queue/billing infrastructure). Retry with backoff.

application/json
{
  "error": "jobs_unavailable"
}
GET/v1/audio/jobs/{id}

Get job status

Fetch the status of a speech job created with POST /v1/audio/jobs.

Poll until status becomes completed or failed. When the job is completed, audio_url carries a pre-signed download URL for the audio. When subtitles were requested (srt_requested: true) and the job completes, the srt field carries the SRT subtitle content.

Path & query parameters

FieldDescription
idstring · yes

The job_id returned by POST /v1/audio/jobs.

cURL
curl "https://api.canto-gen.com/v1/audio/jobs/b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

Current job state. srt is attached once subtitles are ready.

application/json
{
  "job_id": "b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b",
  "status": "completed",
  "poll_url": "/v1/audio/jobs/b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b",
  "srt_requested": true,
  "srt": "1\n00:00:00,000 --> 00:00:02,400\n你好,歡迎使用港嘢!"
}
400

Malformed job id.

application/json
{
  "error": "invalid_job_id"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
404

No job exists with this id (or it belongs to another key).

application/json
{
  "error": "job_not_found"
}
DELETE/v1/audio/jobs/{id}

Cancel a job / delete a finished job record

Handles a speech job created with POST /v1/audio/jobs via DELETE. Dual semantics, split by the job's state:

① The job is still running (`queued`/`processing`/`cancelling`) → cancel (spec §4.4):

  • queued → 200: cancelled immediately and fully refunded (refunded is the actual number of credits refunded).
  • processing → 202: the cancellation was accepted and the job winds down — polling then shows cancelling before it settles as cancelled.

② The job has settled (`completed`/`failed`/`cancelled`) → delete the job record:

  • 200 { id, object: "job", deleted: true }: the job record (including the text you generated), the audio file and its subtitle sidecars (.srt/.vtt/.json) are deleted immediately — there is no restore, and the data is physically purged within 30 days (in practice it is removed right away).
  • Order: the database record is deleted first, then the audio object.

You can only handle jobs owned by your key; an unknown or foreign id returns 404 job_not_found (which does not reveal whether the id exists).

Path & query parameters

FieldDescription
idstring · yes

The job_id returned by POST /v1/audio/jobs.

cURL
curl -X DELETE "https://api.canto-gen.com/v1/audio/jobs/b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

The job had not started — cancelled immediately and fully refunded.

cancelled
{
  "ok": true,
  "status": "cancelled",
  "refunded": 1234
}
deleted
{
  "id": "b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b",
  "object": "job",
  "deleted": true
}
202

Cancellation accepted — the in-flight job winds down; polling shows cancelling before it settles as cancelled.

application/json
{
  "ok": true,
  "status": "cancelling"
}
400

Malformed job id.

application/json
{
  "error": "invalid_job_id"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
404

No job exists with this id (or it belongs to another key).

application/json
{
  "error": "job_not_found"
}

Voices

Voice catalog
DELETE/v1/voices/{id}

Delete one of your voices

Deletes one of your own voices (created with POST /api/voice-gallery/upload or the voice-design flow). {id} may be the voice's slug or its uuid id — both are identifiers you already have.

  • Effective immediately: the voice disappears from every listing and can no longer be used for generation.
  • Permanently purged: the reference audio and the prepared-reference cache copies of it are deleted right away — there is no restore, and the data is physically purged within 30 days (in practice it is removed right away).
  • Official preset voices (the ones from GET /v1/voices) can never be deleted — they return 404 not_found, exactly like a voice owned by another key (the id's existence is never revealed).
  • You can only delete voices owned by your key; an unknown or foreign id returns 404 not_found.
  • A generation is still running for this voice → it is not deleted and the request returns 409 voice_busy (deleting it would break the running job). Delete it again once that job has finished.
  • Requires the voices:manage scope (a key without it returns 403 insufficient_scope).
  • Order: the database record is deleted first, then the audio object.

Path & query parameters

FieldDescription
idstring · yes

The voice's slug (e.g. u-1a2b3c4d-9f8e7d6c) or its uuid id.

cURL
curl -X DELETE "https://api.canto-gen.com/v1/voices/u-1a2b3c4d-9f8e7d6c" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

Deleted — the voice took effect immediately (it no longer appears in any listing and can no longer generate) and its files were purged.

application/json
{
  "id": "b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b",
  "object": "voice",
  "slug": "u-1a2b3c4d-9f8e7d6c",
  "deleted": true
}
400

Invalid id (empty or too long).

application/json
{
  "error": "invalid_id"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
403

The key lacks the voices:manage scope.

application/json
{
  "error": "insufficient_scope"
}
404

Unknown id (or owned by another key, or an official preset voice — none of these are distinguished, so the id's existence is never revealed).

application/json
{
  "error": "not_found"
}
409

A generation is still running for this voice, so it was not deleted (that would break the running job). Delete it once the job has finished.

application/json
{
  "error": "voice_busy"
}
503

Temporarily unavailable. Retry shortly.

application/json
{
  "error": "deletion_failed"
}
GET/v1/voices

List voices

List the official voice catalog. All preset voices are Cantonese-optimized (廣東話優化) — use each voice's slug as the voice parameter of POST /v1/audio/speech (sync) or POST /v1/audio/jobs (async).

preview_url streams a short sample without extra auth.

cURL
curl "https://api.canto-gen.com/v1/voices" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

The official voice catalog.

application/json
{
  "voices": [
    {
      "slug": "sum",
      "name": "心妍",
      "gender": "female",
      "age": "adult",
      "styles": [],
      "preview_url": "https://canto-gen.com/api/voice-clip?slug=sum"
    }
  ]
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
503

Voice catalog temporarily unavailable.

application/json
{
  "error": "voice_gallery_unavailable"
}

Transcription

Audio transcription
POST/v1/asr/transcribe

Transcribe audio to text

Upload an audio file and receive the transcript synchronously in the same request. Canonical path: /v1/asr/transcribe — OpenAI-compatible clients may keep using

Fields: file (required, the audio file), model (required), language (optional, ISO-639-1), response_format (json default / text). srt and verbose_json need segment-level timestamps and are not yet supported — they return 400 unsupported_response_format. Transcription is currently Cantonese-optimized.

Billing: billed by audio duration in credits (1 credit = HK$0.001) — HK$0.80 per hour for file transcription, charged per second with no rounding up. Order: ① plan monthly credits (5,000/month on Free) → ② prepaid wallet credits (may overdraw to −HK$5) → ③ with auto top-up enabled, one automatic top-up and retry when short; otherwise 402 insufficient_balance (nothing processed, nothing billed). The estimated amount is held before processing and settled on the actual duration when done; failures, timeouts and outages are refunded in full (success-only billing). GET /v1/balance returns your balance and the current rates.

No recognizable speech (silence, pure music, background noise): the engine still completes — the request returns 200 with an empty text ("") and is billed on the actual audio duration (mainstream industry convention — a valid result, not an error; response_format=text returns an empty string).

Auth: any valid API key works on the ASR surface (including jobs, retrieval and the realtime token — there is no separate asr: scope; single-key model).

Limits (sync-window pregate, C3 2026-10-20): the effective per-file cap on the synchronous route is 4.5 MB (platform request-body limit; exceeding it returns a platform-level 413 — compress first with 16 kHz mono Opus 16k, one file fits ≈60 minutes of audio); the synchronous delivery cap is 8 minutes (480 seconds) of audio — probed duration over it returns 400 audio_too_long (with duration_seconds + async_endpoint, rejected before processing — nothing billed); the per-request audio policy cap is 4 hours (over it returns 413 payload_too_large).

No daily audio-duration cap (every plan alike since 2026-10-30): usage is bounded by the plan credits quota plus the prepaid wallet — each request holds the measured duration up front and settles on the actual duration afterwards. Free plans still get 50 generation submissions per day, counted separately from TTS (over it returns 429 sandbox_daily_limit).

Long-audio path: POST /v1/asr/jobs (async, audio_url/storage_path up to 500 MB / 4 hours) — returns 202 queued immediately; poll GET /v1/asr/transcriptions/{id} for the transcript. Same credits-then-wallet billing semantics.

Request body · TranscriptionRequest (required)

FieldDescription
filestring · binary · yes

The audio file to transcribe (wav, mp3, m4a/mp4, webm, ogg, flac). Max 4.5 MB effective (platform request-body cap); for longer audio use POST /v1/asr/jobs with audio_url or storage_path (up to 500 MB).

modelstring · yes

Transcription model name. Required by the API shape; any non-empty value is accepted — the current release offers a single Cantonese-optimized transcription model (cantogen-asr).

languagestring · no

Optional ISO-639-1 language hint. Accepted as-is; transcription is currently Cantonese-optimized.

response_formatstring · enum(2) · no

json (default) returns the structured object; text returns plain text. Segment-timestamp formats (srt, verbose_json) are not yet supported and return 400 unsupported_response_format.

enum: json · text

default: json

vocabularyarray · no

Optional keyword-biasing list (up to 50 terms, each ≤30 chars after trim). Grant-gated: only accounts with the asr_vocabulary entitlement have it applied — without the grant the field is silently ignored and the request is processed exactly as if it were absent. On multipart requests send a JSON-encoded string array (e.g. '["term1","term2"]'). Stored default (API key requests): when the parameter is omitted, the vocabulary stored for your account (PUT /v1/asr/vocabulary) is applied automatically; when the parameter is present — including an empty array — the request value wins (an empty array means no biasing, it does not fall back to the stored list).

cURL
curl -X POST "https://api.canto-gen.com/v1/asr/transcribe" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file":"(binary audio file)","model":"cantogen-asr","response_format":"json"}'

Examples

Transcribe an audio file
{
  "file": "(binary audio file)",
  "model": "cantogen-asr",
  "response_format": "json"
}

Responses

200

Transcription succeeded.

application/json
{
  "id": "b7e6f2a1-4c3d-4e5f-8a9b-0c1d2e3f4a5b",
  "object": "transcription",
  "text": "今日天氣幾好,一齊去行山啦。",
  "duration_seconds": 1830,
  "charged_hkd": 0.4067
}
400

Invalid request — invalid_request (multipart missing file/model, an empty file, or an unsupported audio type), unsupported_response_format (response_format currently supports json/text only), or audio_too_long (audio exceeds the 8-minute/480-second synchronous delivery cap — the response carries duration_seconds + async_endpoint: /v1/asr/jobs; rejected before processing, nothing billed. Use POST /v1/asr/jobs for long audio).

invalid_request
{
  "error": "invalid_request",
  "message": "file field is required."
}
unsupported_response_format
{
  "error": "unsupported_response_format",
  "message": "Supported formats: json, text. Segment-timestamp formats are not yet supported."
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
402

The plan credits quota and prepaid wallet together cannot cover the hold for this transcription (nothing was processed, nothing billed). Top up at /account/billing and retry.

application/json
{
  "error": "insufficient_balance",
  "message": "Top up your prepaid balance and retry."
}
413

The audio exceeds the platform request-body cap (4.5 MB) — compress first (16 kHz mono Opus 16k, ≈33–40 min per 4.5 MB) or use POST /v1/asr/jobs (audio_url/storage_path up to 500 MB / 4 hours, async).

application/json
{
  "error": "payload_too_large",
  "message": "Audio exceeds the 4.5 MB request-body cap — compress (Opus 16k) or use POST /v1/asr/jobs."
}
503

The transcription service is temporarily unavailable (duration-probe, billing or pipeline failure; engine queueing/degradation within the sync window also lands here — transient, carries Retry-After, retry shortly). Any hold is refunded in full — success-only billing.

engine_unavailable
{
  "error": "engine_unavailable"
}
billing_unavailable
{
  "error": "engine_unavailable",
  "message": "billing_unavailable"
}
POST/v1/asr/jobs

Submit a transcription job (upfront async)

Returns 202 queued immediately — no sync wait. Three entry modes: multipart file (≤4.5 MB platform cap), JSON audio_url (server-side fetch — bypasses the 4.5 MB cap; https only, up to 500 MB / 4 hours, private addresses rejected), or JSON storage_path (browser session only — the Creator large-file lane; API-key callers sending it get 400). Then poll GET /v1/asr/transcriptions/{id}: queued → processing → completed (text / duration_seconds present) / failed (error present). No recognizable speech (silence / pure music) still completes with an empty text ("") and is billed — same convention as the sync route; a valid result, not an error. The wallet hold is settled on actual duration the first time completed is observed (idempotent). Billing matches /v1/asr/transcribe: HK$0.80/hour, per-second, success-only.

Request body · TranscriptionRequest (required)

FieldDescription
filestring · binary · yes

The audio file to transcribe (wav, mp3, m4a/mp4, webm, ogg, flac). Max 4.5 MB effective (platform request-body cap); for longer audio use POST /v1/asr/jobs with audio_url or storage_path (up to 500 MB).

modelstring · yes

Transcription model name. Required by the API shape; any non-empty value is accepted — the current release offers a single Cantonese-optimized transcription model (cantogen-asr).

languagestring · no

Optional ISO-639-1 language hint. Accepted as-is; transcription is currently Cantonese-optimized.

response_formatstring · enum(2) · no

json (default) returns the structured object; text returns plain text. Segment-timestamp formats (srt, verbose_json) are not yet supported and return 400 unsupported_response_format.

enum: json · text

default: json

vocabularyarray · no

Optional keyword-biasing list (up to 50 terms, each ≤30 chars after trim). Grant-gated: only accounts with the asr_vocabulary entitlement have it applied — without the grant the field is silently ignored and the request is processed exactly as if it were absent. On multipart requests send a JSON-encoded string array (e.g. '["term1","term2"]'). Stored default (API key requests): when the parameter is omitted, the vocabulary stored for your account (PUT /v1/asr/vocabulary) is applied automatically; when the parameter is present — including an empty array — the request value wins (an empty array means no biasing, it does not fall back to the stored list).

cURL
curl -X POST "https://api.canto-gen.com/v1/asr/jobs" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file":"(binary audio file)","model":"cantogen-asr","response_format":"json"}'

Examples

Transcribe an audio file
{
  "file": "(binary audio file)",
  "model": "cantogen-asr",
  "response_format": "json"
}
audio_url entry
{
  "audio_url": "https://example.com/long-audio.ogg",
  "model": "cantogen-asr"
}
storage_path entry (browser session only)
{
  "storage_path": "asr-uploads/free/user-uuid/018f3c2a-7b12-4c5d-9e8f-a1b2c3d4e5f6.wav",
  "model": "cantogen-asr"
}

Responses

202

Queued — poll GET /v1/asr/transcriptions/{id} for the transcript.

application/json
{
  "id": "1cabbd7b-741d-46a1-b83e-ed259247a57c",
  "object": "transcription",
  "status": "queued",
  "retrieval": "/v1/asr/transcriptions/1cabbd7b-741d-46a1-b83e-ed259247a57c"
}
400

Invalid parameters / audio URL rejected (https only, private hosts, 500 MB cap); malformed storage_path (bad shape, sent together with audio_url, or sent by an API-key caller).

invalid_request
{
  "error": "invalid_request"
}
audio_url_must_be_https
{
  "error": "audio_url_must_be_https"
}
audio_url_host_not_allowed
{
  "error": "audio_url_host_not_allowed"
}
audio_url_too_large
{
  "error": "audio_url_too_large"
}
storage_path_session_only
{
  "error": "storage_path_session_only"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
402

Insufficient prepaid balance (nothing queued, zero charge).

application/json
{
  "error": "insufficient_balance"
}
403

storage_path does not belong to the authenticated user (cross-account guard).

application/json
{
  "error": "storage_path_forbidden"
}
404

The object referenced by storage_path does not exist (upload incomplete or past its TTL — 24 hours on free / 7 days on paid).

application/json
{
  "error": "storage_path_not_found"
}
413

Audio exceeds the 4-hour cap.

application/json
{
  "error": "payload_too_large"
}
503

Submit infrastructure temporarily unavailable — refunded; retry after Retry-After.

application/json
{
  "error": "asr_queue_submit_failed"
}
GET/v1/asr/transcriptions/{id}

Retrieve a long-audio transcription (poll surface for async 202)

Async transcription retrieval — poll this endpoint for the transcript: queued → processing → completed (text / duration_seconds present) / failed (error present). No recognizable speech (silence / pure music) still completes with an empty text ("") and is billed (same convention as the sync route — a valid result, not an error). The wallet hold is settled on actual duration the first time completed is observed (idempotent — re-polling never double-charges). You can only retrieve results owned by your key. Submit via POST /v1/asr/jobs (returns 202 queued).

Path & query parameters

FieldDescription
idstring · uuid · yes

The id returned by the 202 response.

cURL
curl "https://api.canto-gen.com/v1/asr/transcriptions/{id}" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

Current status (text / duration_seconds present when completed). Jobs submitted with vocabulary (grant-gated) have recitation residue stripped from text before it is returned; jobs without a vocabulary list return the transcript verbatim.

application/json
{
  "id": "0117bfb9-215a-4559-a94f-e27b525d600c",
  "object": "transcription",
  "status": "completed",
  "text": "多謝大家抽空過嚟,我哋即刻開始今日嘅環節。嗯。",
  "duration_seconds": 631.2,
  "error": null,
  "created_at": "2026-10-18T10:00:00.000Z",
  "completed_at": "2026-10-18T10:04:12.000Z"
}
400

Invalid id.

application/json
{
  "error": "invalid_id"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
404

Unknown id (or owned by another key).

application/json
{
  "error": "not_found"
}
503

Temporarily unavailable. Retry shortly.

application/json
{
  "error": "retrieval_failed"
}
DELETE/v1/asr/transcriptions/{id}

Delete a transcription (including its audio)

Deletes one transcription: the transcript and the uploaded audio take effect immediately, there is no restore, and the data is physically purged within 30 days (in practice it is removed right away). You can only delete records owned by your key (records owned by another key return 404, which does not reveal whether the id exists). Order: the database record is deleted first, then the audio object.

Path & query parameters

FieldDescription
idstring · uuid · yes

The id returned by the 202 response (= asr_long_transcriptions.request_id).

cURL
curl -X DELETE "https://api.canto-gen.com/v1/asr/transcriptions/{id}" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

Deleted.

application/json
{
  "id": "0117bfb9-215a-4559-a94f-e27b525d600c",
  "object": "transcription",
  "deleted": true
}
400

Invalid id.

application/json
{
  "error": "invalid_id"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
404

Unknown id (or owned by another key).

application/json
{
  "error": "not_found"
}
503

Temporarily unavailable. Retry shortly.

application/json
{
  "error": "deletion_failed"
}
GET/v1/asr/vocabulary

Get your account's keyword vocabulary

Reads the ASR keyword vocabulary for your account (one list, per account). terms is the cleaned term list (each term ≤30 characters, at most 50 terms); updated_at is when it was last changed (null if never set). The list is used for keyword biasing: API key requests (sk_) to POST /v1/asr/transcribe and POST /v1/asr/jobs apply it automatically when the request does not carry a vocabulary parameter; a request that carries one (including an empty array) takes precedence. The keyword vocabulary feature must be enabled for your account (otherwise 403).

cURL
curl "https://api.canto-gen.com/v1/asr/vocabulary" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

Your account's vocabulary (empty if never set).

application/json
{
  "scope": "api",
  "terms": [
    "證監會",
    "庫務局"
  ],
  "updated_at": "2026-10-28T09:00:00.000Z"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
403

The keyword vocabulary feature is not enabled for this account.

application/json
{
  "error": "asr_vocabulary_not_granted",
  "message": "Keyword vocabulary is not enabled for this account. Ask Canto-Gen support to enable the asr_vocabulary feature for your account, then retry."
}
503

Temporarily unavailable. Retry shortly.

application/json
{
  "error": "vocabulary_read_failed"
}
PUT/v1/asr/vocabulary

Replace your account's keyword vocabulary

Replaces the ASR keyword vocabulary for your account (whole-list replacement, not an increment). terms is cleaned first (trimmed, de-duplicated, terms longer than 30 characters dropped, at most 50 kept) and then stored; the response echoes what was actually stored. Sending an empty array {"terms": []} clears the list (the DELETE method does the same). The keyword vocabulary feature must be enabled for your account (otherwise 403).

Request body · AsrVocabularyRequest (required)

FieldDescription
termsarray · yes

The terms to store — up to 50 terms, each ≤30 characters after trimming. The list is cleaned before it is stored (trimmed, de-duplicated, over-long terms dropped, capped at 50). An empty array clears the list.

cURL
curl -X PUT "https://api.canto-gen.com/v1/asr/vocabulary" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"terms":["證監會","庫務局"]}'

Examples

Two keyword terms
{
  "terms": [
    "證監會",
    "庫務局"
  ]
}
Clear the list (same as DELETE)
{
  "terms": []
}

Responses

200

Saved (echoes the stored value).

application/json
{
  "scope": "api",
  "terms": [
    "證監會",
    "庫務局"
  ],
  "updated_at": "2026-10-28T09:00:00.000Z"
}
400

Malformed body (not valid JSON, terms missing, or terms is not an array of strings).

terms_required
{
  "error": "terms_required"
}
invalid_terms
{
  "error": "invalid_terms"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
403

The keyword vocabulary feature is not enabled for this account.

application/json
{
  "error": "asr_vocabulary_not_granted",
  "message": "Keyword vocabulary is not enabled for this account. Ask Canto-Gen support to enable the asr_vocabulary feature for your account, then retry."
}
503

Temporarily unavailable. Retry shortly.

application/json
{
  "error": "vocabulary_write_failed"
}
DELETE/v1/asr/vocabulary

Clear your account's keyword vocabulary

Clears the ASR keyword vocabulary for your account (same as PUT {"terms": []} — the list becomes empty and updated_at is refreshed). API key transcription requests that carry no vocabulary parameter will then apply no terms. The keyword vocabulary feature must be enabled for your account (otherwise 403).

cURL
curl -X DELETE "https://api.canto-gen.com/v1/asr/vocabulary" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

Cleared.

application/json
{
  "ok": true,
  "scope": "api",
  "terms": [],
  "updated_at": "2026-10-28T09:00:00.000Z"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
403

The keyword vocabulary feature is not enabled for this account.

application/json
{
  "error": "asr_vocabulary_not_granted",
  "message": "Keyword vocabulary is not enabled for this account. Ask Canto-Gen support to enable the asr_vocabulary feature for your account, then retry."
}
503

Temporarily unavailable. Retry shortly.

application/json
{
  "error": "vocabulary_write_failed"
}
POST/v1/asr/realtime/token

Mint an ASR realtime ephemeral token (browser use)

Mints a short-lived cst_… token so browsers can open wss://api.canto-gen.com/v1/asr/realtime without exposing the permanent sk_ key. Tokens are HMAC-signed, scoped to asr:realtime, and live 60–600 seconds (default 300). Always mint server-side (with your sk_ key or an authenticated session) and pass the token to the browser via the ?token= query parameter — never put your permanent API key in a URL. Optional vocabulary (keyword biasing, gated by the asr_vocabulary entitlement; silently ignored without it) — both sk_ and session callers may pass it.

Request body · AsrRealtimeTokenRequest (optional)

FieldDescription
expires_in_secondsnumber · no

Token TTL in seconds. 60–600, default 300.

vocabularyarray · no

Optional keyword-biasing list for this session (up to 50 terms, each ≤30 chars after trim). Grant-gated: only accounts with the asr_vocabulary entitlement have it applied — without the grant the list is silently ignored and the token is minted exactly as if it were absent. Per-request only: this endpoint does not apply your stored vocabulary (PUT /v1/asr/vocabulary) — pass the terms you want in the request.

cURL
curl -X POST "https://api.canto-gen.com/v1/asr/realtime/token" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"expires_in_seconds":300}'

Examples

Default 300s
{
  "expires_in_seconds": 300
}

Responses

200

Token minted.

application/json
{
  "token": "cst_eyJzdWIiOiJ1MSIsInNjb3BlIjoiYXNyOnJlYWx0aW1lIn0.x8Y",
  "expires_in": 300,
  "ws_url": "wss://api.canto-gen.com/v1/asr/realtime",
  "token_type": "cst"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
429

Rate limited (30/minute per user; 15/minute per key — all keys on the account count together).

application/json
{
  "error": "rate_limited"
}

Balance

Account balance
GET/v1/balance

Get prepaid balance

Get the account's prepaid balance (HKD) plus the file-transcription / realtime- dictation rates and the auto top-up settings.

  • balance_hkd — the current prepaid balance (HKD).
  • asr — rates: HK$0.80/hour for file transcription, HK$1.40/hour for realtime dictation, billed per audio second (audio_second).
  • auto_topup — auto top-up settings (enabled, threshold, amount).

Test keys report the test-environment balance (isolated from production). Top up at /account/billing when the balance runs low.

cURL
curl "https://api.canto-gen.com/v1/balance" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

Prepaid balance and rates.

application/json
{
  "object": "balance",
  "currency": "HKD",
  "balance_hkd": 50,
  "balance_hkd_exact": 49.9975,
  "asr": {
    "batch_rate_hkd_per_hour": 0.8,
    "realtime_rate_hkd_per_hour": 1.4,
    "billed_unit": "audio_second"
  },
  "auto_topup": {
    "enabled": true,
    "threshold_hkd": 20,
    "amount_hkd": 100
  }
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
503

Balance lookup temporarily failed. Retry shortly.

application/json
{
  "error": "balance_read_failed"
}
GET/v1/usage

Usage ledger (prepaid wallet entries)

List entries from your prepaid wallet ledger (the append-only source of truth) — every credit/debit carries a kind (top_up / hold / hold_release / refund / adjustment…), a signed 4-decimal amount and the balance after it; usage rows also carry unit, quantity and the rate at charge time. hold and hold_release appear in pairs (estimated hold → settled on actual duration). The response also carries summary (current-period usage): period_start (start of the current billing period — the subscription anniversary day for paid plans, not the 1st of the calendar month), used_chars (characters consumed this period), limit_chars (the plan's quota for this period), remaining_chars (characters left), credit_chars (credit pool) and balance_hkd / balance_hkd_exact (prepaid wallet balance) — so you can reconcile against your own system without summing every entry. Cursor pagination: limit (1–100, default 20) and starting_after (the last entry id of the previous page). Test keys report the test-environment ledger. Amounts are 4-decimal exact (/v1/balance remains the 2-decimal display surface).

Path & query parameters

FieldDescription
limitinteger · no

Entries per page (1–100, default 20).

default: 20

starting_afterstring · uuid · no

Cursor — the id of the last entry on the previous page; older entries resume from here.

cURL
curl "https://api.canto-gen.com/v1/usage" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

A page of ledger entries (newest first).

application/json
{
  "object": "list",
  "summary": {
    "period_start": "2026-10-10",
    "used_chars": 2339,
    "limit_chars": 370000,
    "remaining_chars": 367661,
    "credit_chars": 5765,
    "currency": "HKD",
    "balance_hkd": 49.98,
    "balance_hkd_exact": 49.9775,
    "balance_credits": 49977.5
  },
  "data": [
    {
      "id": "3fcf4ca5-a996-813f-9714-c45e59549a24",
      "object": "wallet_ledger_entry",
      "created_at": "2026-10-17T10:34:00.000Z",
      "kind": "hold_release",
      "amount_hkd": 0.0001,
      "balance_after_hkd": 49.9775,
      "unit": "audio_second",
      "quantity": 11.46,
      "rate_hkd_per_hour": 0.8,
      "note": null
    }
  ],
  "has_more": true,
  "next_cursor": "3f9f4ca5-a996-8149-a631-d7c4351b7bb3"
}
400

Invalid parameter.

application/json
{
  "error": "invalid_cursor"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
503

Ledger temporarily unavailable. Retry shortly.

application/json
{
  "error": "usage_read_failed"
}

Account

Account lifecycle (deletion / privacy)
POST/v1/account/deletion

Delete your account

Delete your own account (self-service deletion) — available to API-only customers without the web console.

Two-step confirmation (body { confirmEmail, confirmWord }):

  • confirmEmail — must equal your account email (case-insensitive);
  • confirmWord — must equal DELETE (case-sensitive).

A mismatch returns 400 (confirm_missing / confirm_email_mismatch / confirm_word_mismatch).

Preconditions (409):

  • active_jobs — you still have unfinished generation jobs (queued / processing / cancelling);
  • team_owner — you own a workspace that still has other members (dissolve or hand it over first).

Success (200 { ok: true, purge_by }):

  • Deactivated immediately: the account is locked (login banned, every existing session invalidated).
  • Permanently purged: your generation records, voices, reference audio and other personal data are removed by the daily cleanup job; purge_by is the deadline by which the purge completes (legally retained billing and usage records are kept).

Repeat requests are idempotent (one deletion request per account).

Request body · AccountDeletionRequest (required)

FieldDescription
confirmEmailstring · yes

Your account email (compared case-insensitively).

confirmWordstring · enum(1) · yes

Must be exactly DELETE (case-sensitive).

enum: DELETE

cURL
curl -X POST "https://api.canto-gen.com/v1/account/deletion" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"confirmEmail":"you@example.com","confirmWord":"DELETE"}'

Examples

Two-step confirmation
{
  "confirmEmail": "you@example.com",
  "confirmWord": "DELETE"
}

Responses

200

Deletion request recorded — the account is deactivated immediately and the data is removed by the daily cleanup job.

application/json
{
  "ok": true,
  "purge_by": "2026-11-02T03:00:00.000Z"
}
400

The two-step confirmation did not match — confirm_missing / confirm_email_mismatch / confirm_word_mismatch.

confirm_missing
{
  "error": "confirm_missing"
}
confirm_email_mismatch
{
  "error": "confirm_email_mismatch"
}
confirm_word_mismatch
{
  "error": "confirm_word_mismatch"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
409

A precondition failed — active_jobs (you still have unfinished generation jobs) / team_owner (you own a workspace that still has other members).

active_jobs
{
  "error": "active_jobs"
}
team_owner
{
  "error": "team_owner"
}
503

The deletion request could not be recorded temporarily. Retry shortly.

application/json
{
  "error": "deletion_request_failed"
}
GET/v1/account/telemetry

Quality-signal (anonymous usage stats) setting

Read or update this account's quality-signal opt-out (anonymous usage stats).

  • telemetry_opt_out: true turns off automatic behavioural telemetry (for example how you use the service);
  • feedback you submit on purpose (ratings, reports) is not affected — that is an explicit request, not telemetry.

This is one setting per account (the same user_profiles.telemetry_opt_out for every key on the account).

cURL
curl "https://api.canto-gen.com/v1/account/telemetry" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY"

Responses

200

The current quality-signal setting.

application/json
{
  "telemetry_opt_out": false
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
503

The setting is temporarily unavailable. Retry shortly.

application/json
{
  "error": "telemetry_read_failed"
}
PUT/v1/account/telemetry

Quality-signal (anonymous usage stats) setting

Read or update this account's quality-signal opt-out (anonymous usage stats).

  • telemetry_opt_out: true turns off automatic behavioural telemetry (for example how you use the service);
  • feedback you submit on purpose (ratings, reports) is not affected — that is an explicit request, not telemetry.

This is one setting per account (the same user_profiles.telemetry_opt_out for every key on the account).

Request body · TelemetryPreference (required)

FieldDescription
telemetry_opt_outboolean · yes

True = turn automatic behavioural telemetry off.

cURL
curl -X PUT "https://api.canto-gen.com/v1/account/telemetry" \
  -H "Authorization: Bearer $CANTOGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"telemetry_opt_out":true}'

Examples

Turn anonymous usage stats off
{
  "telemetry_opt_out": true
}

Responses

200

The setting was saved.

application/json
{
  "ok": true,
  "telemetry_opt_out": true
}
400

Invalid body — invalid_telemetry_opt_out (telemetry_opt_out is not a boolean).

application/json
{
  "error": "invalid_telemetry_opt_out"
}
401

Missing, malformed, invalid or expired API key.

application/json
{
  "error": "invalid_or_expired_token"
}
503

The setting could not be saved temporarily. Retry shortly.

application/json
{
  "error": "telemetry_update_failed"
}

Schemas

SpeechRequest

Choose exactly one voice mode — they are mutually exclusive:

  • voice — a preset voice slug from GET /v1/voices (recommended; all preset voices are Cantonese-optimized 香港聲線). Requires the tts:generate scope.
  • design — describe a synthetic voice by gender + age. Accepted with the tts:generate scope or the finer-grained tts:design scope (either one suffices, so existing tts:generate keys keep working unchanged).
  • clone — clone a voice from a base64 reference_audio sample (requires the tts:clone key scope). Only reference_audio is needed; the legacy prompt_text field is retired (any value is ignored).

Sending more than one of voice / design / clone returns 400 voice_mode_conflict.

Field

FieldDescription
modelstring · enum(1) · no

The TTS model. Currently only cantogen-tts exists; other values return 400 invalid_model.

enum: cantogen-tts

default: cantogen-tts

voicestring · no

Preset voice slug from GET /v1/voices. Required unless design or clone is used.

textstring · yes

The text to speak (1–500 characters on the async endpoint; the sync POST /v1/audio/speech caps at 300 billable credits). Cantonese text works best — 廣東話字正腔圓. Supports inline tone tags: insert [label] in the script, e.g. [笑聲]你好[唷!] — closed set of 15 tags (see the API guide, Inline tone tags). Unknown bracket tokens pass through untouched.

pitchinteger · 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

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

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

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

Free-text delivery direction in Cantonese, Chinese or English — e.g. 「用興奮嘅語氣講,好似慶祝生日咁」. Applied after style and emotion, so it has the final say on how the line is delivered. Values over 500 characters return 400 invalid_instruction.

response_formatstring · enum(2) · no

Audio container format. Other formats return 400 unsupported_format.

enum: mp3 · wav

default: mp3

srtboolean · no

Also generate SRT subtitles. When true, a completed job's srt field carries the subtitle content (billed at a higher credit rate).

default: false

seedinteger · no

Reserved. Accepted and validated as an integer but not yet used for reproducibility.

sample_rateinteger · no

Reserved. Accepted and validated as an integer but not yet applied.

designDesignObject · no
cloneCloneObject · no

DesignObject

Describe a synthetic voice instead of picking a preset. Accepted with the tts:generate or the tts:design key scope (either one suffices).

Field

FieldDescription
genderstring · enum(2) · yes

Voice gender.

enum: male · female

agestring · enum(7) · yes

Voice age band. Prefer child, teenage, adult, midage, elder. teen (alias of teenage) and young (alias of adult) are deprecated but still accepted.

enum: child · teenage · adult · midage · elder · teen · young

CloneObject

Clone a voice from a reference sample. Requires an API key with the tts:clone scope.

Field

FieldDescription
reference_audiostring · yes

Base64 audio sample (data URL such as data:audio/wav;base64,… or raw base64). Use a clean sample of at least 3 seconds — shorter samples are rejected; long samples are auto-trimmed to ~15–20 s on sentence boundaries.

JobStatus

State of a speech job. Returned by GET /v1/audio/jobs/{id} (200) and as the 202 body of POST /v1/audio/jobs. Async generation is submitted via POST /v1/audio/jobs; the sync POST /v1/audio/speech returns audio bytes directly (200).

Field

FieldDescription
job_idstring · yes

Job id (UUID).

statusstring · enum(6) · yes

Job lifecycle state. cancelling is transient — after DELETE /v1/audio/jobs/{id} on an in-flight job it settles as cancelled.

enum: queued · processing · cancelling · completed · failed · cancelled

poll_urlstring · yes

Relative URL of the job poll endpoint for this job.

srt_requestedboolean · yes

Whether the job was submitted with srt: true.

srtstring · no

SRT subtitle content. Present only when subtitles were requested and the job has completed with captions materialized. Additive — its absence never affects other fields.

audio_urlstring · uri · no

Pre-signed download URL for the generated audio. Present only once status is completed — URLs from the materialized library are valid for 1 hour, worker URLs (not yet materialized) for 7 days. Additive — its absence never affects other fields.

Voice

A preset voice. All official voices are Cantonese-optimized (廣東話優化).

Field

FieldDescription
slugstring · yes

Use as the voice parameter of POST /v1/audio/speech (sync) or POST /v1/audio/jobs (async).

namestring · yes

Display name (Chinese name as-is).

genderstring · no

Voice gender.

agestring · no

Voice age range.

stylesarray · no

Supported speaking styles/emotions.

preview_urlstring · no

URL streaming a short preview sample (no extra auth needed).

TranscriptionRequest

Transcribe audio to text

Field

FieldDescription
filestring · binary · yes

The audio file to transcribe (wav, mp3, m4a/mp4, webm, ogg, flac). Max 4.5 MB effective (platform request-body cap); for longer audio use POST /v1/asr/jobs with audio_url or storage_path (up to 500 MB).

modelstring · yes

Transcription model name. Required by the API shape; any non-empty value is accepted — the current release offers a single Cantonese-optimized transcription model (cantogen-asr).

languagestring · no

Optional ISO-639-1 language hint. Accepted as-is; transcription is currently Cantonese-optimized.

response_formatstring · enum(2) · no

json (default) returns the structured object; text returns plain text. Segment-timestamp formats (srt, verbose_json) are not yet supported and return 400 unsupported_response_format.

enum: json · text

default: json

vocabularyarray · no

Optional keyword-biasing list (up to 50 terms, each ≤30 chars after trim). Grant-gated: only accounts with the asr_vocabulary entitlement have it applied — without the grant the field is silently ignored and the request is processed exactly as if it were absent. On multipart requests send a JSON-encoded string array (e.g. '["term1","term2"]'). Stored default (API key requests): when the parameter is omitted, the vocabulary stored for your account (PUT /v1/asr/vocabulary) is applied automatically; when the parameter is present — including an empty array — the request value wins (an empty array means no biasing, it does not fall back to the stored list).

AsrJobUrlRequest

Async submit (JSON entry) — audio_url: the server fetches the audio, bypassing the 4.5 MB upload cap; storage_path: browser session only (the Creator large-file lane — first upload via a signed URL from /api/asr/upload-url; objects expire after 24 hours on free / 7 days on paid). Exactly one of the two is required; sending both → 400.

Field

FieldDescription
audio_urlstring · uri · no

https URL of the audio file (server-side fetch; up to 500 MB / 4 hours).

storage_pathstring · no

Upload path as returned by POST /api/asr/upload-url (browser session callers only — API-key requests are rejected with 400 storage_path_session_only). The path must belong to the authenticated user; a cross-account path returns 403 storage_path_forbidden. Max 500 MB / 4 hours of audio.

modelstring · enum(1) · no

enum: cantogen-asr

languagestring · no

ISO-639-1 language hint (optional).

vocabularyarray · no

Optional keyword-biasing list (up to 50 terms, each ≤30 chars after trim). Grant-gated: only accounts with the asr_vocabulary entitlement have it applied — without the grant the field is silently ignored and the job is processed exactly as if it were absent. When granted, the stored transcript has recitation residue stripped before it is returned by the poll endpoint. Stored default (API key requests): when the parameter is omitted, the vocabulary stored for your account (PUT /v1/asr/vocabulary) is applied automatically; when the parameter is present — including an empty array — the request value wins (an empty array means no biasing, it does not fall back to the stored list).

callback_urlstring · uri · no

Optional https webhook — POSTed { id, object, status, duration_seconds?, error? } when the job reaches completed/failed (2xx = delivered; failed attempts retried up to 5 times). When your account has a webhook signing secret configured (issued and rotated by support), every callback also carries x-canto-signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, "<t>." + raw body)> plus x-timestamp (ISO 8601, same second). Verify against the raw request body in constant time and reject requests whose |now − t| > 300 seconds. Accounts without a secret receive unsigned callbacks (payload unchanged).

AsrRealtimeTokenRequest

Token TTL in seconds. 60–600, default 300.

Field

FieldDescription
expires_in_secondsnumber · no

Token TTL in seconds. 60–600, default 300.

vocabularyarray · no

Optional keyword-biasing list for this session (up to 50 terms, each ≤30 chars after trim). Grant-gated: only accounts with the asr_vocabulary entitlement have it applied — without the grant the list is silently ignored and the token is minted exactly as if it were absent. Per-request only: this endpoint does not apply your stored vocabulary (PUT /v1/asr/vocabulary) — pass the terms you want in the request.

Transcription

Transcription succeeded.

Field

FieldDescription
idstring · yes

Transcription request id (UUID).

objectstring · enum(1) · yes

Always transcription.

enum: transcription

textstring · yes

The transcribed text.

duration_secondsnumber · no

Audio duration in seconds (rounded to 2 decimals) — the billing basis.

charged_hkdnumber · no

HKD actually settled for this request (success-only billing, per-second, no rounding up). Additive — its absence never affects other fields.

AsrVocabularyRequest

The keyword vocabulary (whole-list replacement).

Field

FieldDescription
termsarray · yes

The terms to store — up to 50 terms, each ≤30 characters after trimming. The list is cleaned before it is stored (trimmed, de-duplicated, over-long terms dropped, capped at 50). An empty array clears the list.

AsrVocabulary

Your account's keyword vocabulary.

Field

FieldDescription
scopestring · enum(1) · yes

Always api — the public API vocabulary scope.

enum: api

termsarray · yes

The stored terms (cleaned).

updated_atstring · no

ISO-8601 timestamp of the last change (null when the list was never set).

Balance

Prepaid balance and rates.

Field

FieldDescription
objectstring · enum(1) · yes

Always balance.

enum: balance

currencystring · enum(1) · yes

Prepaid-balance currency.

enum: HKD

balance_hkdnumber · yes

The current prepaid balance in HKD (2-decimal display; test keys report the test-environment balance).

balance_hkd_exactnumber · no

The same balance at 4 decimals (2026-10-18 additive) — sub-cent charges (e.g. 0.0025) stay auditable.

asrobject · yes

Get prepaid balance

auto_topupobject · yes

AccountDeletionRequest

The two-step confirmation body for deleting an account.

Field

FieldDescription
confirmEmailstring · yes

Your account email (compared case-insensitively).

confirmWordstring · enum(1) · yes

Must be exactly DELETE (case-sensitive).

enum: DELETE

TelemetryPreference

The quality-signal opt-out body.

Field

FieldDescription
telemetry_opt_outboolean · yes

True = turn automatic behavioural telemetry off.

Error

Field

FieldDescription
errorstring · yes

Stable machine-readable error code.

messagestring · no

Optional human-readable explanation.