openai 0.22.1 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +1 -1
  4. data/lib/openai/models/realtime/audio_transcription.rb +60 -0
  5. data/lib/openai/models/realtime/client_secret_create_params.rb +18 -9
  6. data/lib/openai/models/realtime/client_secret_create_response.rb +11 -250
  7. data/lib/openai/models/realtime/conversation_item.rb +1 -1
  8. data/lib/openai/models/realtime/conversation_item_added.rb +14 -1
  9. data/lib/openai/models/realtime/conversation_item_done.rb +3 -0
  10. data/lib/openai/models/realtime/conversation_item_input_audio_transcription_completed_event.rb +10 -8
  11. data/lib/openai/models/realtime/conversation_item_input_audio_transcription_delta_event.rb +14 -5
  12. data/lib/openai/models/realtime/conversation_item_truncate_event.rb +2 -2
  13. data/lib/openai/models/realtime/input_audio_buffer_append_event.rb +10 -5
  14. data/lib/openai/models/realtime/models.rb +58 -0
  15. data/lib/openai/models/realtime/noise_reduction_type.rb +20 -0
  16. data/lib/openai/models/realtime/realtime_audio_config.rb +6 -427
  17. data/lib/openai/models/realtime/realtime_audio_config_input.rb +89 -0
  18. data/lib/openai/models/realtime/realtime_audio_config_output.rb +100 -0
  19. data/lib/openai/models/realtime/realtime_audio_formats.rb +121 -0
  20. data/lib/openai/models/realtime/realtime_audio_input_turn_detection.rb +131 -0
  21. data/lib/openai/models/realtime/realtime_client_event.rb +31 -23
  22. data/lib/openai/models/realtime/realtime_conversation_item_assistant_message.rb +43 -10
  23. data/lib/openai/models/realtime/realtime_conversation_item_function_call.rb +16 -7
  24. data/lib/openai/models/realtime/realtime_conversation_item_function_call_output.rb +15 -7
  25. data/lib/openai/models/realtime/realtime_conversation_item_system_message.rb +18 -6
  26. data/lib/openai/models/realtime/realtime_conversation_item_user_message.rb +62 -13
  27. data/lib/openai/models/realtime/realtime_response.rb +117 -107
  28. data/lib/openai/models/realtime/realtime_response_create_audio_output.rb +100 -0
  29. data/lib/openai/models/realtime/realtime_response_create_mcp_tool.rb +310 -0
  30. data/lib/openai/models/realtime/realtime_response_create_params.rb +225 -0
  31. data/lib/openai/models/realtime/realtime_response_status.rb +1 -1
  32. data/lib/openai/models/realtime/realtime_response_usage.rb +5 -2
  33. data/lib/openai/models/realtime/realtime_response_usage_input_token_details.rb +58 -8
  34. data/lib/openai/models/realtime/realtime_server_event.rb +21 -5
  35. data/lib/openai/models/realtime/realtime_session.rb +9 -125
  36. data/lib/openai/models/realtime/realtime_session_client_secret.rb +36 -0
  37. data/lib/openai/models/realtime/realtime_session_create_request.rb +50 -71
  38. data/lib/openai/models/realtime/realtime_session_create_response.rb +621 -219
  39. data/lib/openai/models/realtime/realtime_tools_config_union.rb +2 -53
  40. data/lib/openai/models/realtime/realtime_tracing_config.rb +7 -6
  41. data/lib/openai/models/realtime/realtime_transcription_session_audio.rb +19 -0
  42. data/lib/openai/models/realtime/realtime_transcription_session_audio_input.rb +90 -0
  43. data/lib/openai/models/realtime/realtime_transcription_session_audio_input_turn_detection.rb +131 -0
  44. data/lib/openai/models/realtime/realtime_transcription_session_client_secret.rb +38 -0
  45. data/lib/openai/models/realtime/realtime_transcription_session_create_request.rb +12 -270
  46. data/lib/openai/models/realtime/realtime_transcription_session_create_response.rb +78 -0
  47. data/lib/openai/models/realtime/realtime_transcription_session_input_audio_transcription.rb +66 -0
  48. data/lib/openai/models/realtime/realtime_transcription_session_turn_detection.rb +57 -0
  49. data/lib/openai/models/realtime/realtime_truncation.rb +8 -40
  50. data/lib/openai/models/realtime/realtime_truncation_retention_ratio.rb +34 -0
  51. data/lib/openai/models/realtime/response_cancel_event.rb +3 -1
  52. data/lib/openai/models/realtime/response_create_event.rb +18 -348
  53. data/lib/openai/models/realtime/response_done_event.rb +7 -0
  54. data/lib/openai/models/realtime/session_created_event.rb +20 -4
  55. data/lib/openai/models/realtime/session_update_event.rb +36 -12
  56. data/lib/openai/models/realtime/session_updated_event.rb +20 -4
  57. data/lib/openai/models/realtime/transcription_session_created.rb +8 -243
  58. data/lib/openai/models/realtime/transcription_session_update.rb +179 -3
  59. data/lib/openai/models/realtime/transcription_session_updated_event.rb +8 -243
  60. data/lib/openai/resources/realtime/client_secrets.rb +2 -3
  61. data/lib/openai/version.rb +1 -1
  62. data/lib/openai.rb +19 -1
  63. data/rbi/openai/models/realtime/audio_transcription.rbi +132 -0
  64. data/rbi/openai/models/realtime/client_secret_create_params.rbi +25 -11
  65. data/rbi/openai/models/realtime/client_secret_create_response.rbi +2 -587
  66. data/rbi/openai/models/realtime/conversation_item_added.rbi +14 -1
  67. data/rbi/openai/models/realtime/conversation_item_done.rbi +3 -0
  68. data/rbi/openai/models/realtime/conversation_item_input_audio_transcription_completed_event.rbi +11 -8
  69. data/rbi/openai/models/realtime/conversation_item_input_audio_transcription_delta_event.rbi +15 -5
  70. data/rbi/openai/models/realtime/conversation_item_truncate_event.rbi +2 -2
  71. data/rbi/openai/models/realtime/input_audio_buffer_append_event.rbi +10 -5
  72. data/rbi/openai/models/realtime/models.rbi +97 -0
  73. data/rbi/openai/models/realtime/noise_reduction_type.rbi +31 -0
  74. data/rbi/openai/models/realtime/realtime_audio_config.rbi +8 -956
  75. data/rbi/openai/models/realtime/realtime_audio_config_input.rbi +221 -0
  76. data/rbi/openai/models/realtime/realtime_audio_config_output.rbi +222 -0
  77. data/rbi/openai/models/realtime/realtime_audio_formats.rbi +329 -0
  78. data/rbi/openai/models/realtime/realtime_audio_input_turn_detection.rbi +262 -0
  79. data/rbi/openai/models/realtime/realtime_conversation_item_assistant_message.rbi +51 -10
  80. data/rbi/openai/models/realtime/realtime_conversation_item_function_call.rbi +16 -7
  81. data/rbi/openai/models/realtime/realtime_conversation_item_function_call_output.rbi +14 -7
  82. data/rbi/openai/models/realtime/realtime_conversation_item_system_message.rbi +16 -6
  83. data/rbi/openai/models/realtime/realtime_conversation_item_user_message.rbi +110 -12
  84. data/rbi/openai/models/realtime/realtime_response.rbi +287 -212
  85. data/rbi/openai/models/realtime/realtime_response_create_audio_output.rbi +250 -0
  86. data/rbi/openai/models/realtime/realtime_response_create_mcp_tool.rbi +616 -0
  87. data/rbi/openai/models/realtime/realtime_response_create_params.rbi +529 -0
  88. data/rbi/openai/models/realtime/realtime_response_usage.rbi +8 -2
  89. data/rbi/openai/models/realtime/realtime_response_usage_input_token_details.rbi +106 -7
  90. data/rbi/openai/models/realtime/realtime_server_event.rbi +4 -1
  91. data/rbi/openai/models/realtime/realtime_session.rbi +12 -262
  92. data/rbi/openai/models/realtime/realtime_session_client_secret.rbi +49 -0
  93. data/rbi/openai/models/realtime/realtime_session_create_request.rbi +112 -133
  94. data/rbi/openai/models/realtime/realtime_session_create_response.rbi +1229 -405
  95. data/rbi/openai/models/realtime/realtime_tools_config_union.rbi +1 -117
  96. data/rbi/openai/models/realtime/realtime_tracing_config.rbi +11 -10
  97. data/rbi/openai/models/realtime/realtime_transcription_session_audio.rbi +50 -0
  98. data/rbi/openai/models/realtime/realtime_transcription_session_audio_input.rbi +226 -0
  99. data/rbi/openai/models/realtime/realtime_transcription_session_audio_input_turn_detection.rbi +259 -0
  100. data/rbi/openai/models/realtime/realtime_transcription_session_client_secret.rbi +51 -0
  101. data/rbi/openai/models/realtime/realtime_transcription_session_create_request.rbi +25 -597
  102. data/rbi/openai/models/realtime/realtime_transcription_session_create_response.rbi +195 -0
  103. data/rbi/openai/models/realtime/realtime_transcription_session_input_audio_transcription.rbi +144 -0
  104. data/rbi/openai/models/realtime/realtime_transcription_session_turn_detection.rbi +94 -0
  105. data/rbi/openai/models/realtime/realtime_truncation.rbi +5 -56
  106. data/rbi/openai/models/realtime/realtime_truncation_retention_ratio.rbi +45 -0
  107. data/rbi/openai/models/realtime/response_cancel_event.rbi +3 -1
  108. data/rbi/openai/models/realtime/response_create_event.rbi +19 -786
  109. data/rbi/openai/models/realtime/response_done_event.rbi +7 -0
  110. data/rbi/openai/models/realtime/session_created_event.rbi +42 -9
  111. data/rbi/openai/models/realtime/session_update_event.rbi +57 -19
  112. data/rbi/openai/models/realtime/session_updated_event.rbi +42 -9
  113. data/rbi/openai/models/realtime/transcription_session_created.rbi +17 -591
  114. data/rbi/openai/models/realtime/transcription_session_update.rbi +425 -7
  115. data/rbi/openai/models/realtime/transcription_session_updated_event.rbi +14 -591
  116. data/rbi/openai/resources/realtime/client_secrets.rbi +5 -3
  117. data/sig/openai/models/realtime/audio_transcription.rbs +57 -0
  118. data/sig/openai/models/realtime/client_secret_create_response.rbs +1 -251
  119. data/sig/openai/models/realtime/models.rbs +57 -0
  120. data/sig/openai/models/realtime/noise_reduction_type.rbs +16 -0
  121. data/sig/openai/models/realtime/realtime_audio_config.rbs +12 -331
  122. data/sig/openai/models/realtime/realtime_audio_config_input.rbs +72 -0
  123. data/sig/openai/models/realtime/realtime_audio_config_output.rbs +72 -0
  124. data/sig/openai/models/realtime/realtime_audio_formats.rbs +128 -0
  125. data/sig/openai/models/realtime/realtime_audio_input_turn_detection.rbs +99 -0
  126. data/sig/openai/models/realtime/realtime_conversation_item_assistant_message.rbs +17 -2
  127. data/sig/openai/models/realtime/realtime_conversation_item_user_message.rbs +30 -1
  128. data/sig/openai/models/realtime/realtime_response.rbs +103 -82
  129. data/sig/openai/models/realtime/realtime_response_create_audio_output.rbs +84 -0
  130. data/sig/openai/models/realtime/realtime_response_create_mcp_tool.rbs +218 -0
  131. data/sig/openai/models/realtime/realtime_response_create_params.rbs +148 -0
  132. data/sig/openai/models/realtime/realtime_response_usage_input_token_details.rbs +50 -1
  133. data/sig/openai/models/realtime/realtime_session.rbs +16 -106
  134. data/sig/openai/models/realtime/realtime_session_client_secret.rbs +20 -0
  135. data/sig/openai/models/realtime/realtime_session_create_request.rbs +27 -43
  136. data/sig/openai/models/realtime/realtime_session_create_response.rbs +389 -187
  137. data/sig/openai/models/realtime/realtime_tools_config_union.rbs +1 -53
  138. data/sig/openai/models/realtime/realtime_transcription_session_audio.rbs +24 -0
  139. data/sig/openai/models/realtime/realtime_transcription_session_audio_input.rbs +72 -0
  140. data/sig/openai/models/realtime/realtime_transcription_session_audio_input_turn_detection.rbs +99 -0
  141. data/sig/openai/models/realtime/realtime_transcription_session_client_secret.rbs +20 -0
  142. data/sig/openai/models/realtime/realtime_transcription_session_create_request.rbs +11 -203
  143. data/sig/openai/models/realtime/realtime_transcription_session_create_response.rbs +69 -0
  144. data/sig/openai/models/realtime/realtime_transcription_session_input_audio_transcription.rbs +59 -0
  145. data/sig/openai/models/realtime/realtime_transcription_session_turn_detection.rbs +47 -0
  146. data/sig/openai/models/realtime/realtime_truncation.rbs +1 -28
  147. data/sig/openai/models/realtime/realtime_truncation_retention_ratio.rbs +21 -0
  148. data/sig/openai/models/realtime/response_create_event.rbs +6 -249
  149. data/sig/openai/models/realtime/session_created_event.rbs +14 -4
  150. data/sig/openai/models/realtime/session_update_event.rbs +14 -4
  151. data/sig/openai/models/realtime/session_updated_event.rbs +14 -4
  152. data/sig/openai/models/realtime/transcription_session_created.rbs +4 -254
  153. data/sig/openai/models/realtime/transcription_session_update.rbs +154 -4
  154. data/sig/openai/models/realtime/transcription_session_updated_event.rbs +4 -254
  155. metadata +59 -5
  156. data/lib/openai/models/realtime/realtime_client_secret_config.rb +0 -64
  157. data/rbi/openai/models/realtime/realtime_client_secret_config.rbi +0 -147
  158. data/sig/openai/models/realtime/realtime_client_secret_config.rbs +0 -60
