aircaps-live-1) and A5S Streaming v1 (a5s-streaming-v1, early access), subject to your account’s model access.
1. Create a token on your backend
CallPOST /v1/realtime/token with your server-side API key:
Response: 201 Created
expires_in accepts 60–3,600 seconds and defaults to 3,600 when omitted. Use 60 seconds when the browser will connect immediately. The response reports the remaining lifetime, which may be slightly shorter than requested.
Expose this call through an authenticated route in your application, such as POST /api/aircaps-token. Check that the signed-in user may start a stream, return the token to that user, and set Cache-Control: no-store on your response. Keep the AirCaps API key on your backend.
Backend: inside your authenticated route
2. Connect from the browser
/api/aircaps-token below is the route you implement in your own application, not an AirCaps endpoint.
Browser
Authorization header or access_token field is needed on this WebSocket. A valid client token allows connections from your application’s browser origin.
After ready, send raw PCM in real time: 16 kHz, mono, signed 16-bit little-endian, normally in 20 ms frames (640 bytes). For Live 1, send {"type":"finalize"} at each turn’s end, or configure end-of-turn detection. To end the session, send {"type":"finish"} and wait for finished before closing.
For A5S Streaming v1, set model to "a5s-streaming-v1" and add the desired language and diarization options to start. See the streaming guide and WebSocket protocol.
WebSocket address
Usewss://api.aircaps.com/v1/realtime with the token query parameter, as shown above. This address accepts client tokens for both AirCaps Live 1 and A5S Streaming v1, subject to your account’s model access. Select the model in your start message; no endpoint lookup is needed for this flow.
GET /v1/realtime/endpoint is available for server-side clients connecting with an API key. Not every direct address it returns accepts client tokens yet, so use the address above for token-authenticated clients.
Expiry, permissions, and reconnecting
- Streaming only. Client tokens work on the
/v1/realtimeWebSocket. REST endpoints reject them with401 unauthorized, including token creation and endpoint lookup. - Same account access. Model access, billing, and session limits are inherited from the API key that created the token. The token is not restricted to a particular model or application user.
- Expiry controls new connections. Connect before
expires_at. Expiry does not close an already-authenticated stream; its normal session limit still applies, up to one hour. Obtain a fresh token when reconnecting after expiry. - Tokens are reusable until expiry. They are not single-use. Create a fresh, short-lived token for each intended session, and keep it out of logs and persistent browser storage.
- Revocation. Revoking the parent API key prevents new token-authenticated sessions within the authentication cache interval, up to 60 seconds. Sessions already open continue until they end.
unauthorized and WebSocket close code 4401. Do not retry indefinitely with the same rejected token; obtain a fresh one from your backend.
