Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

Realtime

ModelsExpand Collapse
type AudioTranscription struct{…}
type ConversationCreatedEvent struct{…}

Returned when a conversation is created. Emitted right after session creation.

type ConversationItemUnion interface{…}

A single item within a Realtime conversation.

type ConversationItemAdded struct{…}

Sent by the server when an Item is added to the default Conversation. This can happen in several cases:

  • When the client sends a conversation.item.create event.
  • When the input audio buffer is committed. In this case the item will be a user message containing the audio from the buffer.
  • When the model is generating a Response. In this case the conversation.item.added event will be sent when the model starts generating a specific Item, and thus it will not yet have any content (and status will be in_progress).

The event will include the full content of the Item (except when model is generating a Response) except for audio data, which can be retrieved separately with a conversation.item.retrieve event if necessary.

type ConversationItemCreateEvent struct{…}

Add a new Item to the Conversation’s context, including messages, function calls, and function call responses. This event can be used both to populate a “history” of the conversation and to add new items mid-stream, but has the current limitation that it cannot populate assistant audio messages.

If successful, the server will respond with a conversation.item.created event, otherwise an error event will be sent.

type ConversationItemCreatedEvent struct{…}

Returned when a conversation item is created. There are several scenarios that produce this event:

  • The server is generating a Response, which if successful will produce either one or two Items, which will be of type message (role assistant) or type function_call.
  • The input audio buffer has been committed, either by the client or the server (in server_vad mode). The server will take the content of the input audio buffer and add it to a new user message Item.
  • The client has sent a conversation.item.create event to add a new Item to the Conversation.
type ConversationItemDeleteEvent struct{…}

Send this event when you want to remove any item from the conversation history. The server will respond with a conversation.item.deleted event, unless the item does not exist in the conversation history, in which case the server will respond with an error.

type ConversationItemDeletedEvent struct{…}

Returned when an item in the conversation is deleted by the client with a conversation.item.delete event. This event is used to synchronize the server’s understanding of the conversation history with the client’s view.

type ConversationItemDone struct{…}

Returned when a conversation item is finalized.

The event will include the full content of the Item except for audio data, which can be retrieved separately with a conversation.item.retrieve event if needed.

type ConversationItemInputAudioTranscriptionCompletedEvent struct{…}

This event is the output of audio transcription for user audio written to the user audio buffer. Transcription begins when the input audio buffer is committed by the client or server (when VAD is enabled). Transcription runs asynchronously with Response creation, so this event may come before or after the Response events.

Realtime API models accept audio natively, and thus input transcription is a separate process run on a separate ASR (Automatic Speech Recognition) model. The transcript may diverge somewhat from the model’s interpretation, and should be treated as a rough guide.

type ConversationItemInputAudioTranscriptionDeltaEvent struct{…}

Returned when the text value of an input audio transcription content part is updated with incremental transcription results.

type ConversationItemInputAudioTranscriptionFailedEvent struct{…}

Returned when input audio transcription is configured, and a transcription request for a user message failed. These events are separate from other error events so that the client can identify the related Item.

type ConversationItemInputAudioTranscriptionSegment struct{…}

Returned when an input audio transcription segment is identified for an item.

type ConversationItemRetrieveEvent struct{…}

Send this event when you want to retrieve the server’s representation of a specific item in the conversation history. This is useful, for example, to inspect user audio after noise cancellation and VAD. The server will respond with a conversation.item.retrieved event, unless the item does not exist in the conversation history, in which case the server will respond with an error.

type ConversationItemTruncateEvent struct{…}

Send this event to truncate a previous assistant message’s audio. The server will produce audio faster than realtime, so this event is useful when the user interrupts to truncate audio that has already been sent to the client but not yet played. This will synchronize the server’s understanding of the audio with the client’s playback.

Truncating audio will delete the server-side text transcript to ensure there is not text in the context that hasn’t been heard by the user.

If successful, the server will respond with a conversation.item.truncated event.

type ConversationItemTruncatedEvent struct{…}