@@ -19,8 +19,8 @@ module OpenAI
19
19
  # @!attribute response
20
20
  # Create a new Realtime response with these parameters
21
21
  #
22
- # @return [OpenAI::Models::Realtime::ResponseCreateEvent::Response, nil]
23
- optional :response, -> { OpenAI::Realtime::ResponseCreateEvent::Response }
22
+ # @return [OpenAI::Models::Realtime::RealtimeResponseCreateParams, nil]
23
+ optional :response, -> { OpenAI::Realtime::RealtimeResponseCreateParams }
24
24
 
25
25
  # @!method initialize(event_id: nil, response: nil, type: :"response.create")
26
26
  # This event instructs the server to create a Response, which means triggering
@@ -29,362 +29,32 @@ module OpenAI
29
29
  #
30
30
  # A Response will include at least one Item, and may have two, in which case the
31
31
  # second will be a function call. These Items will be appended to the conversation
32
- # history.
32
+ # history by default.
33
33
  #
34
34
  # The server will respond with a `response.created` event, events for Items and
35
35
  # content created, and finally a `response.done` event to indicate the Response is
36
36
  # complete.
37
37
  #
38
- # The `response.create` event includes inference configuration like
39
- # `instructions`, and `temperature`. These fields will override the Session's
40
- # configuration for this Response only.
38
+ # The `response.create` event includes inference configuration like `instructions`
39
+ # and `tools`. If these are set, they will override the Session's configuration
40
+ # for this Response only.
41
+ #
42
+ # Responses can be created out-of-band of the default Conversation, meaning that
43
+ # they can have arbitrary input, and it's possible to disable writing the output
44
+ # to the Conversation. Only one Response can write to the default Conversation at
45
+ # a time, but otherwise multiple Responses can be created in parallel. The
46
+ # `metadata` field is a good way to disambiguate multiple simultaneous Responses.
47
+ #
48
+ # Clients can set `conversation` to `none` to create a Response that does not
49
+ # write to the default Conversation. Arbitrary input can be provided with the
50
+ # `input` field, which is an array accepting raw Items and references to existing
51
+ # Items.
41
52
  #
