API reference
Generate speech
Generates speech from complete text and returns the audio in the response body.
Request
POSThttps://aniwaffle.com/v1/tts
Headers
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer awp_... |
Content-Type | Yes | application/json |
Idempotency-Key | No | 1–200 characters. Makes retries safe; see Idempotency. |
Body
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | The text to speak, 1–20,000 characters, including any tags. |
voice_id | string | Yes | A voice ID from GET /v1/voices. |
output_format | string | Yes | One of pcm_24000, pcm_44100, pcm_48000, aac_44100_128. Must be supported by the model. See Output formats. |
model | string | No | A model ID from GET /v1/models. Defaults to Waffle Mono. |
realtime | boolean | No | Use the realtime tier. Defaults to false. Waffle Mono only, on hosts where the model lists realtime: true. |
context_id | string | No | Your identifier for this utterance, up to 200 characters. |
partner_session_id | string | No | Your identifier for the conversation or session, 1–200 characters. |
Unknown fields are rejected with 400 invalid_request.
Example
curl https://aniwaffle.com/v1/tts \
--fail-with-body \
--header "Authorization: Bearer $ANIWAFFLE_API_KEY" \
--header "Content-Type: application/json" \
--header "Idempotency-Key: $(uuidgen)" \
--data '{
"text": "<happy>Welcome back!</happy> Your order shipped today.",
"voice_id": "'"$ANIWAFFLE_VOICE_ID"'",
"output_format": "pcm_48000"
}' \
--dump-header headers.txt \
--output speech.pcmResponse
A successful request returns 200 OK with the audio as the body.
| Header | Description |
|---|---|
Content-Type | audio/pcm;rate=48000;channels=1 for PCM, audio/aac for AAC. |
X-Audio-Format | The delivered output_format. |
X-Audio-Channels | 1 or 2. |
X-Audio-Duration-Ms | Length of the audio in milliseconds. |
X-Request-Id | The request's ID. Include it when you contact support. |
The request waits until the whole utterance is generated, so set your client timeout to cover the length of the text. For playback that starts sooner, use streaming. For long text, use a job.
Idempotency
Send an Idempotency-Key to make retries safe after a timeout or lost connection:
- A retry with the same key and body within 24 hours returns the original audio and
X-Request-Id, without generating or charging again. - If the original request is still running, the retry returns
409 idempotency_in_progresswithRetry-After. - The same key with a different body returns
409 idempotency_conflict. - If the original request failed or its result expired, the retry returns
410 idempotency_result_unavailable. Use a new key.
Requests without the header are always independent. Use a new key whenever you change the text, voice, model or format.
Errors
Errors return JSON instead of audio. Check the status before saving the body.
| Status | Code | Cause |
|---|---|---|
| 400 | invalid_request | Invalid JSON, a missing or unknown field, invalid tags, text over 20,000 characters, or a voice the workspace can't use. |
| 400 | invalid_voice | The voice can't be used with the requested model. |
| 400 | unsupported_output_format | The model can't produce the requested format. |
| 401 | unauthorized | Missing, invalid or revoked API key. |
| 402 | insufficient_credit | The workspace balance is too low. |
| 403 | capability_disabled | Text to Speech is not enabled for the workspace. |
| 5xx | provider_error, provider_unavailable | Generation failed. Retry if retryable is true. |
See Errors for every code and retry guidance.