DocsDeveloper

Streaming

Start playback before synthesis finishes. Raw PCM over a chunked HTTP response — cloned voices only, five languages.

One POST, one chunked response — under a contract stricter than the buffered endpoint's, checked before anything is charged. voice_id is REQUIRED: the streaming engine clones a saved reference, so there is no default voice. The language must be one of five — English, Mandarin, Japanese, Korean or Cantonese (en, zh, ja, ko, yue); anything else is a 422. Text is capped at 5,000 characters. And the output is fixed: raw 16-bit little-endian PCM (pcm_s16le, no WAV header), prefixed once by a 4-byte little-endian sample rate, so a client can start scheduling samples as they arrive. output_format and with_timestamps are rejected with 422 rather than silently ignored — encoded formats, word timestamps, longer text and the wider language set all live on POST /api/v1/text-to-speech.

Authentication

Same account API key and tts:synthesize scope as buffered synthesis. voice_id is REQUIRED here: the streaming engine clones a reference voice, so there is no default to fall back on.

Create a key in Settings → API Keys. It is shown once, so copy it then. Every example below reads it from $SONICVOX_API_KEY.

Endpoints

POST/api/v1/text-to-speech/streamFull reference →

Stream synthesis. Limited to 5,000 characters and to five languages — en, zh, ja, ko, yue — with a mandatory voice_id; longer text, other languages and encoded formats belong on POST /api/v1/text-to-speech. Credits are reserved up front and refunded if the stream fails.

Scope
tts:synthesize
Credits
⌈characters / 100⌉ × 100, reserved up front
# Write the raw PCM to a file. Note --no-buffer: without it curl
# holds the response and you lose the point of streaming.
curl https://staging.sonicvox.ai/api/v1/text-to-speech/stream \
  -H "sv-api-key: $SONICVOX_API_KEY" \
  -H "content-type: application/json" \
  --no-buffer \
  -d '{
    "text": "Streaming starts playing before it finishes.",
    "voice_id": "cmpwrfi46015zkww3t8nui4ye",
    "language": "en"
  }' \
  --output stream.pcm
Response
HTTP/1.1 200 OK
content-type: application/octet-stream
transfer-encoding: chunked
x-audio-format: pcm_s16le
x-credits-charged: 100

<4-byte LE sample rate><PCM frames…>

When it fails

Every error carries type, code, message, request_id and a doc_url. Branch on type for retry policy.

validation_errorvoice_id missing, text over 5,000 characters, a language outside en/zh/ja/ko/yue (the voice's own language counts when you omit the field), or output_format/with_timestamps sent — none are supported here, and each is refused loudly rather than ignored. Use the buffered endpoint instead.
voice_not_foundThe voice_id is not one this key may use.
insufficient_creditsThe reserve could not be taken. Nothing was synthesized.
concurrency_limit_exceededYour plan's concurrent-synthesis limit is reached. Retry after the Retry-After header — the slot frees when one of your streams finishes.
Every error code →

Next

Was this page helpful?
Streaming | SonicVox Docs