42
53
  # @param event_id [String] Optional client-generated ID used to identify this event.
43
54
  #
44
- # @param response [OpenAI::Models::Realtime::ResponseCreateEvent::Response] Create a new Realtime response with these parameters
55
+ # @param response [OpenAI::Models::Realtime::RealtimeResponseCreateParams] Create a new Realtime response with these parameters
45
56
  #
46
57
  # @param type [Symbol, :"response.create"] The event type, must be `response.create`.
47
-
48
- # @see OpenAI::Models::Realtime::ResponseCreateEvent#response
49
- class Response < OpenAI::Internal::Type::BaseModel
50
- # @!attribute conversation
51
- # Controls which conversation the response is added to. Currently supports `auto`
52
- # and `none`, with `auto` as the default value. The `auto` value means that the
53
- # contents of the response will be added to the default conversation. Set this to
54
- # `none` to create an out-of-band response which will not add items to default
55
- # conversation.
56
- #
57
- # @return [String, Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::Conversation, nil]
58
- optional :conversation, union: -> { OpenAI::Realtime::ResponseCreateEvent::Response::Conversation }
59
-
60
- # @!attribute input
61
- # Input items to include in the prompt for the model. Using this field creates a
62
- # new context for this Response instead of using the default conversation. An
63
- # empty array `[]` will clear the context for this Response. Note that this can
64
- # include references to items from the default conversation.
65
- #
66
- # @return [Array<OpenAI::Models::Realtime::RealtimeConversationItemSystemMessage, OpenAI::Models::Realtime::RealtimeConversationItemUserMessage, OpenAI::Models::Realtime::RealtimeConversationItemAssistantMessage, OpenAI::Models::Realtime::RealtimeConversationItemFunctionCall, OpenAI::Models::Realtime::RealtimeConversationItemFunctionCallOutput, OpenAI::Models::Realtime::RealtimeMcpApprovalResponse, OpenAI::Models::Realtime::RealtimeMcpListTools, OpenAI::Models::Realtime::RealtimeMcpToolCall, OpenAI::Models::Realtime::RealtimeMcpApprovalRequest>, nil]
67
- optional :input, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Realtime::ConversationItem] }
68
-
69
- # @!attribute instructions
70
- # The default system instructions (i.e. system message) prepended to model calls.
71
- # This field allows the client to guide the model on desired responses. The model
72
- # can be instructed on response content and format, (e.g. "be extremely succinct",
73
- # "act friendly", "here are examples of good responses") and on audio behavior
74
- # (e.g. "talk quickly", "inject emotion into your voice", "laugh frequently"). The
75
- # instructions are not guaranteed to be followed by the model, but they provide
76
- # guidance to the model on the desired behavior.
77
- #
78
- # Note that the server sets default instructions which will be used if this field
79
- # is not set and are visible in the `session.created` event at the start of the
80
- # session.
81
- #
82
- # @return [String, nil]
83
- optional :instructions, String
84
-
85
- # @!attribute max_output_tokens
86
- # Maximum number of output tokens for a single assistant response, inclusive of
87
- # tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
88
- # `inf` for the maximum available tokens for a given model. Defaults to `inf`.
89
- #
90
- # @return [Integer, Symbol, :inf, nil]
91
- optional :max_output_tokens,
92
- union: -> { OpenAI::Realtime::ResponseCreateEvent::Response::MaxOutputTokens }
93
-
94
- # @!attribute metadata
95
- # Set of 16 key-value pairs that can be attached to an object. This can be useful
96
- # for storing additional information about the object in a structured format, and
97
- # querying for objects via API or the dashboard.
98
- #
99
- # Keys are strings with a maximum length of 64 characters. Values are strings with
100
- # a maximum length of 512 characters.
101
- #
102
- # @return [Hash{Symbol=>String}, nil]
103
- optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
104
-
105
- # @!attribute modalities
106
- # The set of modalities the model can respond with. To disable audio, set this to
107
- # ["text"].
108
- #
109
- # @return [Array<Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::Modality>, nil]
110
- optional :modalities,
111
- -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Realtime::ResponseCreateEvent::Response::Modality] }
112
-
113
- # @!attribute output_audio_format
114
- # The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
115
- #
116
- # @return [Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::OutputAudioFormat, nil]
117
- optional :output_audio_format,
118
- enum: -> { OpenAI::Realtime::ResponseCreateEvent::Response::OutputAudioFormat }
119
-
120
- # @!attribute prompt
121
- # Reference to a prompt template and its variables.
122
- # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
123
- #
124
- # @return [OpenAI::Models::Responses::ResponsePrompt, nil]
125
- optional :prompt, -> { OpenAI::Responses::ResponsePrompt }, nil?: true
126
-
127
- # @!attribute temperature
128
- # Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
129
- #
130
- # @return [Float, nil]
131
- optional :temperature, Float
132
-
133
- # @!attribute tool_choice
134
- # How the model chooses tools. Provide one of the string modes or force a specific
135
- # function/MCP tool.
136
- #
137
- # @return [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp, nil]
138
- optional :tool_choice, union: -> { OpenAI::Realtime::ResponseCreateEvent::Response::ToolChoice }
139
-
140
- # @!attribute tools
141
- # Tools (functions) available to the model.
142
- #
143
- # @return [Array<OpenAI::Models::Realtime::ResponseCreateEvent::Response::Tool>, nil]
144
- optional :tools,
145
- -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Realtime::ResponseCreateEvent::Response::Tool] }
146
-
147
- # @!attribute voice
148
- # The voice the model uses to respond. Voice cannot be changed during the session
149
- # once the model has responded with audio at least once. Current voice options are
150
- # `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
151
- #
152
- # @return [String, Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice, nil]
153
- optional :voice, union: -> { OpenAI::Realtime::ResponseCreateEvent::Response::Voice }
154
-
155
- # @!method initialize(conversation: nil, input: nil, instructions: nil, max_output_tokens: nil, metadata: nil, modalities: nil, output_audio_format: nil, prompt: nil, temperature: nil, tool_choice: nil, tools: nil, voice: nil)
156
- # Some parameter documentations has been truncated, see
157
- # {OpenAI::Models::Realtime::ResponseCreateEvent::Response} for more details.
158
- #
159
- # Create a new Realtime response with these parameters
160
- #
161
- # @param conversation [String, Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::Conversation] Controls which conversation the response is added to. Currently supports
162
- #
163
- # @param input [Array<OpenAI::Models::Realtime::RealtimeConversationItemSystemMessage, OpenAI::Models::Realtime::RealtimeConversationItemUserMessage, OpenAI::Models::Realtime::RealtimeConversationItemAssistantMessage, OpenAI::Models::Realtime::RealtimeConversationItemFunctionCall, OpenAI::Models::Realtime::RealtimeConversationItemFunctionCallOutput, OpenAI::Models::Realtime::RealtimeMcpApprovalResponse, OpenAI::Models::Realtime::RealtimeMcpListTools, OpenAI::Models::Realtime::RealtimeMcpToolCall, OpenAI::Models::Realtime::RealtimeMcpApprovalRequest>] Input items to include in the prompt for the model. Using this field
164
- #
165
- # @param instructions [String] The default system instructions (i.e. system message) prepended to model
166
- #
167
- # @param max_output_tokens [Integer, Symbol, :inf] Maximum number of output tokens for a single assistant response,
168
- #
169
- # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
170
- #
171
- # @param modalities [Array<Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::Modality>] The set of modalities the model can respond with. To disable audio,
172
- #
173
- # @param output_audio_format [Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::OutputAudioFormat] The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
174
- #
175
- # @param prompt [OpenAI::Models::Responses::ResponsePrompt, nil] Reference to a prompt template and its variables.
176
- #
177
- # @param temperature [Float] Sampling temperature for the model, limited to [0.6, 1.2]. Defaults to 0.8.
178
- #
179
- # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp] How the model chooses tools. Provide one of the string modes or force a specific
180
- #
181
- # @param tools [Array<OpenAI::Models::Realtime::ResponseCreateEvent::Response::Tool>] Tools (functions) available to the model.
182
- #
183
- # @param voice [String, Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice] The voice the model uses to respond. Voice cannot be changed during the
184
-
185
- # Controls which conversation the response is added to. Currently supports `auto`
186
- # and `none`, with `auto` as the default value. The `auto` value means that the
187
- # contents of the response will be added to the default conversation. Set this to
188
- # `none` to create an out-of-band response which will not add items to default
189
- # conversation.
190
- #
191
- # @see OpenAI::Models::Realtime::ResponseCreateEvent::Response#conversation
192
- module Conversation
193
- extend OpenAI::Internal::Type::Union
194
-
195
- variant String
196
-
197
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Conversation::AUTO }
198
-
199
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Conversation::NONE }
200
-
201
- # @!method self.variants
202
- # @return [Array(String, Symbol)]
203
-
204
- define_sorbet_constant!(:Variants) do
205
- T.type_alias { T.any(String, OpenAI::Realtime::ResponseCreateEvent::Response::Conversation::TaggedSymbol) }
206
- end
207
-
208
- # @!group
209
-
210
- AUTO = :auto
211
- NONE = :none
212
-
213
- # @!endgroup
214
- end
215
-
216
- # Maximum number of output tokens for a single assistant response, inclusive of
217
- # tool calls. Provide an integer between 1 and 4096 to limit output tokens, or
218
- # `inf` for the maximum available tokens for a given model. Defaults to `inf`.
219
- #
220
- # @see OpenAI::Models::Realtime::ResponseCreateEvent::Response#max_output_tokens
221
- module MaxOutputTokens
222
- extend OpenAI::Internal::Type::Union
223
-
224
- variant Integer
225
-
226
- variant const: :inf
227
-
228
- # @!method self.variants
229
- # @return [Array(Integer, Symbol, :inf)]
230
- end
231
-
232
- module Modality
233
- extend OpenAI::Internal::Type::Enum
234
-
235
- TEXT = :text
236
- AUDIO = :audio
237
-
238
- # @!method self.values
239
- # @return [Array<Symbol>]
240
- end
241
-
242
- # The format of output audio. Options are `pcm16`, `g711_ulaw`, or `g711_alaw`.
243
- #
244
- # @see OpenAI::Models::Realtime::ResponseCreateEvent::Response#output_audio_format
245
- module OutputAudioFormat
246
- extend OpenAI::Internal::Type::Enum
247
-
248
- PCM16 = :pcm16
249
- G711_ULAW = :g711_ulaw
250
- G711_ALAW = :g711_alaw
251
-
252
- # @!method self.values
253
- # @return [Array<Symbol>]
254
- end
255
-
256
- # How the model chooses tools. Provide one of the string modes or force a specific
257
- # function/MCP tool.
258
- #
259
- # @see OpenAI::Models::Realtime::ResponseCreateEvent::Response#tool_choice
260
- module ToolChoice
261
- extend OpenAI::Internal::Type::Union
262
-
263
- # Controls which (if any) tool is called by the model.
264
- #
265
- # `none` means the model will not call any tool and instead generates a message.
266
- #
267
- # `auto` means the model can pick between generating a message or calling one or
268
- # more tools.
269
- #
270
- # `required` means the model must call one or more tools.
271
- variant enum: -> { OpenAI::Responses::ToolChoiceOptions }
272
-
273
- # Use this option to force the model to call a specific function.
274
- variant -> { OpenAI::Responses::ToolChoiceFunction }
275
-
276
- # Use this option to force the model to call a specific tool on a remote MCP server.
277
- variant -> { OpenAI::Responses::ToolChoiceMcp }
278
-
279
- # @!method self.variants
280
- # @return [Array(Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp)]
281
- end
282
-
283
- class Tool < OpenAI::Internal::Type::BaseModel
284
- # @!attribute description
285
- # The description of the function, including guidance on when and how to call it,
286
- # and guidance about what to tell the user when calling (if anything).
287
- #
288
- # @return [String, nil]
289
- optional :description, String
290
-
291
- # @!attribute name
292
- # The name of the function.
293
- #
294
- # @return [String, nil]
295
- optional :name, String
296
-
297
- # @!attribute parameters
298
- # Parameters of the function in JSON Schema.
299
- #
300
- # @return [Object, nil]
301
- optional :parameters, OpenAI::Internal::Type::Unknown
302
-
303
- # @!attribute type
304
- # The type of the tool, i.e. `function`.
305
- #
306
- # @return [Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::Tool::Type, nil]
307
- optional :type, enum: -> { OpenAI::Realtime::ResponseCreateEvent::Response::Tool::Type }
308
-
309
- # @!method initialize(description: nil, name: nil, parameters: nil, type: nil)
310
- # Some parameter documentations has been truncated, see
311
- # {OpenAI::Models::Realtime::ResponseCreateEvent::Response::Tool} for more
312
- # details.
313
- #
314
- # @param description [String] The description of the function, including guidance on when and how
315
- #
316
- # @param name [String] The name of the function.
317
- #
318
- # @param parameters [Object] Parameters of the function in JSON Schema.
319
- #
320
- # @param type [Symbol, OpenAI::Models::Realtime::ResponseCreateEvent::Response::Tool::Type] The type of the tool, i.e. `function`.
321
-
322
- # The type of the tool, i.e. `function`.
323
- #
324
- # @see OpenAI::Models::Realtime::ResponseCreateEvent::Response::Tool#type
325
- module Type
326
- extend OpenAI::Internal::Type::Enum
327
-
328
- FUNCTION = :function
329
-
330
- # @!method self.values
331
- # @return [Array<Symbol>]
332
- end
333
- end
334
-
335
- # The voice the model uses to respond. Voice cannot be changed during the session
336
- # once the model has responded with audio at least once. Current voice options are
337
- # `alloy`, `ash`, `ballad`, `coral`, `echo`, `sage`, `shimmer`, and `verse`.
338
- #
339
- # @see OpenAI::Models::Realtime::ResponseCreateEvent::Response#voice
340
- module Voice
341
- extend OpenAI::Internal::Type::Union
342
-
343
- variant String
344
-
345
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::ALLOY }
346
-
347
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::ASH }
348
-
349
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::BALLAD }
350
-
351
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::CORAL }
352
-
353
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::ECHO }
354
-
355
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::SAGE }
356
-
357
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::SHIMMER }
358
-
359
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::VERSE }
360
-
361
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::MARIN }
362
-
363
- variant const: -> { OpenAI::Models::Realtime::ResponseCreateEvent::Response::Voice::CEDAR }
364
-
365
- # @!method self.variants
366
- # @return [Array(String, Symbol)]
367
-
368
- define_sorbet_constant!(:Variants) do
369
- T.type_alias { T.any(String, OpenAI::Realtime::ResponseCreateEvent::Response::Voice::TaggedSymbol) }
370
- end
371
-
372
- # @!group
373
-
374
- ALLOY = :alloy
375
- ASH = :ash
376
- BALLAD = :ballad
377
- CORAL = :coral
378
- ECHO = :echo
379
- SAGE = :sage
380
- SHIMMER = :shimmer
381
- VERSE = :verse
382
- MARIN = :marin
383
- CEDAR = :cedar
384
-
385
- # @!endgroup
386
- end
387
- end
388
58
  end
