AniwaffleDocsHomeStudio

API reference

Generate speech

Generates speech from complete text and returns the audio in the response body.

Request

POSThttps://aniwaffle.com/v1/tts

Headers

HeaderRequiredValue
AuthorizationYesBearer awp_...
Content-TypeYesapplication/json
Idempotency-KeyNo1–200 characters. Makes retries safe; see Idempotency.

Body

FieldTypeRequiredDescription
textstringYesThe text to speak, 1–20,000 characters, including any tags.
voice_idstringYesA voice ID from GET /v1/voices.
output_formatstringYesOne of pcm_24000, pcm_44100, pcm_48000, aac_44100_128. Must be supported by the model. See Output formats.
modelstringNoA model ID from GET /v1/models. Defaults to Waffle Mono.
realtimebooleanNoUse the realtime tier. Defaults to false. Waffle Mono only, on hosts where the model lists realtime: true.
context_idstringNoYour identifier for this utterance, up to 200 characters.
partner_session_idstringNoYour 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.pcm

Response

A successful request returns 200 OK with the audio as the body.

HeaderDescription
Content-Typeaudio/pcm;rate=48000;channels=1 for PCM, audio/aac for AAC.
X-Audio-FormatThe delivered output_format.
X-Audio-Channels1 or 2.
X-Audio-Duration-MsLength of the audio in milliseconds.
X-Request-IdThe 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_progress with Retry-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.

StatusCodeCause
400invalid_requestInvalid JSON, a missing or unknown field, invalid tags, text over 20,000 characters, or a voice the workspace can't use.
400invalid_voiceThe voice can't be used with the requested model.
400unsupported_output_formatThe model can't produce the requested format.
401unauthorizedMissing, invalid or revoked API key.
402insufficient_creditThe workspace balance is too low.
403capability_disabledText to Speech is not enabled for the workspace.
5xxprovider_error, provider_unavailableGeneration failed. Retry if retryable is true.

See Errors for every code and retry guidance.

Contact our team

Tell us about your character and what you’d like to build.