SPB Git

Repository Public

calls.md 33.0 KB 1,025 lines markdown

1# Calls23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45## Accept call67**post** `/realtime/calls/{call_id}/accept`89Accept an incoming SIP call and configure the realtime session that will10handle it.1112### Path Parameters1314- `call_id: string`1516### Body Parameters1718- `type: "realtime"`1920  The type of session to create. Always `realtime` for the Realtime API.2122  - `"realtime"`2324- `audio: optional RealtimeAudioConfig`2526  Configuration for input and output audio.2728  - `input: optional RealtimeAudioConfigInput`2930    - `format: optional RealtimeAudioFormats`3132      The format of the input audio.3334      - `PCMAudio object { rate, type }`3536        The PCM audio format. Only a 24kHz sample rate is supported.3738        - `rate: optional 24000`3940          The sample rate of the audio. Always `24000`.4142          - `24000`4344        - `type: optional "audio/pcm"`4546          The audio format. Always `audio/pcm`.4748          - `"audio/pcm"`4950      - `PCMUAudio object { type }`5152        The G.711 μ-law format.5354        - `type: optional "audio/pcmu"`5556          The audio format. Always `audio/pcmu`.5758          - `"audio/pcmu"`5960      - `PCMAAudio object { type }`6162        The G.711 A-law format.6364        - `type: optional "audio/pcma"`6566          The audio format. Always `audio/pcma`.6768          - `"audio/pcma"`6970    - `noise_reduction: optional object { type }`7172      Configuration for input audio noise reduction. This can be set to `null` to turn off.73      Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.74      Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.7576      - `type: optional NoiseReductionType`7778        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.7980        - `"near_field"`8182        - `"far_field"`8384    - `transcription: optional AudioTranscription`8586      Configuration for input audio transcription, defaults to off and can be set to `null` to turn off once on. Input audio transcription is not native to the model, since the model consumes audio directly. Transcription runs asynchronously through [the /audio/transcriptions endpoint](/api/reference/resources/audio/subresources/transcriptions/methods/create) and should be treated as guidance of input audio content rather than precisely what the model heard. The client can optionally set the language and prompt for transcription, these offer additional guidance to the transcription service.8788      - `delay: optional "minimal" or "low" or "medium" or 2 more`8990        Controls how long the model waits before emitting transcription text.91        Higher values can improve transcription accuracy at the cost of latency.92        Only supported with `gpt-realtime-whisper` in GA Realtime sessions.9394        - `"minimal"`9596        - `"low"`9798        - `"medium"`99100        - `"high"`101102        - `"xhigh"`103104      - `keywords: optional array of string`105106        Words or phrases to guide transcription of the input audio. Supported by `gpt-transcribe` and `gpt-live-transcribe`.107108      - `language: optional string`109110        The language of the input audio. Supplying the input language in111        [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format112        will improve accuracy and latency.113114      - `languages: optional array of string`115116        Possible languages of the input audio, in [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) format. Supported by `gpt-transcribe` and `gpt-live-transcribe`.117118      - `model: optional string or "whisper-1" or "gpt-transcribe" or "gpt-live-transcribe" or 5 more`119120        The model to use for transcription. Current options are `whisper-1`, `gpt-transcribe`, `gpt-live-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.121122        - `string`123124        - `"whisper-1" or "gpt-transcribe" or "gpt-live-transcribe" or 5 more`125126          The model to use for transcription. Current options are `whisper-1`, `gpt-transcribe`, `gpt-live-transcribe`, `gpt-4o-mini-transcribe`, `gpt-4o-mini-transcribe-2025-12-15`, `gpt-4o-transcribe`, `gpt-4o-transcribe-diarize`, and `gpt-realtime-whisper`. Use `gpt-4o-transcribe-diarize` when you need diarization with speaker labels.127128          - `"whisper-1"`129130          - `"gpt-transcribe"`131132          - `"gpt-live-transcribe"`133134          - `"gpt-4o-mini-transcribe"`135136          - `"gpt-4o-mini-transcribe-2025-12-15"`137138          - `"gpt-4o-transcribe"`139140          - `"gpt-4o-transcribe-diarize"`141142          - `"gpt-realtime-whisper"`143144      - `prompt: optional string`145146        An optional text to guide the model's style or continue a previous audio147        segment.148        For `whisper-1`, the [prompt is a list of keywords](/api/docs/guides/speech-to-text#prompting).149        For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".150        Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.151152    - `turn_detection: optional RealtimeAudioInputTurnDetection or null`153154      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.155156      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.157158      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.159160      For `gpt-realtime-whisper` transcription sessions, turn detection must be161      set to `null`; VAD is not supported.162163      - `ServerVad object { type, create_response, idle_timeout_ms, 4 more }`164165        Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.166167        - `type: "server_vad"`168169          Type of turn detection, `server_vad` to turn on simple Server VAD.170171          - `"server_vad"`172173        - `create_response: optional boolean`174175          Whether or not to automatically generate a response when a VAD stop event occurs. If `interrupt_response` is set to `false` this may fail to create a response if the model is already responding.176177          If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.178179        - `idle_timeout_ms: optional number or null`180181          Optional timeout after which a model response will be triggered automatically. This is182          useful for situations in which a long pause from the user is unexpected, such as a phone183          call. The model will effectively prompt the user to continue the conversation based184          on the current context.185186          The timeout value will be applied after the last model response's audio has finished playing,187          i.e. it's set to the `response.done` time plus audio playback duration.188189          An `input_audio_buffer.timeout_triggered` event (plus events190          associated with the Response) will be emitted when the timeout is reached.191          Idle timeout is currently only supported for `server_vad` mode.192193        - `interrupt_response: optional boolean`194195          Whether or not to automatically interrupt (cancel) any ongoing response with output to the default196          conversation (i.e. `conversation` of `auto`) when a VAD start event occurs. If `true` then the response will be cancelled, otherwise it will continue until complete.197198          If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.199200        - `prefix_padding_ms: optional number`201202          Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in203          milliseconds). Defaults to 300ms.204205        - `silence_duration_ms: optional number`206207          Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults208          to 500ms. With shorter values the model will respond more quickly,209          but may jump in on short pauses from the user.210211        - `threshold: optional number`212213          Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A214          higher threshold will require louder audio to activate the model, and215          thus might perform better in noisy environments.216217      - `SemanticVad object { type, create_response, eagerness, interrupt_response }`218219        Server-side semantic turn detection which uses a model to determine when the user has finished speaking.220221        - `type: "semantic_vad"`222223          Type of turn detection, `semantic_vad` to turn on Semantic VAD.224225          - `"semantic_vad"`226227        - `create_response: optional boolean`228229          Whether or not to automatically generate a response when a VAD stop event occurs.230231        - `eagerness: optional "low" or "medium" or "high" or "auto"`232233          Used only for `semantic_vad` mode. The eagerness of the model to respond. `low` will wait longer for the user to continue speaking, `high` will respond more quickly. `auto` is the default and is equivalent to `medium`. `low`, `medium`, and `high` have max timeouts of 8s, 4s, and 2s respectively.234235          - `"low"`236237          - `"medium"`238239          - `"high"`240241          - `"auto"`242243        - `interrupt_response: optional boolean`244245          Whether or not to automatically interrupt any ongoing response with output to the default246          conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.247248  - `output: optional RealtimeAudioConfigOutput`249250    - `format: optional RealtimeAudioFormats`251252      The format of the output audio.253254    - `speed: optional number`255256      The speed of the model's spoken response as a multiple of the original speed.257      1.0 is the default speed. 0.25 is the minimum speed. 1.5 is the maximum speed. This value can only be changed in between model turns, not while a response is in progress.258259      This parameter is a post-processing adjustment to the audio after it is generated, it's260      also possible to prompt the model to speak faster or slower.261262    - `voice: optional string or "alloy" or "ash" or "ballad" or 7 more or object { id }`263264      The voice the model uses to respond. Supported built-in voices are265      `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,266      `marin`, and `cedar`. You may also provide a custom voice object with267      an `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed268      during the session once the model has responded with audio at least once.269      We recommend `marin` and `cedar` for best quality.270271      - `string`272273      - `"alloy" or "ash" or "ballad" or 7 more`274275        - `"alloy"`276277        - `"ash"`278279        - `"ballad"`280281        - `"coral"`282283        - `"echo"`284285        - `"sage"`286287        - `"shimmer"`288289        - `"verse"`290291        - `"marin"`292293        - `"cedar"`294295      - `ID object { id }`296297        Custom voice reference.298299        - `id: string`300301          The custom voice ID, e.g. `voice_1234`.302303- `include: optional array of "item.input_audio_transcription.logprobs"`304305  Additional fields to include in server outputs.306307  `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.308309  - `"item.input_audio_transcription.logprobs"`310311- `instructions: optional string`312313  The default system instructions (i.e. system message) prepended to model calls. This field allows the client to guide the model on desired responses. The model can be instructed on response content and format, (e.g. "be extremely succinct", "act friendly", "here are examples of good responses") and on audio behavior (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The instructions are not guaranteed to be followed by the model, but they provide guidance to the model on the desired behavior.314315  Note that the server sets default instructions which will be used if this field is not set and are visible in the `session.created` event at the start of the session.316317- `max_output_tokens: optional number or "inf"`318319  Maximum number of output tokens for a single assistant response,320  inclusive of tool calls. Provide an integer between 1 and 4096 to321  limit output tokens, or `inf` for the maximum available tokens for a322  given model. Defaults to `inf`.323324  - `number`325326  - `"inf"`327328    - `"inf"`329330- `model: optional string or "gpt-realtime" or "gpt-realtime-1.5" or "gpt-realtime-2" or 16 more`331332  The Realtime model used for this session.333334  - `string`335336  - `"gpt-realtime" or "gpt-realtime-1.5" or "gpt-realtime-2" or 16 more`337338    The Realtime model used for this session.339340    - `"gpt-realtime"`341342    - `"gpt-realtime-1.5"`343344    - `"gpt-realtime-2"`345346    - `"gpt-realtime-2.1"`347348    - `"gpt-realtime-2.1-mini"`349350    - `"gpt-realtime-2025-08-28"`351352    - `"gpt-4o-realtime-preview"`353354    - `"gpt-4o-realtime-preview-2024-10-01"`355356    - `"gpt-4o-realtime-preview-2024-12-17"`357358    - `"gpt-4o-realtime-preview-2025-06-03"`359360    - `"gpt-4o-mini-realtime-preview"`361362    - `"gpt-4o-mini-realtime-preview-2024-12-17"`363364    - `"gpt-realtime-mini"`365366    - `"gpt-realtime-mini-2025-10-06"`367368    - `"gpt-realtime-mini-2025-12-15"`369370    - `"gpt-audio-1.5"`371372    - `"gpt-audio-mini"`373374    - `"gpt-audio-mini-2025-10-06"`375376    - `"gpt-audio-mini-2025-12-15"`377378- `output_modalities: optional array of "text" or "audio"`379380  The set of modalities the model can respond with. It defaults to `["audio"]`, indicating381  that the model will respond with audio plus a transcript. `["text"]` can be used to make382  the model respond with text only. It is not possible to request both `text` and `audio` at the same time.383384  - `"text"`385386  - `"audio"`387388- `parallel_tool_calls: optional boolean`389390  Whether the model may call multiple tools in parallel. Only supported by391  reasoning Realtime models such as `gpt-realtime-2`.392393- `prompt: optional ResponsePrompt or null`394395  Reference to a prompt template and its variables.396  [Learn more](/api/docs/guides/text?api-mode=responses#version-prompts-in-code).397398  - `id: string`399400    The unique identifier of the prompt template to use.401402  - `variables: optional map[string or ResponseInputText or ResponseInputImage or ResponseInputFile] or null`403404    Optional map of values to substitute in for variables in your405    prompt. The substitution values can either be strings, or other406    Response input types like images or files.407408    - `string`409410    - `ResponseInputText object { text, type, prompt_cache_breakpoint }`411412      A text input to the model.413414      - `text: string`415416        The text input to the model.417418      - `type: "input_text"`419420        The type of the input item. Always `input_text`.421422        - `"input_text"`423424      - `prompt_cache_breakpoint: optional object { mode }`425426        Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.427428        - `mode: "explicit"`429430          The breakpoint mode. Always `explicit`.431432          - `"explicit"`433434    - `ResponseInputImage object { detail, type, file_id, 2 more }`435436      An image input to the model. Learn about [image inputs](/api/docs/guides/images-vision).437438      - `detail: ImageDetail`439440        The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.441442        - `"low"`443444        - `"high"`445446        - `"auto"`447448        - `"original"`449450      - `type: "input_image"`451452        The type of the input item. Always `input_image`.453454        - `"input_image"`455456      - `file_id: optional string or null`457458        The ID of the file to be sent to the model.459460      - `image_url: optional string or null`461462        The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.463464      - `prompt_cache_breakpoint: optional object { mode }`465466        Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.467468        - `mode: "explicit"`469470          The breakpoint mode. Always `explicit`.471472          - `"explicit"`473474    - `ResponseInputFile object { type, detail, file_data, 4 more }`475476      A file input to the model.477478      - `type: "input_file"`479480        The type of the input item. Always `input_file`.481482        - `"input_file"`483484      - `detail: optional "auto" or "low" or "high"`485486        The detail level of the file to be sent to the model. Use `auto` to let the system select the detail level; for GPT-5.6 and later models, `auto` uses high-quality rendering, which may increase input token usage. Use `low` for lower-cost rendering, or `high` to render the file at higher quality. Defaults to `auto`.487488        - `"auto"`489490        - `"low"`491492        - `"high"`493494      - `file_data: optional string`495496        The content of the file to be sent to the model.497498      - `file_id: optional string or null`499500        The ID of the file to be sent to the model.501502      - `file_url: optional string`503504        The URL of the file to be sent to the model.505506      - `filename: optional string`507508        The name of the file to be sent to the model.509510      - `prompt_cache_breakpoint: optional object { mode }`511512        Marks the exact end of a reusable prompt prefix. The breakpoint inherits its TTL from the request's `prompt_cache_options.ttl`; the boundary is not rounded to a token block.513514        - `mode: "explicit"`515516          The breakpoint mode. Always `explicit`.517518          - `"explicit"`519520  - `version: optional string or null`521522    Optional version of the prompt template.523524- `reasoning: optional RealtimeReasoning`525526  Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.527528  - `effort: optional RealtimeReasoningEffort`529530    Constrains effort on reasoning for reasoning-capable Realtime models such as531    `gpt-realtime-2`.532533    - `"minimal"`534535    - `"low"`536537    - `"medium"`538539    - `"high"`540541    - `"xhigh"`542543- `tool_choice: optional RealtimeToolChoiceConfig`544545  How the model chooses tools. Provide one of the string modes or force a specific546  function/MCP tool.547548  - `ToolChoiceOptions = "none" or "auto" or "required"`549550    Controls which (if any) tool is called by the model.551552    `none` means the model will not call any tool and instead generates a message.553554    `auto` means the model can pick between generating a message or calling one or555    more tools.556557    `required` means the model must call one or more tools.558559    - `"none"`560561    - `"auto"`562563    - `"required"`564565  - `ToolChoiceFunction object { name, type }`566567    Use this option to force the model to call a specific function.568569    - `name: string`570571      The name of the function to call.572573    - `type: "function"`574575      For function calling, the type is always `function`.576577      - `"function"`578579  - `ToolChoiceMcp object { server_label, type, name }`580581    Use this option to force the model to call a specific tool on a remote MCP server.582583    - `server_label: string`584585      The label of the MCP server to use.586587    - `type: "mcp"`588589      For MCP tools, the type is always `mcp`.590591      - `"mcp"`592593    - `name: optional string or null`594595      The name of the tool to call on the server.596597- `tools: optional RealtimeToolsConfig`598599  Tools available to the model.600601  - `RealtimeFunctionTool object { description, name, parameters, type }`602603    - `description: optional string`604605      The description of the function, including guidance on when and how606      to call it, and guidance about what to tell the user when calling607      (if anything).608609    - `name: optional string`610611      The name of the function.612613    - `parameters: optional unknown`614615      Parameters of the function in JSON Schema.616617    - `type: optional "function"`618619      The type of the tool, i.e. `function`.620621      - `"function"`622623  - `McpTool object { server_label, type, allowed_callers, 9 more }`624625    Give the model access to additional tools via remote Model Context Protocol626    (MCP) servers. [Learn more about MCP](/api/docs/guides/tools-connectors-mcp).627628    - `server_label: string`629630      A label for this MCP server, used to identify it in tool calls.631632    - `type: "mcp"`633634      The type of the MCP tool. Always `mcp`.635636      - `"mcp"`637638    - `allowed_callers: optional array of "direct" or "programmatic" or null`639640      The tool invocation context(s).641642      - `"direct"`643644      - `"programmatic"`645646    - `allowed_tools: optional array of string or object { read_only, tool_names }  or null`647648      List of allowed tool names or a filter object.649650      - `McpAllowedTools = array of string`651652        A string array of allowed tool names653654      - `McpToolFilter object { read_only, tool_names }`655656        A filter object to specify which tools are allowed.657658        - `read_only: optional boolean`659660          Indicates whether or not a tool modifies data or is read-only. If an661          MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),662          it will match this filter.663664        - `tool_names: optional array of string`665666          List of allowed tool names.667668    - `authorization: optional string`669670      An OAuth access token that can be used with a remote MCP server, either671      with a custom MCP server URL or a service connector. Your application672      must handle the OAuth authorization flow and provide the token here.673674    - `connector_id: optional "connector_dropbox" or "connector_gmail" or "connector_googlecalendar" or 5 more`675676      Identifier for service connectors, like those available in ChatGPT. One of677      `server_url`, `connector_id`, or `tunnel_id` must be provided. Learn more678      about service connectors [here](/api/docs/guides/tools-connectors-mcp#connectors).679680      This field is deprecated for models released after September 1, 2026.681      Use `server_url` to connect to a remote MCP server, or `tunnel_id` to682      connect through a Secure MCP Tunnel.683684      Currently supported `connector_id` values are:685686      - Dropbox: `connector_dropbox`687      - Gmail: `connector_gmail`688      - Google Calendar: `connector_googlecalendar`689      - Google Drive: `connector_googledrive`690      - Microsoft Teams: `connector_microsoftteams`691      - Outlook Calendar: `connector_outlookcalendar`692      - Outlook Email: `connector_outlookemail`693      - SharePoint: `connector_sharepoint`694695      - `"connector_dropbox"`696697      - `"connector_gmail"`698699      - `"connector_googlecalendar"`700701      - `"connector_googledrive"`702703      - `"connector_microsoftteams"`704705      - `"connector_outlookcalendar"`706707      - `"connector_outlookemail"`708709      - `"connector_sharepoint"`710711    - `defer_loading: optional boolean`712713      Whether this MCP tool is deferred and discovered via tool search.714715    - `headers: optional map[string] or null`716717      Optional HTTP headers to send to the MCP server. Use for authentication718      or other purposes.719720    - `require_approval: optional object { always, never }  or "always" or "never" or null`721722      Specify which of the MCP server's tools require approval.723724      - `McpToolApprovalFilter object { always, never }`725726        Specify which of the MCP server's tools require approval. Can be727        `always`, `never`, or a filter object associated with tools728        that require approval.729730        - `always: optional object { read_only, tool_names }`731732          A filter object to specify which tools are allowed.733734          - `read_only: optional boolean`735736            Indicates whether or not a tool modifies data or is read-only. If an737            MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),738            it will match this filter.739740          - `tool_names: optional array of string`741742            List of allowed tool names.743744        - `never: optional object { read_only, tool_names }`745746          A filter object to specify which tools are allowed.747748          - `read_only: optional boolean`749750            Indicates whether or not a tool modifies data or is read-only. If an751            MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),752            it will match this filter.753754          - `tool_names: optional array of string`755756            List of allowed tool names.757758      - `McpToolApprovalSetting = "always" or "never"`759760        Specify a single approval policy for all tools. One of `always` or761        `never`. When set to `always`, all tools will require approval. When762        set to `never`, all tools will not require approval.763764        - `"always"`765766        - `"never"`767768    - `server_description: optional string`769770      Optional description of the MCP server, used to provide more context.771772    - `server_url: optional string`773774      The URL for the MCP server. One of `server_url`, `connector_id`, or775      `tunnel_id` must be provided.776777    - `tunnel_id: optional string`778779      The Secure MCP Tunnel ID to use instead of a direct server URL. One of780      `server_url`, `connector_id`, or `tunnel_id` must be provided.781782- `tracing: optional RealtimeTracingConfig or null`783784  Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once785  tracing is enabled for a session, the configuration cannot be modified.786787  `auto` will create a trace for the session with default values for the788  workflow name, group id, and metadata.789790  - `Auto = "auto"`791792    Enables tracing and sets default values for tracing configuration options. Always `auto`.793794    - `"auto"`795796  - `TracingConfiguration object { group_id, metadata, workflow_name }`797798    Granular configuration for tracing.799800    - `group_id: optional string`801802      The group id to attach to this trace to enable filtering and803      grouping in the Traces Dashboard.804805    - `metadata: optional unknown`806807      The arbitrary metadata to attach to this trace to enable808      filtering in the Traces Dashboard.809810    - `workflow_name: optional string`811812      The name of the workflow to attach to this trace. This is used to813      name the trace in the Traces Dashboard.814815- `truncation: optional RealtimeTruncation`816817  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.818819  Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.820821  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.822823  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.824825  - `"auto" or "disabled"`826827    The truncation strategy to use for the session. `auto` is the default truncation strategy. `disabled` will disable truncation and emit errors when the conversation exceeds the input token limit.828829    - `"auto"`830831    - `"disabled"`832833  - `RetentionRatioTruncation object { retention_ratio, type, token_limits }`834835    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.836837    - `retention_ratio: number`838839      Fraction of post-instruction conversation tokens to retain (`0.0` - `1.0`) when the conversation exceeds the input token limit. Setting this to `0.8` means that messages will be dropped until 80% of the maximum allowed tokens are used. This helps reduce the frequency of truncations and improve cache rates.840841    - `type: "retention_ratio"`842843      Use retention ratio truncation.844845      - `"retention_ratio"`846847    - `token_limits: optional object { post_instructions }`848849      Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.850851      - `post_instructions: optional number`852853        Maximum tokens allowed in the conversation after instructions (which including tool definitions). For example, setting this to 5,000 would mean that truncation would occur when the conversation exceeds 5,000 tokens after instructions. This cannot be higher than the model's context window size minus the maximum output tokens.854855### Example856857```http858curl https://api.openai.com/v1/realtime/calls/$CALL_ID/accept \859    -H 'Content-Type: application/json' \860    -H "Authorization: Bearer $OPENAI_API_KEY" \861    -d '{862          "type": "realtime"863        }'864```865866### Example867868```http869curl -X POST https://api.openai.com/v1/realtime/calls/$CALL_ID/accept \870  -H "Authorization: Bearer $OPENAI_API_KEY" \871  -H "Content-Type: application/json" \872  -d '{873        "type": "realtime",874        "model": "gpt-realtime",875        "instructions": "You are Alex, a friendly concierge for Example Corp.",876      }'877```878879## Create call880881**post** `/realtime/calls`882883Create a new Realtime API call over WebRTC and receive the SDP answer needed884to complete the peer connection.885886### Example887888```http889curl https://api.openai.com/v1/realtime/calls \890    -H 'Content-Type: multipart/form-data' \891    -H "Authorization: Bearer $OPENAI_API_KEY" \892    -F sdp=sdp893```894895### Example896897```http898curl -X POST https://api.openai.com/v1/realtime/calls \899  -H "Authorization: Bearer $OPENAI_API_KEY" \900  -F "sdp=<offer.sdp;type=application/sdp" \901  -F 'session={"type":"realtime","model":"gpt-realtime"};type=application/json'902```903904#### Response905906```json907v=0908o=- 4227147428 1719357865 IN IP4 127.0.0.1909s=-910c=IN IP4 0.0.0.0911t=0 0912a=group:BUNDLE 0 1913a=msid-semantic:WMS *914a=fingerprint:sha-256 CA:92:52:51:B4:91:3B:34:DD:9C:0B:FB:76:19:7E:3B:F1:21:0F:32:2C:38:01:72:5D:3F:78:C7:5F:8B:C7:36915m=audio 9 UDP/TLS/RTP/SAVPF 111 0 8916a=mid:0917a=ice-ufrag:kZ2qkHXX/u11918a=ice-pwd:uoD16Di5OGx3VbqgA3ymjEQV2kwiOjw6919a=setup:active920a=rtcp-mux921a=rtpmap:111 opus/48000/2922a=candidate:993865896 1 udp 2130706431 4.155.146.196 3478 typ host ufrag kZ2qkHXX/u11923a=candidate:1432411780 1 tcp 1671430143 4.155.146.196 443 typ host tcptype passive ufrag kZ2qkHXX/u11924m=application 9 UDP/DTLS/SCTP webrtc-datachannel925a=mid:1926a=sctp-port:5000927```928929## Hang up call930931**post** `/realtime/calls/{call_id}/hangup`932933End an active Realtime API call, whether it was initiated over SIP or934WebRTC.935936### Path Parameters937938- `call_id: string`939940### Example941942```http943curl https://api.openai.com/v1/realtime/calls/$CALL_ID/hangup \944    -X POST \945    -H "Authorization: Bearer $OPENAI_API_KEY"946```947948### Example949950```http951curl -X POST https://api.openai.com/v1/realtime/calls/$CALL_ID/hangup \952  -H "Authorization: Bearer $OPENAI_API_KEY"953```954955## Refer call956957**post** `/realtime/calls/{call_id}/refer`958959Transfer an active SIP call to a new destination using the SIP REFER verb.960961### Path Parameters962963- `call_id: string`964965### Body Parameters966967- `target_uri: string`968969  URI that should appear in the SIP Refer-To header. Supports values like970  `tel:+14155550123` or `sip:agent@example.com`.971972### Example973974```http975curl https://api.openai.com/v1/realtime/calls/$CALL_ID/refer \976    -H 'Content-Type: application/json' \977    -H "Authorization: Bearer $OPENAI_API_KEY" \978    -d '{979          "target_uri": "tel:+14155550123"980        }'981```982983### Example984985```http986curl -X POST https://api.openai.com/v1/realtime/calls/$CALL_ID/refer \987  -H "Authorization: Bearer $OPENAI_API_KEY" \988  -H "Content-Type: application/json" \989  -d '{"target_uri": "tel:+14155550123"}'990```991992## Reject call993994**post** `/realtime/calls/{call_id}/reject`995996Decline an incoming SIP call by returning a SIP status code to the caller.997998### Path Parameters9991000- `call_id: string`10011002### Body Parameters10031004- `status_code: optional number`10051006  SIP response code to send back to the caller. Defaults to `603` (Decline)1007  when omitted.10081009### Example10101011```http1012curl https://api.openai.com/v1/realtime/calls/$CALL_ID/reject \1013    -X POST \1014    -H "Authorization: Bearer $OPENAI_API_KEY"1015```10161017### Example10181019```http1020curl -X POST https://api.openai.com/v1/realtime/calls/$CALL_ID/reject \1021  -H "Authorization: Bearer $OPENAI_API_KEY" \1022  -H "Content-Type: application/json" \1023  -d '{"status_code": 486}'1024```1025
Files main
Menu

Theme