389
59
  end
390
60
  end
@@ -27,6 +27,13 @@ module OpenAI
27
27
  # state. The Response object included in the `response.done` event will include
28
28
  # all output Items in the Response but will omit the raw audio data.
29
29
  #
30
+ # Clients should check the `status` field of the Response to determine if it was
31
+ # successful (`completed`) or if there was another outcome: `cancelled`, `failed`,
32
+ # or `incomplete`.
33
+ #
34
+ # A response will contain all output items that were generated during the
35
+ # response, excluding any audio content.
36
+ #
30
37
  # @param event_id [String] The unique ID of the server event.
31
38
  #
32
39
  # @param response [OpenAI::Models::Realtime::RealtimeResponse] The response resource.
@@ -11,10 +11,10 @@ module OpenAI
11
11
  required :event_id, String
12
12
 
13
13
  # @!attribute session
14
- # Realtime session object.
14
+ # The session configuration.
15
15
  #
16
- # @return [OpenAI::Models::Realtime::RealtimeSession]
17
- required :session, -> { OpenAI::Realtime::RealtimeSession }
16
+ # @return [OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest]
17
+ required :session, union: -> { OpenAI::Realtime::SessionCreatedEvent::Session }
18
18
 
19
19
  # @!attribute type
20
20
  # The event type, must be `session.created`.
