Skip to main content
The Realtime API lets you hold low-latency, bidirectional voice and text conversations with a model over a WebSocket connection. Instead of sending discrete HTTP requests, you open a persistent connection and exchange event messages in both directions — sending audio or text input and receiving streamed audio or text responses as they are generated. Anyone’s Realtime endpoint is compatible with the OpenAI Realtime API format and also supports Azure OpenAI Realtime. You need a channel configured with a provider that supports Realtime (OpenAI or Azure OpenAI) before connecting.
Realtime requires a channel configured with a Realtime-capable provider (OpenAI or Azure OpenAI). Contact your Anyone administrator if the WebSocket connection is rejected.

Connecting

Endpoint: GET /v1/realtime Upgrade an HTTP GET request to a WebSocket connection. You can pass your API key as a query parameter or as an Authorization header in the WebSocket handshake.
For TLS-secured instances:

Authentication

Pass your API key in one of the following ways:
  • Query parameter: ?token=YOUR_TOKEN
  • Authorization header: Authorization: Bearer YOUR_TOKEN (set during the HTTP upgrade handshake)

Event types

Once connected, you exchange JSON event messages. Each message has a type field that identifies its purpose. The following are the core event types.

Client → server

Server → client


Session configuration

After connecting, send a session.update event to configure the session:
string[]
The interaction modes to enable. For example, ["text", "audio"].
string
System-level instructions that guide the model’s behavior for the session.
string
The voice to use for audio output. For example, alloy, echo, nova, or shimmer.
string
Format of the audio you send. For example, pcm16, g711_ulaw, or g711_alaw.
string
Format of the audio the model returns. For example, pcm16.
object
Configuration for transcribing your audio input.
object | null
Controls how the server detects end-of-turn in audio input. Set to null to disable automatic turn detection and manage it manually.
object[]
A list of tool definitions available to the model during this session, following the OpenAI function-calling schema.
string
Controls when the model uses tools. auto, none, or a specific tool name.
number
Sampling temperature for the model. Defaults to 0.8.

Usage tracking

When the model finishes a response, the response.done event includes a usage object:
integer
Total tokens consumed by this response turn.
integer
Tokens in the input (audio + text).
integer
Tokens in the model’s output (audio + text).
object
Breakdown of input token types (e.g., cached, audio).
object
Breakdown of output token types (e.g., audio, text).

Example

The following JavaScript example connects to the Realtime endpoint, configures a session, and logs events as they arrive.
javascript