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
| Header | Required | Value |
|---|---|---|
Authorization | Yes | Bearer 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"
}
}| Field | Type | Description |
|---|---|---|
token | string | The stream token. Treat it as a secret until it expires. |
expires_at | string | ISO 8601 time when the token stops opening connections, 2 minutes after creation. |
websocket_url | string | The streaming endpoint on the host that issued the token. |
capabilities | object | What 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/streamonly. 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
| Status | Code | Cause |
|---|---|---|
| 400 | invalid_request | The request had a non-empty body. |
| 401 | unauthorized | Missing, invalid or revoked API key. |
| 403 | capability_disabled | Text to Speech is not enabled for the workspace. |