@@ -29,9 +29,25 @@ module OpenAI
29
29
  #
30
30
  # @param event_id [String] The unique ID of the server event.
31
31
  #
32
- # @param session [OpenAI::Models::Realtime::RealtimeSession] Realtime session object.
32
+ # @param session [OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest] The session configuration.
33
33
  #
34
34
  # @param type [Symbol, :"session.created"] The event type, must be `session.created`.
35
+
36
+ # The session configuration.
37
+ #
38
+ # @see OpenAI::Models::Realtime::SessionCreatedEvent#session
39
+ module Session
40
+ extend OpenAI::Internal::Type::Union
41
+
42
+ # Realtime session object configuration.
43
+ variant -> { OpenAI::Realtime::RealtimeSessionCreateRequest }
44
+
45
+ # Realtime transcription session object configuration.
46
+ variant -> { OpenAI::Realtime::RealtimeTranscriptionSessionCreateRequest }
47
+
48
+ # @!method self.variants
49
+ # @return [Array(OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest)]
50
+ end
35
51
  end
36
52
  end
37
53
  end
@@ -5,10 +5,11 @@ module OpenAI
5
5
  module Realtime
6
6
  class SessionUpdateEvent < OpenAI::Internal::Type::BaseModel
7
7
  # @!attribute session
