AniwaffleDocsHomeStudio

API reference

Create a stream token

Creates a short-lived token that a browser or mobile app uses to open a streaming connection, so your API key never leaves your server.

Request

POSThttps://aniwaffle.com/v1/tts/stream-tokens

HeaderRequiredValue
AuthorizationYesBearer awp_.... Must be an API key.

Send no body, or an empty JSON object {}.

curl --request POST https://aniwaffle.com/v1/tts/stream-tokens \
  --header "Authorization: Bearer $ANIWAFFLE_API_KEY"

Response

201 Created
{
  "token": "STREAM_TOKEN",
  "expires_at": "2026-11-23T09:02:00.000Z",
  "websocket_url": "wss://aniwaffle.com/v1/tts/stream",
  "capabilities": {
    "text_input": true,
    "streaming_audio": true,
    "audio_encoding": "base64_json"
  }
}
FieldTypeDescription
tokenstringThe stream token. Treat it as a secret until it expires.
expires_atstringISO 8601 time when the token stops opening connections, 2 minutes after creation.
websocket_urlstringThe streaming endpoint on the host that issued the token.
capabilitiesobjectWhat the connection supports: text input, streaming audio, and base64 audio in JSON events.

The response is sent with Cache-Control: no-store.

Use the token

Return token and websocket_url to your client. The client connects with the token in the query string:

Browser
const socket = new WebSocket(`${websocket_url}?token=${encodeURIComponent(token)}`)
  • Create one token per connection, just before the client connects.
  • A token opens connections to /v1/tts/stream only. It can't call other endpoints.
  • Browser connections are also checked against your workspace's allowed web origins. Email hello@narya.ai to add yours.

Errors

StatusCodeCause
400invalid_requestThe request had a non-empty body.
401unauthorizedMissing, invalid or revoked API key.
403capability_disabledText to Speech is not enabled for the workspace.

Contact our team

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