Returned when an earlier assistant audio message item is truncated by the client with a conversation.item.truncate event. This event is used to synchronize the server’s understanding of the audio with the client’s playback.

This action will truncate the audio and remove the server-side text transcript to ensure there is no text in the context that hasn’t been heard by the user.

type ConversationItemWithReference struct{…}

The item to add to the conversation.

type InputAudioBufferAppendEvent struct{…}

Send this event to append audio bytes to the input audio buffer. The audio buffer is temporary storage you can write to and later commit. A “commit” will create a new user message item in the conversation history from the buffer content and clear the buffer. Input audio transcription (if enabled) will be generated when the buffer is committed.

If VAD is enabled the audio buffer is used to detect speech and the server will decide when to commit. When Server VAD is disabled, you must commit the audio buffer manually. Input audio noise reduction operates on writes to the audio buffer.

The client may choose how much audio to place in each event up to a maximum of 15 MiB, for example streaming smaller chunks from the client may allow the VAD to be more responsive. Unlike most other client events, the server will not send a confirmation response to this event.

type InputAudioBufferClearEvent struct{…}

Send this event to clear the audio bytes in the buffer. The server will respond with an input_audio_buffer.cleared event.

type InputAudioBufferClearedEvent struct{…}

Returned when the input audio buffer is cleared by the client with a input_audio_buffer.clear event.

type InputAudioBufferCommitEvent struct{…}

Send this event to commit the user input audio buffer, which will create a new user message item in the conversation. This event will produce an error if the input audio buffer is empty. When in Server VAD mode, the client does not need to send this event, the server will commit the audio buffer automatically.

Committing the input audio buffer will trigger input audio transcription (if enabled in session configuration), but it will not create a response from the model. The server will respond with an input_audio_buffer.committed event.

type InputAudioBufferCommittedEvent struct{…}

Returned when an input audio buffer is committed, either by the client or automatically in server VAD mode. The item_id property is the ID of the user message item that will be created, thus a conversation.item.created event will also be sent to the client.

type InputAudioBufferDtmfEventReceivedEvent struct{…}