8
- # Realtime session object configuration.
8
+ # Update the Realtime session. Choose either a realtime session or a transcription
9
+ # session.
9
10
  #
10
- # @return [OpenAI::Models::Realtime::RealtimeSessionCreateRequest]
11
- required :session, -> { OpenAI::Realtime::RealtimeSessionCreateRequest }
11
+ # @return [OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest]
12
+ required :session, union: -> { OpenAI::Realtime::SessionUpdateEvent::Session }
12
13
 
13
14
  # @!attribute type
14
15
  # The event type, must be `session.update`.
@@ -17,27 +18,50 @@ module OpenAI
17
18
  required :type, const: :"session.update"
18
19
 
19
20
  # @!attribute event_id
20
- # Optional client-generated ID used to identify this event.
21
+ # Optional client-generated ID used to identify this event. This is an arbitrary
22
+ # string that a client may assign. It will be passed back if there is an error
23
+ # with the event, but the corresponding `session.updated` event will not include
24
+ # it.
21
25
  #
22
26
  # @return [String, nil]
23
27
  optional :event_id, String
24
28
 
25
29
  # @!method initialize(session:, event_id: nil, type: :"session.update")
26
- # Send this event to update the session’s default configuration. The client may
27
- # send this event at any time to update any field, except for `voice`. However,
28
- # note that once a session has been initialized with a particular `model`, it
29
- # can’t be changed to another model using `session.update`.
30
+ # Some parameter documentations has been truncated, see
31
+ # {OpenAI::Models::Realtime::SessionUpdateEvent} for more details.
32
+ #
33
+ # Send this event to update the session’s configuration. The client may send this
34
+ # event at any time to update any field except for `voice` and `model`. `voice`
35
+ # can be updated only if there have been no other audio outputs yet.
30
36
  #
