Docs Speech
POST /v1/audio/speech — every field, every response header, and what streaming actually does.
POST /v1/audio/speech
POST /v1/audio/speech HTTP/1.1
Host: tts.nexis-ai.tech
Authorization: Bearer nxs_tts_…
Content-Type: application/json
OpenAI-compatible JSON in, audio bytes out. The response is streamed: chunks arrive while the worker is still generating, so a long paragraph begins playing before the last sentence exists.
Body
| field | type | default | notes |
|---|---|---|---|
input |
string | — | Required. 1 to 3000 characters. The request's characters are counted against your budget. |
instructions |
string | Speak clearly and naturally. |
How the voice should sound. This is the voice design: describe age, accent, pace, warmth. |
voice |
string or object | none | A saved voice id from GET /v1/voices. Omit it to design the voice from instructions. |
response_format |
string | mp3 |
mp3, wav, pcm. opus, aac and flac are accepted but returned as WAV. |
stream_format |
string | audio |
audio returns the file itself; sse wraps it in server-sent events. |
model |
string | ignored | Accepted so clients that always send one keep working. |
speed |
number | ignored | The model has no speed control. Rewrite the text instead. |
Native fields are passed through to the worker unchanged: cfg_scale, seed, temperature, top_k,
top_p, repetition_penalty, max_new_tokens, split_chars. They are advanced and rarely needed.
Response
HTTP/1.1 200 OK
Content-Type: audio/mpeg
Cache-Control: no-store
X-Request-Id: req_9c1f2ab7d3e4
X-Worker-Latency-Ms: 412
| header | meaning |
|---|---|
X-Request-Id |
Quote this in a bug report. It appears in the worker's log line. |
X-Worker-Latency-Ms |
Time from forwarding to the first audio byte. |
Content-Type |
audio/mpeg, audio/wav or audio/pcm to match the format. |
The bytes are the audio file. There is no JSON wrapper, and no base64.
Timing
At Q8_0 on an RTX 3060 the worker runs at roughly real time: a 10-second line takes about 10 seconds,
a 3,000-character script about three minutes. Streaming means the caller hears the first sentence after
one or two seconds even when the whole request takes minutes.
For narration, split scripts into sentence-sized requests and concatenate. You get the first audio sooner, retries are cheaper, and one bad sentence does not lose the take.
Concurrency
The worker generates one stream at a time. A request that arrives while another is generating is refused
with 503 worker_busy and Retry-After: 5; it costs no characters. Queue in the caller, not in the
gateway — the gateway is deliberately not a job system.
Examples
Shell
curl https://tts.nexis-ai.tech/v1/audio/speech \
-H "Authorization: Bearer $NEXIS_TTS_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"A line of narration.","instructions":"a calm British narrator","response_format":"wav"}' \
--output line.wav
Streaming to disk as it arrives
import os, httpx
with httpx.stream("POST", "https://tts.nexis-ai.tech/v1/audio/speech",
headers={"Authorization": f"Bearer {os.environ['NEXIS_TTS_KEY']}"},
json={"input": "A long paragraph that takes a while.", "response_format": "mp3"},
timeout=180) as response:
response.raise_for_status()
with open("long.mp3", "wb") as handle:
for chunk in response.iter_bytes():
handle.write(chunk)
WAV with a fixed seed
Same text, same seed, same instructions: the worker is deterministic, so the bytes repeat. Useful for a regression fixture.
curl https://tts.nexis-ai.tech/v1/audio/speech \
-H "Authorization: Bearer $NEXIS_TTS_KEY" \
-H "Content-Type: application/json" \
-d '{"input":"Remember this line.","response_format":"wav","seed":7}' \
--output fixture.wav
Errors for this route
| status | code | cause |
|---|---|---|
| 400 | missing_input |
input absent, empty or not a string |
| 400 | input_too_long |
Over 3000 characters |
| 400 | invalid_json |
Body is not JSON |
| 413 | payload_too_large |
Body over 64 KB |
| 415 | unsupported_media_type |
Content-Type is not application/json |
| 429 | rate_limited / quota_exceeded |
See Limits |
| 503 | worker_busy |
The GPU stream is taken |
Everything else in the envelope is on Errors.