ruby/resources/realtime/subresources/calls/index.md +0 −881 deleted
File Deleted View Diff
1# Calls
2
3## Accept call
4
5`realtime.calls.accept(call_id, **kwargs) -> void`
6
7**post** `/realtime/calls/{call_id}/accept`
8
9Accept an incoming SIP call and configure the realtime session that will
10handle it.
11
12### Parameters
13
14- `call_id: String`
15
16- `type: :realtime`
17
18 The type of session to create. Always `realtime` for the Realtime API.
19
20 - `:realtime`
21
22- `audio: RealtimeAudioConfig`
23
24 Configuration for input and output audio.
25
26 - `input: RealtimeAudioConfigInput`
27
28 - `format_: RealtimeAudioFormats`
29
30 The format of the input audio.
31
32 - `class AudioPCM`
33
34 The PCM audio format. Only a 24kHz sample rate is supported.
35
36 - `rate: 24000`
37
38 The sample rate of the audio. Always `24000`.
39
40 - `24000`
41
42 - `type: :"audio/pcm"`
43
44 The audio format. Always `audio/pcm`.
45
46 - `:"audio/pcm"`
47
48 - `class AudioPCMU`
49
50 The G.711 μ-law format.
51
52 - `type: :"audio/pcmu"`
53
54 The audio format. Always `audio/pcmu`.
55
56 - `:"audio/pcmu"`
57
58 - `class AudioPCMA`
59
60 The G.711 A-law format.
61
62 - `type: :"audio/pcma"`
63
64 The audio format. Always `audio/pcma`.
65
66 - `:"audio/pcma"`
67
68 - `noise_reduction: NoiseReduction{ type}`
69
70 Configuration for input audio noise reduction. This can be set to `null` to turn off.
71 Noise reduction filters audio added to the input audio buffer before it is sent to VAD and the model.
72 Filtering the audio can improve VAD and turn detection accuracy (reducing false positives) and model performance by improving perception of the input audio.
73
74 - `type: NoiseReductionType`
75
76 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.
77
78 - `:near_field`
79
80 - `:far_field`
81
82 - `transcription: AudioTranscription`
83
84 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](https://platform.openai.com/docs/api-reference/audio/createTranscription) 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.
85
86 - `delay: :minimal | :low | :medium | 2 more`
87
88 Controls how long the model waits before emitting transcription text.
89 Higher values can improve transcription accuracy at the cost of latency.
90 Only supported with `gpt-realtime-whisper` in GA Realtime sessions.
91
92 - `:minimal`
93
94 - `:low`
95
96 - `:medium`
97
98 - `:high`
99
100 - `:xhigh`
101
102 - `language: String`
103
104 The language of the input audio. Supplying the input language in
105 [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`) format
106 will improve accuracy and latency.
107
108 - `model: String | :"whisper-1" | :"gpt-4o-mini-transcribe" | :"gpt-4o-mini-transcribe-2025-12-15" | 3 more`
109
110 The model to use for transcription. Current options are `whisper-1`, `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.
111
112 - `String = String`
113
114 - `Model = :"whisper-1" | :"gpt-4o-mini-transcribe" | :"gpt-4o-mini-transcribe-2025-12-15" | 3 more`
115
116 The model to use for transcription. Current options are `whisper-1`, `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.
117
118 - `:"whisper-1"`
119
120 - `:"gpt-4o-mini-transcribe"`
121
122 - `:"gpt-4o-mini-transcribe-2025-12-15"`
123
124 - `:"gpt-4o-transcribe"`
125
126 - `:"gpt-4o-transcribe-diarize"`
127
128 - `:"gpt-realtime-whisper"`
129
130 - `prompt: String`
131
132 An optional text to guide the model's style or continue a previous audio
133 segment.
134 For `whisper-1`, the [prompt is a list of keywords](https://platform.openai.com/docs/guides/speech-to-text#prompting).
135 For `gpt-4o-transcribe` models (excluding `gpt-4o-transcribe-diarize`), the prompt is a free text string, for example "expect words related to technology".
136 Prompt is not supported with `gpt-realtime-whisper` in GA Realtime sessions.
137
138 - `turn_detection: RealtimeAudioInputTurnDetection`
139
140 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.
141
142 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.
143
144 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.
145
146 For `gpt-realtime-whisper` transcription sessions, turn detection must be
147 set to `null`; VAD is not supported.
148
149 - `class ServerVad`
150
151 Server-side voice activity detection (VAD) which flips on when user speech is detected and off after a period of silence.
152
153 - `type: :server_vad`
154
155 Type of turn detection, `server_vad` to turn on simple Server VAD.
156
157 - `:server_vad`
158
159 - `create_response: bool`
160
161 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.
162
163 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.
164
165 - `idle_timeout_ms: Integer`
166
167 Optional timeout after which a model response will be triggered automatically. This is
168 useful for situations in which a long pause from the user is unexpected, such as a phone
169 call. The model will effectively prompt the user to continue the conversation based
170 on the current context.
171
172 The timeout value will be applied after the last model response's audio has finished playing,
173 i.e. it's set to the `response.done` time plus audio playback duration.
174
175 An `input_audio_buffer.timeout_triggered` event (plus events
176 associated with the Response) will be emitted when the timeout is reached.
177 Idle timeout is currently only supported for `server_vad` mode.
178
179 - `interrupt_response: bool`
180
181 Whether or not to automatically interrupt (cancel) any ongoing response with output to the default
182 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.
183
184 If both `create_response` and `interrupt_response` are set to `false`, the model will never respond automatically but VAD events will still be emitted.
185
186 - `prefix_padding_ms: Integer`
187
188 Used only for `server_vad` mode. Amount of audio to include before the VAD detected speech (in
189 milliseconds). Defaults to 300ms.
190
191 - `silence_duration_ms: Integer`
192
193 Used only for `server_vad` mode. Duration of silence to detect speech stop (in milliseconds). Defaults
194 to 500ms. With shorter values the model will respond more quickly,
195 but may jump in on short pauses from the user.
196
197 - `threshold: Float`
198
199 Used only for `server_vad` mode. Activation threshold for VAD (0.0 to 1.0), this defaults to 0.5. A
200 higher threshold will require louder audio to activate the model, and
201 thus might perform better in noisy environments.
202
203 - `class SemanticVad`
204
205 Server-side semantic turn detection which uses a model to determine when the user has finished speaking.
206
207 - `type: :semantic_vad`
208
209 Type of turn detection, `semantic_vad` to turn on Semantic VAD.
210
211 - `:semantic_vad`
212
213 - `create_response: bool`
214
215 Whether or not to automatically generate a response when a VAD stop event occurs.
216
217 - `eagerness: :low | :medium | :high | :auto`
218
219 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.
220
221 - `:low`
222
223 - `:medium`
224
225 - `:high`
226
227 - `:auto`
228
229 - `interrupt_response: bool`
230
231 Whether or not to automatically interrupt any ongoing response with output to the default
232 conversation (i.e. `conversation` of `auto`) when a VAD start event occurs.
233
234 - `output: RealtimeAudioConfigOutput`
235
236 - `format_: RealtimeAudioFormats`
237
238 The format of the output audio.
239
240 - `speed: Float`
241
242 The speed of the model's spoken response as a multiple of the original speed.
243 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.
244
245 This parameter is a post-processing adjustment to the audio after it is generated, it's
246 also possible to prompt the model to speak faster or slower.
247
248 - `voice: String | :alloy | :ash | :ballad | 7 more | ID{ id}`
249
250 The voice the model uses to respond. Supported built-in voices are
251 `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, `verse`,
252 `marin`, and `cedar`. You may also provide a custom voice object with
253 an `id`, for example `{ "id": "voice_1234" }`. Voice cannot be changed
254 during the session once the model has responded with audio at least once.
255 We recommend `marin` and `cedar` for best quality.
256
257 - `String = String`
258
259 - `Voice = :alloy | :ash | :ballad | 7 more`
260
261 - `:alloy`
262
263 - `:ash`
264
265 - `:ballad`
266
267 - `:coral`
268
269 - `:echo`
270
271 - `:sage`
272
273 - `:shimmer`
274
275 - `:verse`
276
277 - `:marin`
278
279 - `:cedar`
280
281 - `class ID`
282
283 Custom voice reference.
284
285 - `id: String`
286
287 The custom voice ID, e.g. `voice_1234`.
288
289- `include: Array[:"item.input_audio_transcription.logprobs"]`
290
291 Additional fields to include in server outputs.
292
293 `item.input_audio_transcription.logprobs`: Include logprobs for input audio transcription.
294
295 - `:"item.input_audio_transcription.logprobs"`
296
297- `instructions: String`
298
299 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.
300
301 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.
302
303- `max_output_tokens: Integer | :inf`
304
305 Maximum number of output tokens for a single assistant response,
306 inclusive of tool calls. Provide an integer between 1 and 4096 to
307 limit output tokens, or `inf` for the maximum available tokens for a
308 given model. Defaults to `inf`.
309
310 - `Integer = Integer`
311
312 - `MaxOutputTokens = :inf`
313
314 - `:inf`
315
316- `model: String | :"gpt-realtime" | :"gpt-realtime-1.5" | :"gpt-realtime-2" | 14 more`
317
318 The Realtime model used for this session.
319
320 - `String = String`
321
322 - `Model = :"gpt-realtime" | :"gpt-realtime-1.5" | :"gpt-realtime-2" | 14 more`
323
324 The Realtime model used for this session.
325
326 - `:"gpt-realtime"`
327
328 - `:"gpt-realtime-1.5"`
329
330 - `:"gpt-realtime-2"`
331
332 - `:"gpt-realtime-2025-08-28"`
333
334 - `:"gpt-4o-realtime-preview"`
335
336 - `:"gpt-4o-realtime-preview-2024-10-01"`
337
338 - `:"gpt-4o-realtime-preview-2024-12-17"`
339
340 - `:"gpt-4o-realtime-preview-2025-06-03"`
341
342 - `:"gpt-4o-mini-realtime-preview"`
343
344 - `:"gpt-4o-mini-realtime-preview-2024-12-17"`
345
346 - `:"gpt-realtime-mini"`
347
348 - `:"gpt-realtime-mini-2025-10-06"`
349
350 - `:"gpt-realtime-mini-2025-12-15"`
351
352 - `:"gpt-audio-1.5"`
353
354 - `:"gpt-audio-mini"`
355
356 - `:"gpt-audio-mini-2025-10-06"`
357
358 - `:"gpt-audio-mini-2025-12-15"`
359
360- `output_modalities: Array[:text | :audio]`
361
362 The set of modalities the model can respond with. It defaults to `["audio"]`, indicating
363 that the model will respond with audio plus a transcript. `["text"]` can be used to make
364 the model respond with text only. It is not possible to request both `text` and `audio` at the same time.
365
366 - `:text`
367
368 - `:audio`
369
370- `parallel_tool_calls: bool`
371
372 Whether the model may call multiple tools in parallel. Only supported by
373 reasoning Realtime models such as `gpt-realtime-2`.
374
375- `prompt: ResponsePrompt`
376
377 Reference to a prompt template and its variables.
378 [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
379
380 - `id: String`
381
382 The unique identifier of the prompt template to use.
383
384 - `variables: Hash[Symbol, String | ResponseInputText | ResponseInputImage | ResponseInputFile]`
385
386 Optional map of values to substitute in for variables in your
387 prompt. The substitution values can either be strings, or other
388 Response input types like images or files.
389
390 - `String = String`
391
392 - `class ResponseInputText`
393
394 A text input to the model.
395
396 - `text: String`
397
398 The text input to the model.
399
400 - `type: :input_text`
401
402 The type of the input item. Always `input_text`.
403
404 - `:input_text`
405
406 - `class ResponseInputImage`
407
408 An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
409
410 - `detail: :low | :high | :auto | :original`
411
412 The detail level of the image to be sent to the model. One of `high`, `low`, `auto`, or `original`. Defaults to `auto`.
413
414 - `:low`
415
416 - `:high`
417
418 - `:auto`
419
420 - `:original`
421
422 - `type: :input_image`
423
424 The type of the input item. Always `input_image`.
425
426 - `:input_image`
427
428 - `file_id: String`
429
430 The ID of the file to be sent to the model.
431
432 - `image_url: String`
433
434 The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image in a data URL.
435
436 - `class ResponseInputFile`
437
438 A file input to the model.
439
440 - `type: :input_file`
441
442 The type of the input item. Always `input_file`.
443
444 - `:input_file`
445
446 - `detail: :low | :high`
447
448 The detail level of the file to be sent to the model. Use `low` for the default rendering behavior, or `high` to render the file at higher quality. Defaults to `low`.
449
450 - `:low`
451
452 - `:high`
453
454 - `file_data: String`
455
456 The content of the file to be sent to the model.
457
458 - `file_id: String`
459
460 The ID of the file to be sent to the model.
461
462 - `file_url: String`
463
464 The URL of the file to be sent to the model.
465
466 - `filename: String`
467
468 The name of the file to be sent to the model.
469
470 - `version: String`
471
472 Optional version of the prompt template.
473
474- `reasoning: RealtimeReasoning`
475
476 Configuration for reasoning-capable Realtime models such as `gpt-realtime-2`.
477
478 - `effort: RealtimeReasoningEffort`
479
480 Constrains effort on reasoning for reasoning-capable Realtime models such as
481 `gpt-realtime-2`.
482
483 - `:minimal`
484
485 - `:low`
486
487 - `:medium`
488
489 - `:high`
490
491 - `:xhigh`
492
493- `tool_choice: RealtimeToolChoiceConfig`
494
495 How the model chooses tools. Provide one of the string modes or force a specific
496 function/MCP tool.
497
498 - `ToolChoiceOptions = :none | :auto | :required`
499
500 Controls which (if any) tool is called by the model.
501
502 `none` means the model will not call any tool and instead generates a message.
503
504 `auto` means the model can pick between generating a message or calling one or
505 more tools.
506
507 `required` means the model must call one or more tools.
508
509 - `:none`
510
511 - `:auto`
512
513 - `:required`
514
515 - `class ToolChoiceFunction`
516
517 Use this option to force the model to call a specific function.
518
519 - `name: String`
520
521 The name of the function to call.
522
523 - `type: :function`
524
525 For function calling, the type is always `function`.
526
527 - `:function`
528
529 - `class ToolChoiceMcp`
530
531 Use this option to force the model to call a specific tool on a remote MCP server.
532
533 - `server_label: String`
534
535 The label of the MCP server to use.
536
537 - `type: :mcp`
538
539 For MCP tools, the type is always `mcp`.
540
541 - `:mcp`
542
543 - `name: String`
544
545 The name of the tool to call on the server.
546
547- `tools: RealtimeToolsConfig`
548
549 Tools available to the model.
550
551 - `class RealtimeFunctionTool`
552
553 - `description: String`
554
555 The description of the function, including guidance on when and how
556 to call it, and guidance about what to tell the user when calling
557 (if anything).
558
559 - `name: String`
560
561 The name of the function.
562
563 - `parameters: untyped`
564
565 Parameters of the function in JSON Schema.
566
567 - `type: :function`
568
569 The type of the tool, i.e. `function`.
570
571 - `:function`
572
573 - `class Mcp`
574
575 Give the model access to additional tools via remote Model Context Protocol
576 (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
577
578 - `server_label: String`
579
580 A label for this MCP server, used to identify it in tool calls.
581
582 - `type: :mcp`
583
584 The type of the MCP tool. Always `mcp`.
585
586 - `:mcp`
587
588 - `allowed_tools: Array[String] | McpToolFilter{ read_only, tool_names}`
589
590 List of allowed tool names or a filter object.
591
592 - `McpAllowedTools = Array[String]`
593
594 A string array of allowed tool names
595
596 - `class McpToolFilter`
597
598 A filter object to specify which tools are allowed.
599
600 - `read_only: bool`
601
602 Indicates whether or not a tool modifies data or is read-only. If an
603 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
604 it will match this filter.
605
606 - `tool_names: Array[String]`
607
608 List of allowed tool names.
609
610 - `authorization: String`
611
612 An OAuth access token that can be used with a remote MCP server, either
613 with a custom MCP server URL or a service connector. Your application
614 must handle the OAuth authorization flow and provide the token here.
615
616 - `connector_id: :connector_dropbox | :connector_gmail | :connector_googlecalendar | 5 more`
617
618 Identifier for service connectors, like those available in ChatGPT. One of
619 `server_url` or `connector_id` must be provided. Learn more about service
620 connectors [here](https://platform.openai.com/docs/guides/tools-remote-mcp#connectors).
621
622 Currently supported `connector_id` values are:
623
624 - Dropbox: `connector_dropbox`
625 - Gmail: `connector_gmail`
626 - Google Calendar: `connector_googlecalendar`
627 - Google Drive: `connector_googledrive`
628 - Microsoft Teams: `connector_microsoftteams`
629 - Outlook Calendar: `connector_outlookcalendar`
630 - Outlook Email: `connector_outlookemail`
631 - SharePoint: `connector_sharepoint`
632
633 - `:connector_dropbox`
634
635 - `:connector_gmail`
636
637 - `:connector_googlecalendar`
638
639 - `:connector_googledrive`
640
641 - `:connector_microsoftteams`
642
643 - `:connector_outlookcalendar`
644
645 - `:connector_outlookemail`
646
647 - `:connector_sharepoint`
648
649 - `defer_loading: bool`
650
651 Whether this MCP tool is deferred and discovered via tool search.
652
653 - `headers: Hash[Symbol, String]`
654
655 Optional HTTP headers to send to the MCP server. Use for authentication
656 or other purposes.
657
658 - `require_approval: McpToolApprovalFilter{ always, never} | :always | :never`
659
660 Specify which of the MCP server's tools require approval.
661
662 - `class McpToolApprovalFilter`
663
664 Specify which of the MCP server's tools require approval. Can be
665 `always`, `never`, or a filter object associated with tools
666 that require approval.
667
668 - `always: Always{ read_only, tool_names}`
669
670 A filter object to specify which tools are allowed.
671
672 - `read_only: bool`
673
674 Indicates whether or not a tool modifies data or is read-only. If an
675 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
676 it will match this filter.
677
678 - `tool_names: Array[String]`
679
680 List of allowed tool names.
681
682 - `never: Never{ read_only, tool_names}`
683
684 A filter object to specify which tools are allowed.
685
686 - `read_only: bool`
687
688 Indicates whether or not a tool modifies data or is read-only. If an
689 MCP server is [annotated with `readOnlyHint`](https://modelcontextprotocol.io/specification/2025-06-18/schema#toolannotations-readonlyhint),
690 it will match this filter.
691
692 - `tool_names: Array[String]`
693
694 List of allowed tool names.
695
696 - `McpToolApprovalSetting = :always | :never`
697
698 Specify a single approval policy for all tools. One of `always` or
699 `never`. When set to `always`, all tools will require approval. When
700 set to `never`, all tools will not require approval.
701
702 - `:always`
703
704 - `:never`
705
706 - `server_description: String`
707
708 Optional description of the MCP server, used to provide more context.
709
710 - `server_url: String`
711
712 The URL for the MCP server. One of `server_url` or `connector_id` must be
713 provided.
714
715- `tracing: RealtimeTracingConfig`
716
717 Realtime API can write session traces to the [Traces Dashboard](https://platform.openai.com/logs?api=traces). Set to null to disable tracing. Once
718 tracing is enabled for a session, the configuration cannot be modified.
719
720 `auto` will create a trace for the session with default values for the
721 workflow name, group id, and metadata.
722
723 - `RealtimeTracingConfig = :auto`
724
725 Enables tracing and sets default values for tracing configuration options. Always `auto`.
726
727 - `:auto`
728
729 - `class TracingConfiguration`
730
731 Granular configuration for tracing.
732
733 - `group_id: String`
734
735 The group id to attach to this trace to enable filtering and
736 grouping in the Traces Dashboard.
737
738 - `metadata: untyped`
739
740 The arbitrary metadata to attach to this trace to enable
741 filtering in the Traces Dashboard.
742
743 - `workflow_name: String`
744
745 The name of the workflow to attach to this trace. This is used to
746 name the trace in the Traces Dashboard.
747
748- `truncation: RealtimeTruncation`
749
750 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.
751
752 Clients can configure truncation behavior to truncate with a lower max token limit, which is an effective way to control token usage and cost.
753
754 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.
755
756 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.
757
758 - `RealtimeTruncationStrategy = :auto | :disabled`
759
760 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.
761
762 - `:auto`
763
764 - `:disabled`
765
766 - `class RealtimeTruncationRetentionRatio`
767
768 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.
769
770 - `retention_ratio: Float`
771
772 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.
773
774 - `type: :retention_ratio`
775
776 Use retention ratio truncation.
777
778 - `:retention_ratio`
779
780 - `token_limits: TokenLimits{ post_instructions}`
781
782 Optional custom token limits for this truncation strategy. If not provided, the model's default token limits will be used.
783
784 - `post_instructions: Integer`
785
786 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.
787
788### Example
789
790```ruby
791require "openai"
792
793openai = OpenAI::Client.new(api_key: "My API Key")
794
795result = openai.realtime.calls.accept("call_id", type: :realtime)
796
797puts(result)
798```
799
800## Hang up call
801
802`realtime.calls.hangup(call_id) -> void`
803
804**post** `/realtime/calls/{call_id}/hangup`
805
806End an active Realtime API call, whether it was initiated over SIP or
807WebRTC.
808
809### Parameters
810
811- `call_id: String`
812
813### Example
814
815```ruby
816require "openai"
817
818openai = OpenAI::Client.new(api_key: "My API Key")
819
820result = openai.realtime.calls.hangup("call_id")
821
822puts(result)
823```
824
825## Refer call
826
827`realtime.calls.refer(call_id, **kwargs) -> void`
828
829**post** `/realtime/calls/{call_id}/refer`
830
831Transfer an active SIP call to a new destination using the SIP REFER verb.
832
833### Parameters
834
835- `call_id: String`
836
837- `target_uri: String`
838
839 URI that should appear in the SIP Refer-To header. Supports values like
840 `tel:+14155550123` or `sip:agent@example.com`.
841
842### Example
843
844```ruby
845require "openai"
846
847openai = OpenAI::Client.new(api_key: "My API Key")
848
849result = openai.realtime.calls.refer("call_id", target_uri: "tel:+14155550123")
850
851puts(result)
852```
853
854## Reject call
855
856`realtime.calls.reject(call_id, **kwargs) -> void`
857
858**post** `/realtime/calls/{call_id}/reject`
859
860Decline an incoming SIP call by returning a SIP status code to the caller.
861
862### Parameters
863
864- `call_id: String`
865
866- `status_code: Integer`
867
868 SIP response code to send back to the caller. Defaults to `603` (Decline)
869 when omitted.
870
871### Example
872
873```ruby
874require "openai"
875
876openai = OpenAI::Client.new(api_key: "My API Key")
877
878result = openai.realtime.calls.reject("call_id")
879
880puts(result)
881```