31
37
  # When the server receives a `session.update`, it will respond with a
32
38
  # `session.updated` event showing the full, effective configuration. Only the
33
- # fields that are present are updated. To clear a field like `instructions`, pass
34
- # an empty string.
39
+ # fields that are present in the `session.update` are updated. To clear a field
40
+ # like `instructions`, pass an empty string. To clear a field like `tools`, pass
41
+ # an empty array. To clear a field like `turn_detection`, pass `null`.
35
42
  #
36
- # @param session [OpenAI::Models::Realtime::RealtimeSessionCreateRequest] Realtime session object configuration.
43
+ # @param session [OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest] Update the Realtime session. Choose either a realtime
37
44
  #
38
- # @param event_id [String] Optional client-generated ID used to identify this event.
45
+ # @param event_id [String] Optional client-generated ID used to identify this event. This is an arbitrary s
39
46
  #
40
47
  # @param type [Symbol, :"session.update"] The event type, must be `session.update`.
48
+
49
+ # Update the Realtime session. Choose either a realtime session or a transcription
50
+ # session.
51
+ #
52
+ # @see OpenAI::Models::Realtime::SessionUpdateEvent#session
53
+ module Session
54
+ extend OpenAI::Internal::Type::Union
55
+
56
+ # Realtime session object configuration.
57
+ variant -> { OpenAI::Realtime::RealtimeSessionCreateRequest }
58
+
59
+ # Realtime transcription session object configuration.
60
+ variant -> { OpenAI::Realtime::RealtimeTranscriptionSessionCreateRequest }
61
+
62
+ # @!method self.variants
63
+ # @return [Array(OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest)]
64
+ end
41
65
  end
