Skip to Content
Text to speech

Stream synthesized speech

Permissioninference-tts:createAdd-onInferenceRetriesIdempotency-Key identifies the computationAuthentication
POST
/inference/audio/speech

Streams raw little-endian PCM16 mono at 16 kHz as the audio is produced. Use a dedicated Inference key.

A 200 or EOF alone cannot prove completion

Inspect the X-Kejue-Inference-Status trailer — completed, error or cancelled — or read GET /inference/requests/{id} afterwards.

Billing and limits

Text to speech is charged by input length, in characters. The whole input is reserved up front (402 if your balance is short) and charged once audio starts; nothing is charged if no audio is produced, and the audio's length never changes the charge. X-Kejue-Characters carries the characters charged. Output is capped by the model's audio limit and the optional max_audio_seconds, as a safety limit; output_limit means output stopped at that cap, and the input is still charged in full. Audio content is never retained.

Idempotency

The Idempotency-Key identifies one computation. A repeated key returns 409 without rerunning or replaying audio.

See one-shot generation.

Authorization

inferenceBearerAuth
headerAuthorizationBearer <token>

Use an Inference API key. Access and keys.

Header Parameters

Idempotency-Key*string

Identifies one computation. Reuse returns 409 inference_request_exists; results are not replayed. Retries and idempotency.

Match^[A-Za-z0-9!#$%&'*+.^_`|~-]+$
Length1 <= length <= 255

Request Body

application/json
  1. body
model*string
Length1 <= length <= 80
voice*string
Formatuuid
input*string

The text to speak. Charged by its length in Unicode characters (code points), counted as received, whitespace and punctuation included.

Length1 <= length <= 8000
max_audio_seconds?integer

Optional cap on the audio produced, a safety limit for runaway output. It does not change what is charged (the input characters), and output cut by the cap is still charged in full once audio has started.

Range1 <= value <= 600

Response Body

Stream synthesized speech

response?fileaudio/pcm
Formatbinary
Example Request
curl -X POST 'https://api.kejue.co/v1/inference/audio/speech' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{  "model": "string",  "voice": "30cbffd2-8150-49ae-9350-1bb3c0c35f29",  "input": "string"}'
Example Response
"string"