SIP Only: Returned when an DTMF event is received. A DTMF event is a message that represents a telephone keypad press (0–9, *, #, A–D). The event property is the keypad that the user press. The received_at is the UTC Unix Timestamp that the server received the event.

type InputAudioBufferSpeechStartedEvent struct{…}

Sent by the server when in server_vad mode to indicate that speech has been detected in the audio buffer. This can happen any time audio is added to the buffer (unless speech is already detected). The client may want to use this event to interrupt audio playback or provide visual feedback to the user.

The client should expect to receive a input_audio_buffer.speech_stopped event when speech stops. The item_id property is the ID of the user message item that will be created when speech stops and will also be included in the input_audio_buffer.speech_stopped event (unless the client manually commits the audio buffer during VAD activation).

type InputAudioBufferSpeechStoppedEvent struct{…}

Returned in server_vad mode when the server detects the end of speech in the audio buffer. The server will also send an conversation.item.created event with the user message item that is created from the audio buffer.

type InputAudioBufferTimeoutTriggered struct{…}

Returned when the Server VAD timeout is triggered for the input audio buffer. This is configured with idle_timeout_ms in the turn_detection settings of the session, and it indicates that there hasn’t been any speech detected for the configured duration.

The audio_start_ms and audio_end_ms fields indicate the segment of audio after the last model response up to the triggering time, as an offset from the beginning of audio written to the input audio buffer. This means it demarcates the segment of audio that was silent and the difference between the start and end values will roughly match the configured timeout.

The empty audio will be committed to the conversation as an input_audio item (there will be a input_audio_buffer.committed event) and a model response will be generated. There may be speech that didn’t trigger VAD but is still detected by the model, so the model may respond with something relevant to the conversation or a prompt to continue speaking.

type LogProbProperties struct{…}

A log probability object.

type McpListToolsCompleted struct{…}

Returned when listing MCP tools has completed for an item.

type McpListToolsFailed struct{…}

Returned when listing MCP tools has failed for an item.

type McpListToolsInProgress struct{…}

Returned when listing MCP tools is in progress for an item.

type NoiseReductionType string

Type of noise reduction. near_field is for close-talking microphones such as headphones, far_field is for far-field microphones such as laptop or conference room microphones.

type OutputAudioBufferClearEvent struct{…}

WebRTC/SIP Only: Emit to cut off the current audio response. This will trigger the server to stop generating audio and emit a output_audio_buffer.cleared event. This event should be preceded by a response.cancel client event to stop the generation of the current response. Learn more.

type RateLimitsUpdatedEvent struct{…}

Emitted at the beginning of a Response to indicate the updated rate limits. When a Response is created some tokens will be “reserved” for the output tokens, the rate limits shown here reflect that reservation, which is then adjusted accordingly once the Response is completed.

type RealtimeAudioConfig struct{…}

Configuration for input and output audio.

type RealtimeAudioConfigInput struct{…}
type RealtimeAudioConfigOutput struct{…}
type RealtimeAudioFormatsUnion interface{…}

The PCM audio format. Only a 24kHz sample rate is supported.

type RealtimeAudioInputTurnDetectionUnion interface{…}

Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to null to turn off, in which case the client must manually trigger model response.

Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with “uhhm”, the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

For gpt-realtime-whisper transcription sessions, turn detection must be set to null; VAD is not supported.

type RealtimeClientEventUnion interface{…}

A realtime client event.

type RealtimeConversationItemAssistantMessage struct{…}

An assistant message item in a Realtime conversation.

type RealtimeConversationItemFunctionCall struct{…}

A function call item in a Realtime conversation.

type RealtimeConversationItemFunctionCallOutput struct{…}

A function call output item in a Realtime conversation.

type RealtimeConversationItemSystemMessage struct{…}

A system message in a Realtime conversation can be used to provide additional context or instructions to the model. This is similar but distinct from the instruction prompt provided at the start of a conversation, as system messages can be added at any point in the conversation. For major changes to the conversation’s behavior, use instructions, but for smaller updates (e.g. “the user is now asking about a different topic”), use system messages.

type RealtimeConversationItemUserMessage struct{…}

A user message item in a Realtime conversation.

type RealtimeError struct{…}

Details of the error.

type RealtimeErrorEvent struct{…}

Returned when an error occurs, which could be a client problem or a server problem. Most errors are recoverable and the session will stay open, we recommend to implementors to monitor and log error messages by default.

type RealtimeFunctionTool struct{…}
type RealtimeMcpApprovalRequest struct{…}

A Realtime item requesting human approval of a tool invocation.

type RealtimeMcpApprovalResponse struct{…}

A Realtime item responding to an MCP approval request.

type RealtimeMcpListTools struct{…}

A Realtime item listing tools available on an MCP server.

type RealtimeMcpProtocolError struct{…}
type RealtimeMcpToolCall struct{…}

A Realtime item representing an invocation of a tool on an MCP server.

type RealtimeMcpToolExecutionError struct{…}
type RealtimeMcphttpError struct{…}
type RealtimeReasoning struct{…}

Configuration for reasoning-capable Realtime models such as gpt-realtime-2.

type RealtimeReasoningEffort string

Constrains effort on reasoning for reasoning-capable Realtime models such as gpt-realtime-2.

type RealtimeResponse struct{…}

The response resource.

type RealtimeResponseCreateAudioOutput struct{…}

Configuration for audio input and output.

type RealtimeResponseCreateMcpTool struct{…}

Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.

type RealtimeResponseCreateParamsResp struct{…}

Create a new Realtime response with these parameters

type RealtimeResponseStatus struct{…}

Additional details about the status.

type RealtimeResponseUsage struct{…}

Usage statistics for the Response, this will correspond to billing. A Realtime API session will maintain a conversation context and append new Items to the Conversation, thus output from previous turns (text and audio tokens) will become the input for later turns.

type RealtimeResponseUsageInputTokenDetails struct{…}

Details about the input tokens used in the Response. Cached tokens are tokens from previous turns in the conversation that are included as context for the current response. Cached tokens here are counted as a subset of input tokens, meaning input tokens will include cached and uncached tokens.

type RealtimeResponseUsageOutputTokenDetails struct{…}

Details about the output tokens used in the Response.

type RealtimeServerEventUnion interface{…}

A realtime server event.

type RealtimeSession struct{…}

Realtime session object for the beta interface.

type RealtimeSessionCreateRequest struct{…}

Realtime session object configuration.

type RealtimeToolChoiceConfigUnion interface{…}

How the model chooses tools. Provide one of the string modes or force a specific function/MCP tool.

type RealtimeToolsConfig []RealtimeToolsConfigUnion

Tools available to the model.

type RealtimeToolsConfigUnion interface{…}

Give the model access to additional tools via remote Model Context Protocol (MCP) servers. Learn more about MCP.

type RealtimeTracingConfigUnion interface{…}

Realtime API can write session traces to the Traces Dashboard. Set to null to disable tracing. Once tracing is enabled for a session, the configuration cannot be modified.

auto will create a trace for the session with default values for the workflow name, group id, and metadata.

type RealtimeTranscriptionSessionAudio struct{…}

Configuration for input and output audio.

type RealtimeTranscriptionSessionAudioInput struct{…}
type RealtimeTranscriptionSessionAudioInputTurnDetectionUnion interface{…}

Configuration for turn detection, ether Server VAD or Semantic VAD. This can be set to null to turn off, in which case the client must manually trigger model response.

Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech.

Semantic VAD is more advanced and uses a turn detection model (in conjunction with VAD) to semantically estimate whether the user has finished speaking, then dynamically sets a timeout based on this probability. For example, if user audio trails off with “uhhm”, the model will score a low probability of turn end and wait longer for the user to continue speaking. This can be useful for more natural conversations, but may have a higher latency.

For gpt-realtime-whisper transcription sessions, turn detection must be set to null; VAD is not supported.

type RealtimeTranscriptionSessionCreateRequest struct{…}

Realtime transcription session object configuration.

type RealtimeTranslationClientEventUnion interface{…}

A Realtime translation client event.

type RealtimeTranslationClientSecretCreateRequest struct{…}

Create a translation session and client secret for the Realtime API.

type RealtimeTranslationClientSecretCreateResponse struct{…}

Response from creating a translation session and client secret for the Realtime API.

type RealtimeTranslationInputAudioBufferAppendEvent struct{…}

Send this event to append audio bytes to the translation session input audio buffer.

WebSocket translation sessions accept base64-encoded 24 kHz PCM16 mono little-endian raw audio bytes. Unsupported websocket audio formats return a validation error because lower-quality audio materially degrades translation quality.

Translation consumes 200 ms engine frames. For best realtime behavior, append audio in 200 ms chunks. If a chunk is shorter, the server buffers it until it has enough audio for one frame. If a chunk is longer, the server splits it into 200 ms frames and enqueues them back-to-back.

Keep appending silence while the session is active. If a client stops sending audio and later resumes, model time treats the resumed audio as contiguous with the previous audio rather than as a real-world pause.

type RealtimeTranslationInputTranscriptDeltaEvent struct{…}

Returned when optional source-language transcript text is available. This event is emitted only when audio.input.transcription is configured.

Transcript deltas are append-only text fragments. Clients should not insert unconditional spaces between deltas.

type RealtimeTranslationOutputAudioDeltaEvent struct{…}

Returned when translated output audio is available. Output audio deltas are 200 ms frames of PCM16 audio.

type RealtimeTranslationOutputTranscriptDeltaEvent struct{…}

Returned when translated transcript text is available.

Transcript deltas are append-only text fragments. Clients should not insert unconditional spaces between deltas.

type RealtimeTranslationServerEventUnion interface{…}

A Realtime translation server event.

type RealtimeTranslationSession struct{…}

A Realtime translation session. Translation sessions continuously translate input audio into the configured output language.

type RealtimeTranslationSessionCloseEvent struct{…}

Gracefully close the realtime translation session. The server flushes pending input audio and emits any remaining translated output before closing the session.

type RealtimeTranslationSessionClosedEvent struct{…}

Returned when a realtime translation session is closed.

type RealtimeTranslationSessionCreateRequest struct{…}

Realtime translation session configuration. Translation sessions stream source audio in and translated audio plus transcript deltas out continuously.

type RealtimeTranslationSessionCreatedEvent struct{…}

Returned when a translation session is created. Emitted automatically when a new connection is established as the first server event. This event contains the default translation session configuration.

type RealtimeTranslationSessionUpdateEvent struct{…}

Send this event to update the translation session configuration. Translation sessions support updates to audio.output.language, audio.input.transcription, and audio.input.noise_reduction.

type RealtimeTranslationSessionUpdateRequest struct{…}

Realtime translation session fields that can be updated with session.update.

type RealtimeTranslationSessionUpdatedEvent struct{…}

Returned when a translation session is updated with a session.update event, unless there is an error.

type RealtimeTruncationUnion interface{…}

When the number of tokens in a conversation exceeds the model’s input token limit, the conversation be truncated, meaning messages (starting from the oldest) will not be included in the model’s context. A 32k context model with 4,096 max output tokens can only include 28,224 tokens in the context before truncation occurs.

Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.

Truncation will reduce the number of cached tokens on the next turn (busting the cache), since messages are dropped from the beginning of the context. However, clients can also configure truncation to retain messages up to a fraction of the maximum context size, which will reduce the need for future truncations and thus improve the cache rate.

Truncation can be disabled entirely, which means the server will never truncate but would instead return an error if the conversation exceeds the model’s input token limit.

type RealtimeTruncationRetentionRatio struct{…}

Retain a fraction of the conversation tokens when the conversation exceeds the input token limit. This allows you to amortize truncations across multiple turns, which can help improve cached token usage.

type ResponseAudioDeltaEvent struct{…}

Returned when the model-generated audio is updated.

type ResponseAudioDoneEvent struct{…}

Returned when the model-generated audio is done. Also emitted when a Response is interrupted, incomplete, or cancelled.

type ResponseAudioTranscriptDeltaEvent struct{…}

Returned when the model-generated transcription of audio output is updated.

type ResponseAudioTranscriptDoneEvent struct{…}

Returned when the model-generated transcription of audio output is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.

type ResponseCancelEvent struct{…}

Send this event to cancel an in-progress response. The server will respond with a response.done event with a status of response.status=cancelled. If there is no response to cancel, the server will respond with an error. It’s safe to call response.cancel even if no response is in progress, an error will be returned the session will remain unaffected.

type ResponseContentPartAddedEvent struct{…}

Returned when a new content part is added to an assistant message item during response generation.

type ResponseContentPartDoneEvent struct{…}

Returned when a content part is done streaming in an assistant message item. Also emitted when a Response is interrupted, incomplete, or cancelled.

type ResponseCreateEvent struct{…}

This event instructs the server to create a Response, which means triggering model inference. When in Server VAD mode, the server will create Responses automatically.

A Response will include at least one Item, and may have two, in which case the second will be a function call. These Items will be appended to the conversation history by default.

The server will respond with a response.created event, events for Items and content created, and finally a response.done event to indicate the Response is complete.

The response.create event includes inference configuration like instructions and tools. If these are set, they will override the Session’s configuration for this Response only.

Responses can be created out-of-band of the default Conversation, meaning that they can have arbitrary input, and it’s possible to disable writing the output to the Conversation. Only one Response can write to the default Conversation at a time, but otherwise multiple Responses can be created in parallel. The metadata field is a good way to disambiguate multiple simultaneous Responses.

Clients can set conversation to none to create a Response that does not write to the default Conversation. Arbitrary input can be provided with the input field, which is an array accepting raw Items and references to existing Items.

type ResponseCreatedEvent struct{…}

Returned when a new Response is created. The first event of response creation, where the response is in an initial state of in_progress.

type ResponseDoneEvent struct{…}

Returned when a Response is done streaming. Always emitted, no matter the final state. The Response object included in the response.done event will include all output Items in the Response but will omit the raw audio data.

Clients should check the status field of the Response to determine if it was successful (completed) or if there was another outcome: cancelled, failed, or incomplete.

A response will contain all output items that were generated during the response, excluding any audio content.

type ResponseFunctionCallArgumentsDeltaEvent struct{…}

Returned when the model-generated function call arguments are updated.

type ResponseFunctionCallArgumentsDoneEvent struct{…}

Returned when the model-generated function call arguments are done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.

type ResponseMcpCallArgumentsDelta struct{…}

Returned when MCP tool call arguments are updated during response generation.

type ResponseMcpCallArgumentsDone struct{…}

Returned when MCP tool call arguments are finalized during response generation.

type ResponseMcpCallCompleted struct{…}

Returned when an MCP tool call has completed successfully.

type ResponseMcpCallFailed struct{…}

Returned when an MCP tool call has failed.

type ResponseMcpCallInProgress struct{…}

Returned when an MCP tool call has started and is in progress.

type ResponseOutputItemAddedEvent struct{…}

Returned when a new Item is created during Response generation.

type ResponseOutputItemDoneEvent struct{…}

Returned when an Item is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.

type ResponseTextDeltaEvent struct{…}

Returned when the text value of an “output_text” content part is updated.

type ResponseTextDoneEvent struct{…}

Returned when the text value of an “output_text” content part is done streaming. Also emitted when a Response is interrupted, incomplete, or cancelled.

type SessionCreatedEvent struct{…}

Returned when a Session is created. Emitted automatically when a new connection is established as the first server event. This event will contain the default Session configuration.

type SessionUpdateEvent struct{…}

Send this event to update the session’s configuration. The client may send this event at any time to update any field except for voice and model. voice can be updated only if there have been no other audio outputs yet.

When the server receives a session.update, it will respond with a session.updated event showing the full, effective configuration. Only the fields that are present in the session.update are updated. To clear a field like instructions, pass an empty string. To clear a field like tools, pass an empty array. To clear a field like turn_detection, pass null.

type SessionUpdatedEvent struct{…}

Returned when a session is updated with a session.update event, unless there is an error.

type TranscriptionSessionUpdate struct{…}

Send this event to update a transcription session.

type TranscriptionSessionUpdatedEvent struct{…}

Returned when a transcription session is updated with a transcription_session.update event, unless there is an error.

RealtimeCalls

Accept call
client.Realtime.Calls.Accept(ctx, callID, body) error
POST/realtime/calls/{call_id}/accept
Hang up call
client.Realtime.Calls.Hangup(ctx, callID) error
POST/realtime/calls/{call_id}/hangup
Refer call
client.Realtime.Calls.Refer(ctx, callID, body) error
POST/realtime/calls/{call_id}/refer
Reject call
client.Realtime.Calls.Reject(ctx, callID, body) error
POST/realtime/calls/{call_id}/reject

RealtimeClient Secrets

Create client secret
client.Realtime.ClientSecrets.New(ctx, body) (*ClientSecretNewResponse, error)
POST/realtime/client_secrets
ModelsExpand Collapse
type RealtimeSessionCreateResponse struct{…}

A Realtime session configuration object.

type RealtimeTranscriptionSessionCreateResponse struct{…}

A Realtime transcription session configuration object.

type RealtimeTranscriptionSessionTurnDetection struct{…}

Configuration for turn detection. Can be set to null to turn off. Server VAD means that the model will detect the start and end of speech based on audio volume and respond at the end of user speech. For gpt-realtime-whisper, this must be null; VAD is not supported.

RealtimeSessions

RealtimeTranscription Sessions

RealtimeTranslations

RealtimeTranslationsClient Secrets