Skip to main content

gproxy_protocol/wire/openai/realtime/
prompt.rs

1//! Native Realtime wire DTOs. Source definitions are cited on each object.
2//! Verified with Realtime.md and openai-python snapshot
3//! e12b81d3bbf644ec7045e152d69bc4b68d69cd48 (2026-09-13).
4//! https://github.com/openai/openai-python/tree/e12b81d3bbf644ec7045e152d69bc4b68d69cd48/src/openai/types/realtime
5use super::wire::present_nullable;
6use crate::Rest;
7use serde::{Deserialize, Serialize};
8
9/// Source: `openai/types/responses/response_prompt.py`, `ResponsePrompt`.
10#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
11#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
12#[derive(gproxy_protocol_macros::DeclaredFields)]
13#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
14pub struct ResponsePrompt {
15    pub id: String,
16    #[serde(
17        default,
18        deserialize_with = "present_nullable",
19        skip_serializing_if = "Option::is_none"
20    )]
21    pub variables: Option<Option<std::collections::BTreeMap<String, ResponsePromptVariables>>>,
22    #[serde(
23        default,
24        deserialize_with = "present_nullable",
25        skip_serializing_if = "Option::is_none"
26    )]
27    pub version: Option<Option<String>>,
28    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
29    pub rest: Rest,
30}
31
32/// Source: `openai/types/responses/response_prompt.py`, `Variables`.
33#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
34#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
35#[serde(untagged)]
36#[derive(gproxy_protocol_macros::DeclaredFields)]
37#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
38pub enum ResponsePromptVariables {
39    Text(String),
40    ResponseInputText(ResponseInputText),
41    ResponseInputImage(ResponseInputImage),
42    ResponseInputFile(ResponseInputFile),
43}
44
45/// Source: `openai/types/responses/tool_choice_options.py`, `ToolChoiceOptions`.
46#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
47#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
48#[derive(gproxy_protocol_macros::DeclaredFields)]
49#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
50pub enum ToolChoiceOptions {
51    #[serde(rename = "none")]
52    None,
53    #[serde(rename = "auto")]
54    Auto,
55    #[serde(rename = "required")]
56    Required,
57}
58
59/// Source: `openai/types/responses/tool_choice_function.py`, `ToolChoiceFunction`.
60#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
61#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
62#[derive(gproxy_protocol_macros::DeclaredFields)]
63#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
64pub struct ToolChoiceFunction {
65    pub name: String,
66    #[serde(rename = "type")]
67    pub type_: ToolChoiceFunctionType,
68    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
69    pub rest: Rest,
70}
71
72/// Source: `openai/types/responses/tool_choice_mcp.py`, `ToolChoiceMcp`.
73#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
74#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
75#[derive(gproxy_protocol_macros::DeclaredFields)]
76#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
77pub struct ToolChoiceMcp {
78    pub server_label: String,
79    #[serde(rename = "type")]
80    pub type_: ToolChoiceMcpType,
81    #[serde(
82        default,
83        deserialize_with = "present_nullable",
84        skip_serializing_if = "Option::is_none"
85    )]
86    pub name: Option<Option<String>>,
87    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
88    pub rest: Rest,
89}
90
91/// Source: `openai/types/shared/metadata.py`, `Metadata`.
92pub type Metadata = std::collections::BTreeMap<String, String>;
93
94/// Source: `openai/types/responses/response_input_text.py`, `ResponseInputText`.
95#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
96#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
97#[derive(gproxy_protocol_macros::DeclaredFields)]
98#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
99pub struct ResponseInputText {
100    pub text: String,
101    #[serde(rename = "type")]
102    pub type_: ResponseInputTextType,
103    #[serde(
104        default,
105        deserialize_with = "present_nullable",
106        skip_serializing_if = "Option::is_none"
107    )]
108    pub prompt_cache_breakpoint: Option<Option<ResponseInputTextPromptCacheBreakpoint>>,
109    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
110    pub rest: Rest,
111}
112
113/// Source: `openai/types/responses/response_input_image.py`, `ResponseInputImage`.
114#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
115#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
116#[derive(gproxy_protocol_macros::DeclaredFields)]
117#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
118pub struct ResponseInputImage {
119    pub detail: ImageDetail,
120    #[serde(rename = "type")]
121    pub type_: ResponseInputImageType,
122    #[serde(
123        default,
124        deserialize_with = "present_nullable",
125        skip_serializing_if = "Option::is_none"
126    )]
127    pub file_id: Option<Option<String>>,
128    #[serde(
129        default,
130        deserialize_with = "present_nullable",
131        skip_serializing_if = "Option::is_none"
132    )]
133    pub image_url: Option<Option<String>>,
134    #[serde(
135        default,
136        deserialize_with = "present_nullable",
137        skip_serializing_if = "Option::is_none"
138    )]
139    pub prompt_cache_breakpoint: Option<Option<ResponseInputImagePromptCacheBreakpoint>>,
140    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
141    pub rest: Rest,
142}
143
144/// Source: `openai/types/responses/response_input_file.py`, `ResponseInputFile`.
145#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
146#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
147#[derive(gproxy_protocol_macros::DeclaredFields)]
148#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
149pub struct ResponseInputFile {
150    #[serde(rename = "type")]
151    pub type_: ResponseInputFileType,
152    #[serde(
153        default,
154        deserialize_with = "present_nullable",
155        skip_serializing_if = "Option::is_none"
156    )]
157    pub detail: Option<Option<ResponseInputFileDetail>>,
158    #[serde(
159        default,
160        deserialize_with = "present_nullable",
161        skip_serializing_if = "Option::is_none"
162    )]
163    pub file_data: Option<Option<String>>,
164    #[serde(
165        default,
166        deserialize_with = "present_nullable",
167        skip_serializing_if = "Option::is_none"
168    )]
169    pub file_id: Option<Option<String>>,
170    #[serde(
171        default,
172        deserialize_with = "present_nullable",
173        skip_serializing_if = "Option::is_none"
174    )]
175    pub file_url: Option<Option<String>>,
176    #[serde(
177        default,
178        deserialize_with = "present_nullable",
179        skip_serializing_if = "Option::is_none"
180    )]
181    pub filename: Option<Option<String>>,
182    #[serde(
183        default,
184        deserialize_with = "present_nullable",
185        skip_serializing_if = "Option::is_none"
186    )]
187    pub prompt_cache_breakpoint: Option<Option<ResponseInputFilePromptCacheBreakpoint>>,
188    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
189    pub rest: Rest,
190}
191
192/// Source: `openai/types/responses/response_input_text.py`, `PromptCacheBreakpoint`.
193#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
194#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
195#[derive(gproxy_protocol_macros::DeclaredFields)]
196#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
197pub struct ResponseInputTextPromptCacheBreakpoint {
198    pub mode: ResponseInputTextPromptCacheBreakpointMode,
199    #[serde(default, skip_serializing_if = "Option::is_none")]
200    pub ttl: Option<PromptCacheBreakpointTtl>,
201    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
202    pub rest: Rest,
203}
204
205/// Source: `openai/types/responses/image_detail.py`, `ImageDetail`.
206#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
207#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
208#[derive(gproxy_protocol_macros::DeclaredFields)]
209#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
210pub enum ImageDetail {
211    #[serde(rename = "low")]
212    Low,
213    #[serde(rename = "high")]
214    High,
215    #[serde(rename = "auto")]
216    Auto,
217    #[serde(rename = "original")]
218    Original,
219}
220
221/// Source: `openai/types/responses/response_input_image.py`, `PromptCacheBreakpoint`.
222#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
223#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
224#[derive(gproxy_protocol_macros::DeclaredFields)]
225#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
226pub struct ResponseInputImagePromptCacheBreakpoint {
227    pub mode: ResponseInputImagePromptCacheBreakpointMode,
228    #[serde(default, skip_serializing_if = "Option::is_none")]
229    pub ttl: Option<PromptCacheBreakpointTtl>,
230    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
231    pub rest: Rest,
232}
233
234/// Source: `openai/types/responses/response_input_file.py`, `PromptCacheBreakpoint`.
235#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, gproxy_protocol_macros::WireBuilder)]
236#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
237#[derive(gproxy_protocol_macros::DeclaredFields)]
238#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
239pub struct ResponseInputFilePromptCacheBreakpoint {
240    pub mode: ResponseInputFilePromptCacheBreakpointMode,
241    #[serde(default, skip_serializing_if = "Option::is_none")]
242    pub ttl: Option<PromptCacheBreakpointTtl>,
243    #[serde(default, flatten, skip_serializing_if = "serde_json::Map::is_empty")]
244    pub rest: Rest,
245}
246
247#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
248#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
249#[derive(gproxy_protocol_macros::DeclaredFields)]
250#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
251pub enum ToolChoiceFunctionType {
252    #[serde(rename = "function")]
253    Function,
254}
255
256#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
257#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
258#[derive(gproxy_protocol_macros::DeclaredFields)]
259#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
260pub enum ToolChoiceMcpType {
261    #[serde(rename = "mcp")]
262    Mcp,
263}
264
265#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
266#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
267#[derive(gproxy_protocol_macros::DeclaredFields)]
268#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
269pub enum ResponseInputTextType {
270    #[serde(rename = "input_text")]
271    InputText,
272}
273
274#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
275#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
276#[derive(gproxy_protocol_macros::DeclaredFields)]
277#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
278pub enum ResponseInputImageType {
279    #[serde(rename = "input_image")]
280    InputImage,
281}
282
283#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
284#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
285#[derive(gproxy_protocol_macros::DeclaredFields)]
286#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
287pub enum ResponseInputFileType {
288    #[serde(rename = "input_file")]
289    InputFile,
290}
291
292#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
293#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
294#[derive(gproxy_protocol_macros::DeclaredFields)]
295#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
296pub enum ResponseInputFileDetail {
297    #[serde(rename = "auto")]
298    Auto,
299    #[serde(rename = "low")]
300    Low,
301    #[serde(rename = "high")]
302    High,
303}
304
305/// Source: Realtime.md `prompt_cache_breakpoint.ttl` (2026-10-27); omitted
306/// inherits the request TTL.
307#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
308#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
309#[derive(gproxy_protocol_macros::DeclaredFields)]
310#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
311pub enum PromptCacheBreakpointTtl {
312    #[serde(rename = "30m")]
313    ThirtyMinutes,
314    #[serde(rename = "12h")]
315    TwelveHours,
316}
317
318#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
319#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
320#[derive(gproxy_protocol_macros::DeclaredFields)]
321#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
322pub enum ResponseInputTextPromptCacheBreakpointMode {
323    #[serde(rename = "explicit")]
324    Explicit,
325}
326
327#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
328#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
329#[derive(gproxy_protocol_macros::DeclaredFields)]
330#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
331pub enum ResponseInputImagePromptCacheBreakpointMode {
332    #[serde(rename = "explicit")]
333    Explicit,
334}
335
336#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
337#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
338#[derive(gproxy_protocol_macros::DeclaredFields)]
339#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
340pub enum ResponseInputFilePromptCacheBreakpointMode {
341    #[serde(rename = "explicit")]
342    Explicit,
343}