42
66
  end
43
67
  end
@@ -11,10 +11,10 @@ module OpenAI
11
11
  required :event_id, String
12
12
 
13
13
  # @!attribute session
14
- # Realtime session object.
14
+ # The session configuration.
15
15
  #
16
- # @return [OpenAI::Models::Realtime::RealtimeSession]
17
- required :session, -> { OpenAI::Realtime::RealtimeSession }
16
+ # @return [OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest]
17
+ required :session, union: -> { OpenAI::Realtime::SessionUpdatedEvent::Session }
18
18
 
19
19
  # @!attribute type
20
20
  # The event type, must be `session.updated`.
@@ -28,9 +28,25 @@ module OpenAI
28
28
  #
29
29
  # @param event_id [String] The unique ID of the server event.
30
30
  #
31
- # @param session [OpenAI::Models::Realtime::RealtimeSession] Realtime session object.
31
+ # @param session [OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest] The session configuration.
32
32
  #
33
33
  # @param type [Symbol, :"session.updated"] The event type, must be `session.updated`.
34
+
35
+ # The session configuration.
36
+ #
37
+ # @see OpenAI::Models::Realtime::SessionUpdatedEvent#session
38
+ module Session
39
+ extend OpenAI::Internal::Type::Union
40
+
41
+ # Realtime session object configuration.
42
+ variant -> { OpenAI::Realtime::RealtimeSessionCreateRequest }
43
+
44
+ # Realtime transcription session object configuration.
45
+ variant -> { OpenAI::Realtime::RealtimeTranscriptionSessionCreateRequest }
46
+
47
+ # @!method self.variants
48
+ # @return [Array(OpenAI::Models::Realtime::RealtimeSessionCreateRequest, OpenAI::Models::Realtime::RealtimeTranscriptionSessionCreateRequest)]
49
+ end
34
50
  end
35
51
  end
36
52
  end