Connect a Realtime session
/v1/realtime?model={model}Token360 provides an OpenAI-compatible Realtime WebSocket endpoint for low-latency text and audio sessions.
Use this endpoint from a trusted server environment. Do not expose API keys in browser or mobile client code.
Connection
| URL | wss://api.token360.ai/v1/realtime?model=gpt-realtime-2.1 |
| Authentication | Authorization: Bearer <TOKEN360_API_KEY> during the WebSocket handshake |
| Model | gpt-realtime-2.1 |
| Protocol | OpenAI-compatible GA Realtime events over WebSocket |
Do not send the legacy OpenAI-Beta: realtime=v1 header.
Text session flow
- Open the WebSocket and wait for
session.created. - Send
session.updatewithoutput_modalities: ["text"]. - Wait for
session.updatedbefore sending the first item. - Send a
conversation.item.createevent containinginput_text. - Send
response.create. - Read
response.output_text.deltaevents untilresponse.done.
Waiting for session.updated is important. The default session configuration may use audio output, so a text-only client must explicitly select text before creating its first response.
Audio sessions
For speech-to-speech use cases, configure audio input and output through session.update, stream Base64 audio chunks with input_audio_buffer.append, then commit the input and create a response. Keep the audio format consistent for the whole session.
Do not apply the text-only output_modalities: ["text"] setting to an audio session.
Common client events
session.update | Configure output modality, instructions, tools, audio, and other session options |
conversation.item.create | Add text or other conversation content |
input_audio_buffer.append | Append a Base64-encoded audio chunk |
input_audio_buffer.commit | Commit buffered audio as user input |
response.create | Request a model response |
Common server events
session.created | The connection is ready for session configuration |
session.updated | The requested session configuration was accepted |
response.output_text.delta | Incremental text output |
response.output_audio.delta | Incremental Base64 audio output |
response.done | Terminal response event containing status and usage |
error | Request or session error |
Errors and reconnects
- Treat a non-upgraded WebSocket handshake as an authentication, authorization, model availability, or request validation failure and inspect the returned status and message.
- For an
errorevent, inspecterror.code,error.type,error.param, anderror.messagewhen present. - Reconnect transiently closed sessions with bounded exponential backoff and jitter.
- A new WebSocket creates a new session. Re-send the required session configuration and any application state that must be restored.
- Realtime sessions are not permanent. Plan to reconnect before 60 minutes rather than relying on an indefinitely open connection.
Usage lookup
The terminal response.done event contains response usage. You can also reconcile a completed response through:
1curl "https://api.token360.ai/v1/billing/requests/RESPONSE_ID" \
2 -H "Authorization: Bearer $TOKEN360_API_KEY"