DocsDeveloper

Streaming

Start playback before synthesis finishes. Raw PCM over a chunked HTTP response.

One POST, one chunked response. The body is raw 16-bit little-endian PCM — no WAV header — prefixed by a 4-byte little-endian sample rate, so a client can start scheduling samples as they arrive.

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 the languages the streaming engine covers — longer text and other languages 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, or output_format/with_timestamps sent — none are supported here. 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.
rate_limitYour plan's concurrent-synthesis limit is reached. Retry after the Retry-After header.
Every error code →

Next

Was this page helpful?
Streaming | SonicVox Docs