Skip to main content

async_openai/types/responses/
response.rs

1use crate::error::OpenAIError;
2use crate::types::mcp::{MCPListToolsTool, MCPTool};
3use crate::types::responses::{
4    CustomGrammarFormatParam, Filter, ImageDetail, ImageGenInputUsageDetails,
5    ImageGenOutputTokensDetails, MessagePhase, MessageRole, MisalignmentErrorDetailsResource,
6    ModerationParam, ModerationResultBody, PromptCacheBreakpointTTLEnum, PromptCacheModeEnum,
7    PromptCacheOptionsParam, PromptCacheTTLEnum, ReasoningEffort, ResponseFormatJsonSchema,
8    ResponseUsage, SummaryTextContent,
9};
10use derive_builder::Builder;
11use serde::{Deserialize, Serialize};
12use std::collections::HashMap;
13
14/// Whether tool search was executed by the server or by the client.
15#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
16#[serde(rename_all = "snake_case")]
17pub enum ToolSearchExecutionType {
18    Server,
19    Client,
20}
21
22/// The type of content to search for.
23#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
24#[serde(rename_all = "snake_case")]
25pub enum SearchContentType {
26    Text,
27    Image,
28}
29
30/// The status of a function call.
31#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
32#[serde(rename_all = "snake_case")]
33pub enum FunctionCallStatus {
34    InProgress,
35    Completed,
36    Incomplete,
37}
38
39/// The status of a function call output.
40#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
41#[serde(rename_all = "snake_case")]
42pub enum FunctionCallOutputStatusEnum {
43    InProgress,
44    Completed,
45    Incomplete,
46}
47
48/// Groups function/custom tools under a shared namespace.
49#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Builder, Default)]
50#[builder(
51    name = "NamespaceToolParamArgs",
52    pattern = "mutable",
53    setter(into, strip_option),
54    default
55)]
56#[builder(build_fn(error = "OpenAIError"))]
57pub struct NamespaceToolParam {
58    /// The namespace name used in tool calls (for example, `crm`).
59    pub name: String,
60    /// A description of the namespace shown to the model.
61    pub description: String,
62    /// The function/custom tools available inside this namespace.
63    pub tools: Vec<NamespaceToolParamTool>,
64}
65
66/// A function or custom tool that belongs to a namespace.
67#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
68#[serde(tag = "type", rename_all = "snake_case")]
69pub enum NamespaceToolParamTool {
70    Function(FunctionToolParam),
71    Custom(CustomToolParam),
72}
73
74/// A function tool that can be used within a namespace or with tool search.
75#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
76#[builder(
77    name = "FunctionToolParamArgs",
78    pattern = "mutable",
79    setter(into, strip_option),
80    default
81)]
82#[builder(build_fn(error = "OpenAIError"))]
83pub struct FunctionToolParam {
84    /// The name of the function.
85    pub name: String,
86    /// A description of the function.
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub description: Option<String>,
89    /// A JSON schema object describing the parameters of the function.
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub parameters: Option<serde_json::Value>,
92    /// Whether to enforce strict parameter validation.
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub strict: Option<bool>,
95    /// Whether this function should be deferred and discovered via tool search.
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub defer_loading: Option<bool>,
98    /// Whether the tool response can be returned asynchronously versus immediately returned on next
99    /// response creation.
100    #[serde(skip_serializing_if = "Option::is_none")]
101    pub r#async: Option<bool>,
102
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub output_schema: Option<serde_json::Value>,
105
106    #[serde(skip_serializing_if = "Option::is_none")]
107    pub allowed_callers: Option<Vec<CallableToolAllowedCaller>>,
108}
109
110/// Hosted or BYOT tool search configuration for deferred tools.
111#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
112#[builder(
113    name = "ToolSearchToolParamArgs",
114    pattern = "mutable",
115    setter(into, strip_option),
116    default
117)]
118#[builder(build_fn(error = "OpenAIError"))]
119pub struct ToolSearchToolParam {
120    /// Whether tool search is executed by the server or by the client.
121    #[serde(skip_serializing_if = "Option::is_none")]
122    pub execution: Option<ToolSearchExecutionType>,
123    /// Description shown to the model for a client-executed tool search tool.
124    #[serde(skip_serializing_if = "Option::is_none")]
125    pub description: Option<String>,
126    /// Parameter schema for a client-executed tool search tool.
127    #[serde(skip_serializing_if = "Option::is_none")]
128    pub parameters: Option<serde_json::Value>,
129}
130
131/// A tool search call output item.
132#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
133pub struct ToolSearchCall {
134    /// The unique ID of the tool search call item.
135    pub id: String,
136    /// The unique ID of the tool search call generated by the model.
137    pub call_id: Option<String>,
138    /// Whether tool search was executed by the server or by the client.
139    pub execution: ToolSearchExecutionType,
140    /// Arguments used for the tool search call.
141    pub arguments: serde_json::Value,
142    /// The status of the tool search call item.
143    pub status: FunctionCallStatus,
144    /// The identifier of the actor that created the item.
145    #[serde(skip_serializing_if = "Option::is_none")]
146    pub created_by: Option<String>,
147}
148
149/// A tool search call input item.
150#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
151pub struct ToolSearchCallItemParam {
152    /// The unique ID of this tool search call.
153    #[serde(skip_serializing_if = "Option::is_none")]
154    pub id: Option<String>,
155    /// The unique ID of the tool search call generated by the model.
156    #[serde(skip_serializing_if = "Option::is_none")]
157    pub call_id: Option<String>,
158    /// Whether tool search was executed by the server or by the client.
159    #[serde(skip_serializing_if = "Option::is_none")]
160    pub execution: Option<ToolSearchExecutionType>,
161    /// The arguments supplied to the tool search call.
162    #[serde(default)]
163    pub arguments: serde_json::Value,
164    /// The status of the tool search call.
165    #[serde(skip_serializing_if = "Option::is_none")]
166    pub status: Option<OutputStatus>,
167}
168
169/// A tool search output item.
170#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
171pub struct ToolSearchOutput {
172    /// The unique ID of the tool search output item.
173    pub id: String,
174    /// The unique ID of the tool search call generated by the model.
175    pub call_id: Option<String>,
176    /// Whether tool search was executed by the server or by the client.
177    pub execution: ToolSearchExecutionType,
178    /// The loaded tool definitions returned by tool search.
179    pub tools: Vec<Tool>,
180    /// The status of the tool search output item.
181    pub status: FunctionCallOutputStatusEnum,
182    /// The identifier of the actor that created the item.
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub created_by: Option<String>,
185}
186
187/// A tool search output input item.
188#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
189pub struct ToolSearchOutputItemParam {
190    /// The unique ID of this tool search output.
191    #[serde(skip_serializing_if = "Option::is_none")]
192    pub id: Option<String>,
193    /// The unique ID of the tool search call generated by the model.
194    #[serde(skip_serializing_if = "Option::is_none")]
195    pub call_id: Option<String>,
196    /// Whether tool search was executed by the server or by the client.
197    #[serde(skip_serializing_if = "Option::is_none")]
198    pub execution: Option<ToolSearchExecutionType>,
199    /// The loaded tool definitions returned by the tool search output.
200    pub tools: Vec<ToolSearchOutputTool>,
201    /// The status of the tool search output.
202    #[serde(skip_serializing_if = "Option::is_none")]
203    pub status: Option<OutputStatus>,
204}
205
206/// Role of messages in the API.
207#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Default)]
208#[serde(rename_all = "lowercase")]
209pub enum Role {
210    #[default]
211    User,
212    Assistant,
213    System,
214    Developer,
215}
216
217/// Status of input/output items.
218#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
219#[serde(rename_all = "snake_case")]
220pub enum OutputStatus {
221    InProgress,
222    Completed,
223    Incomplete,
224}
225
226#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
227#[serde(untagged)]
228pub enum InputParam {
229    ///  A text input to the model, equivalent to a text input with the
230    /// `user` role.
231    Text(String),
232    /// A list of one or many input items to the model, containing
233    /// different content types.
234    Items(Vec<InputItem>),
235}
236
237/// Content item used to generate a response.
238///
239/// This is a properly discriminated union based on the `type` field, using Rust's
240/// type-safe enum with serde's tag attribute for efficient deserialization.
241///
242/// # OpenAPI Specification
243/// Corresponds to the `Item` schema in the OpenAPI spec with a `type` discriminator.
244#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
245#[serde(tag = "type", rename_all = "snake_case")]
246pub enum Item {
247    /// A message (type: "message").
248    /// Can represent InputMessage (user/system/developer) or OutputMessage (assistant).
249    ///
250    /// InputMessage:
251    ///     A message input to the model with a role indicating instruction following hierarchy.
252    ///     Instructions given with the developer or system role take precedence over instructions given with the user role.
253    /// OutputMessage:
254    ///     A message output from the model.
255    Message(MessageItem),
256
257    /// The results of a file search tool call. See the
258    /// [file search guide](https://platform.openai.com/docs/guides/tools-file-search) for more information.
259    FileSearchCall(FileSearchToolCall),
260
261    /// A tool call to a computer use tool. See the
262    /// [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use) for more information.
263    ComputerCall(ComputerToolCall),
264
265    /// The output of a computer tool call.
266    ComputerCallOutput(ComputerCallOutputItemParam),
267
268    /// The results of a web search tool call. See the
269    /// [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for more information.
270    WebSearchCall(WebSearchToolCall),
271
272    /// A tool call to run a function. See the
273    ///
274    /// [function calling guide](https://platform.openai.com/docs/guides/function-calling) for more information.
275    FunctionCall(FunctionToolCall),
276
277    /// The output of a function tool call.
278    FunctionCallOutput(FunctionCallOutputItemParam),
279
280    /// A tool search call.
281    ToolSearchCall(ToolSearchCallItemParam),
282
283    /// A tool search output.
284    ToolSearchOutput(ToolSearchOutputItemParam),
285
286    AdditionalTools(AdditionalToolsItemParam),
287
288    /// An update to the conversation's response configuration. The configuration
289    /// remains in effect for subsequent responses until it is replaced by another
290    /// configuration update.
291    ConfigurationUpdate(ResponseConfigurationUpdateItemParam),
292
293    /// A description of the chain of thought used by a reasoning model while generating
294    /// a response. Be sure to include these items in your `input` to the Responses API
295    /// for subsequent turns of a conversation if you are manually
296    /// [managing context](https://platform.openai.com/docs/guides/conversation-state).
297    Reasoning(ReasoningItem),
298
299    /// A compaction item generated by the [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
300    Compaction(CompactionSummaryItemParam),
301
302    /// An image generation request made by the model.
303    ImageGenerationCall(ImageGenToolCall),
304
305    /// A tool call to run code.
306    CodeInterpreterCall(CodeInterpreterToolCall),
307
308    /// A tool call to run a command on the local shell.
309    LocalShellCall(LocalShellToolCall),
310
311    /// The output of a local shell tool call.
312    LocalShellCallOutput(LocalShellToolCallOutput),
313
314    /// A tool representing a request to execute one or more shell commands.
315    ShellCall(FunctionShellCallItemParam),
316
317    /// The streamed output items emitted by a shell tool call.
318    ShellCallOutput(FunctionShellCallOutputItemParam),
319
320    /// A tool call representing a request to create, delete, or update files using diff patches.
321    ApplyPatchCall(ApplyPatchToolCallItemParam),
322
323    /// The streamed output emitted by an apply patch tool call.
324    ApplyPatchCallOutput(ApplyPatchToolCallOutputItemParam),
325
326    /// A list of tools available on an MCP server.
327    McpListTools(MCPListTools),
328
329    /// A request for human approval of a tool invocation.
330    McpApprovalRequest(MCPApprovalRequest),
331
332    /// A response to an MCP approval request.
333    McpApprovalResponse(MCPApprovalResponse),
334
335    /// An invocation of a tool on an MCP server.
336    McpCall(MCPToolCall),
337
338    /// The output of a custom tool call from your code, being sent back to the model.
339    CustomToolCallOutput(CustomToolCallOutput),
340
341    /// A call to a custom tool created by the model.
342    CustomToolCall(CustomToolCall),
343}
344
345/// Input item that can be used in the context for generating a response.
346///
347/// This represents the OpenAPI `InputItem` schema which is a `oneOf`:
348/// 1. `EasyInputMessage` - Simple, user-friendly message input (can use string content)
349/// 2. `Item` - Structured items with proper type discrimination (including InputMessage, OutputMessage, tool calls)
350/// 3. `ItemReferenceParam` - Reference to an existing item by ID (type can be null)
351/// 4. `CompactionTriggerItemParam` - An explicit compaction trigger
352/// 5. `ProgramItemParam` - A program replay item
353/// 6. `ProgramOutputItemParam` - A program output replay item
354///
355/// Program and compaction-trigger items use the `type` discriminator directly.
356/// References, structured items, and easy messages retain untagged alternatives
357/// because their shapes overlap and some allow an omitted or null `type`.
358///
359/// # OpenAPI Specification
360/// Corresponds to the `InputItem` schema, including the alternatives outside `Item`.
361#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
362#[serde(tag = "type")]
363pub enum InputItem {
364    /// An explicit compaction trigger.
365    #[serde(rename = "compaction_trigger")]
366    CompactionTrigger(CompactionTriggerItemParam),
367
368    /// A program item echoed back for replay.
369    #[serde(rename = "program")]
370    Program(ProgramItemParam),
371
372    /// A program output echoed back for replay.
373    #[serde(rename = "program_output")]
374    ProgramOutput(ProgramOutputItemParam),
375
376    /// A reference to an existing item by ID.
377    /// Has a required `id` field and optional `type` (can be "item_reference" or null).
378    /// Tried first among the untagged alternatives as it's the most minimal structure.
379    #[serde(untagged)]
380    ItemReference(ItemReference),
381
382    /// All structured items with proper type discrimination.
383    /// Includes InputMessage, OutputMessage, and all tool calls/outputs.
384    /// Uses the discriminated `Item` enum for efficient, type-safe deserialization.
385    #[serde(untagged)]
386    Item(Item),
387
388    /// A simple, user-friendly message input (EasyInputMessage).
389    /// Supports string content and can include assistant role for previous responses.
390    /// Must be tried last as it's the most flexible structure.
391    ///
392    /// A message input to the model with a role indicating instruction following
393    /// hierarchy. Instructions given with the `developer` or `system` role take
394    /// precedence over instructions given with the `user` role. Messages with the
395    /// `assistant` role are presumed to have been generated by the model in previous
396    /// interactions.
397    #[serde(untagged)]
398    EasyMessage(EasyInputMessage),
399}
400
401/// A message item used within the `Item` enum.
402///
403/// Both InputMessage and OutputMessage have `type: "message"`, so we use an untagged
404/// enum to distinguish them based on their structure:
405/// - OutputMessage: role=assistant, required id & status fields
406/// - InputMessage: role=user/system/developer, content is `Vec<ContentType>`, optional id/status
407///
408/// Note: EasyInputMessage is NOT included here - it's a separate variant in `InputItem`,
409/// not part of the structured `Item` enum.
410#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
411#[serde(untagged)]
412pub enum MessageItem {
413    /// An output message from the model (role: assistant, has required id & status).
414    /// This must come first as it has the most specific structure (required id and status fields).
415    Output(OutputMessage),
416
417    /// A structured input message (role: user/system/developer, content is `Vec<ContentType>`).
418    /// Has structured content list and optional id/status fields.
419    ///
420    /// A message input to the model with a role indicating instruction following hierarchy.
421    /// Instructions given with the `developer` or `system` role take precedence over instructions
422    /// given with the `user` role.
423    Input(InputMessage),
424}
425
426/// A reference to an existing item by ID.
427#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
428pub struct ItemReference {
429    /// The type of item to reference. Can be "item_reference" or null.
430    #[serde(skip_serializing_if = "Option::is_none")]
431    pub r#type: Option<ItemReferenceType>,
432    /// The ID of the item to reference.
433    pub id: String,
434}
435
436#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
437#[serde(rename_all = "snake_case")]
438pub enum ItemReferenceType {
439    ItemReference,
440}
441
442/// Output from a function call that you're providing back to the model.
443#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
444pub struct FunctionCallOutputItemParam {
445    /// The unique ID of the function tool call generated by the model.
446    #[serde(skip_serializing_if = "Option::is_none")]
447    pub call_id: Option<String>,
448    /// Text, image, or file output of the function tool call.
449    pub output: FunctionCallOutput,
450    /// The unique ID of the function tool call output.
451    /// Populated when this item is returned via API.
452    #[serde(skip_serializing_if = "Option::is_none")]
453    pub id: Option<String>,
454    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
455    /// Populated when items are returned via API.
456    #[serde(skip_serializing_if = "Option::is_none")]
457    pub status: Option<OutputStatus>,
458    /// The name of the tool that produced the output.
459    #[serde(skip_serializing_if = "Option::is_none")]
460    pub name: Option<String>,
461    /// The namespace of the tool that produced the output.
462    #[serde(skip_serializing_if = "Option::is_none")]
463    pub namespace: Option<String>,
464    /// The execution context that produced this tool call.
465    #[serde(skip_serializing_if = "Option::is_none")]
466    pub caller: Option<ToolCallCaller>,
467}
468
469#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
470#[serde(untagged)]
471pub enum FunctionCallOutput {
472    /// A JSON string of the output of the function tool call.
473    Text(String),
474    Content(Vec<InputContent>), // TODO use shape which allows null from OpenAPI spec?
475}
476
477#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
478pub struct ComputerCallOutputItemParam {
479    /// The ID of the computer tool call that produced the output.
480    pub call_id: String,
481    /// A computer screenshot image used with the computer use tool.
482    pub output: ComputerScreenshotImage,
483    /// The safety checks reported by the API that have been acknowledged by the developer.
484    #[serde(skip_serializing_if = "Option::is_none")]
485    pub acknowledged_safety_checks: Option<Vec<ComputerCallSafetyCheckParam>>,
486    /// The unique ID of the computer tool call output. Optional when creating.
487    #[serde(skip_serializing_if = "Option::is_none")]
488    pub id: Option<String>,
489    /// The status of the message input. One of `in_progress`, `completed`, or `incomplete`.
490    /// Populated when input items are returned via API.
491    #[serde(skip_serializing_if = "Option::is_none")]
492    pub status: Option<OutputStatus>, // TODO rename OutputStatus?
493}
494
495/// The status of a computer tool call output item returned by the API.
496#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
497#[serde(rename_all = "snake_case")]
498pub enum ComputerCallOutputStatus {
499    InProgress,
500    Completed,
501    Incomplete,
502    Failed,
503}
504
505/// A computer tool call output item returned by the API.
506#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
507pub struct ComputerToolCallOutputResource {
508    /// The ID of the computer tool call that produced the output.
509    pub call_id: String,
510    /// A computer screenshot image used with the computer use tool.
511    pub output: ComputerScreenshotImage,
512    /// The safety checks reported by the API that have been acknowledged by the developer.
513    #[serde(skip_serializing_if = "Option::is_none")]
514    pub acknowledged_safety_checks: Option<Vec<ComputerCallSafetyCheckParam>>,
515    /// The ID of the computer tool call output.
516    pub id: String,
517    /// The status of the item returned by the API.
518    pub status: ComputerCallOutputStatus,
519    /// The identifier of the actor that created the item.
520    #[serde(skip_serializing_if = "Option::is_none")]
521    pub created_by: Option<String>,
522}
523
524#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
525#[serde(rename_all = "snake_case")]
526pub enum ComputerScreenshotImageType {
527    ComputerScreenshot,
528}
529
530/// A computer screenshot image used with the computer use tool.
531#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
532pub struct ComputerScreenshotImage {
533    /// Specifies the event type. For a computer screenshot, this property is always
534    /// set to `computer_screenshot`.
535    pub r#type: ComputerScreenshotImageType,
536    /// The identifier of an uploaded file that contains the screenshot.
537    #[serde(skip_serializing_if = "Option::is_none")]
538    pub file_id: Option<String>,
539    /// The URL of the screenshot image.
540    #[serde(skip_serializing_if = "Option::is_none")]
541    pub image_url: Option<String>,
542}
543
544/// Output from a local shell tool call that you're providing back to the model.
545#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
546pub struct LocalShellToolCallOutput {
547    /// The unique ID of the local shell tool call generated by the model.
548    pub id: String,
549
550    /// A JSON string of the output of the local shell tool call.
551    pub output: String,
552
553    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
554    #[serde(skip_serializing_if = "Option::is_none")]
555    pub status: Option<OutputStatus>,
556}
557
558/// Output from a local shell command execution.
559#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
560pub struct LocalShellOutput {
561    /// The stdout output from the command.
562    #[serde(skip_serializing_if = "Option::is_none")]
563    pub stdout: Option<String>,
564
565    /// The stderr output from the command.
566    #[serde(skip_serializing_if = "Option::is_none")]
567    pub stderr: Option<String>,
568
569    /// The exit code of the command.
570    #[serde(skip_serializing_if = "Option::is_none")]
571    pub exit_code: Option<i32>,
572}
573
574/// An MCP approval response that you're providing back to the model.
575#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
576pub struct MCPApprovalResponse {
577    /// The ID of the approval request being answered.
578    pub approval_request_id: String,
579
580    /// Whether the request was approved.
581    pub approve: bool,
582
583    /// The unique ID of the approval response
584    #[serde(skip_serializing_if = "Option::is_none")]
585    pub id: Option<String>,
586
587    /// Optional reason for the decision.
588    #[serde(skip_serializing_if = "Option::is_none")]
589    pub reason: Option<String>,
590}
591
592#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
593#[serde(untagged)]
594pub enum CustomToolCallOutputOutput {
595    /// A string of the output of the custom tool call.
596    Text(String),
597    /// Text, image, or file output of the custom tool call.
598    List(Vec<InputContent>),
599}
600
601#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
602pub struct CustomToolCallOutput {
603    /// The call ID, used to map this custom tool call output to a custom tool call.
604    pub call_id: String,
605
606    /// The output from the custom tool call generated by your code.
607    /// Can be a string or an list of output content.
608    pub output: CustomToolCallOutputOutput,
609
610    /// The unique ID of the custom tool call output in the OpenAI platform.
611    #[serde(skip_serializing_if = "Option::is_none")]
612    pub id: Option<String>,
613
614    #[serde(skip_serializing_if = "Option::is_none")]
615    pub caller: Option<ToolCallCaller>,
616}
617
618/// A custom tool call output item returned by the API.
619#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
620pub struct CustomToolCallOutputResource {
621    /// The call ID, used to map this custom tool call output to a custom tool call.
622    pub call_id: String,
623
624    /// The output from the custom tool call generated by your code.
625    /// Can be a string or a list of output content.
626    pub output: CustomToolCallOutputOutput,
627
628    /// The unique ID of the custom tool call output item.
629    pub id: String,
630
631    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
632    pub status: FunctionCallOutputStatusEnum,
633
634    /// The identifier of the actor that created the item.
635    #[serde(skip_serializing_if = "Option::is_none")]
636    pub created_by: Option<String>,
637
638    #[serde(skip_serializing_if = "Option::is_none")]
639    pub caller: Option<ToolCallCaller>,
640}
641
642/// A simplified message input to the model (EasyInputMessage in the OpenAPI spec).
643///
644/// This is the most user-friendly way to provide messages, supporting both simple
645/// string content and structured content. Role can include `assistant` for providing
646/// previous assistant responses.
647#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
648#[builder(
649    name = "EasyInputMessageArgs",
650    pattern = "mutable",
651    setter(into, strip_option),
652    default
653)]
654#[builder(build_fn(error = "OpenAIError"))]
655pub struct EasyInputMessage {
656    /// The type of the message input. Defaults to `message` when omitted in JSON input.
657    #[serde(default)]
658    pub r#type: MessageType,
659    /// The role of the message input. One of `user`, `assistant`, `system`, or `developer`.
660    pub role: Role,
661    /// Text, image, or audio input to the model, used to generate a response.
662    /// Can also contain previous assistant responses.
663    pub content: EasyInputContent,
664    /// Labels an `assistant` message as intermediate commentary (`commentary`) or
665    /// the final answer (`final_answer`). Not used for user messages.
666    #[serde(skip_serializing_if = "Option::is_none")]
667    pub phase: Option<MessagePhase>,
668}
669
670/// A structured message input to the model (InputMessage in the OpenAPI spec).
671///
672/// This variant requires structured content (not a simple string) and does not support
673/// the `assistant` role (use OutputMessage for that). status is populated when items are returned via API.
674#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
675#[builder(
676    name = "InputMessageArgs",
677    pattern = "mutable",
678    setter(into, strip_option),
679    default
680)]
681#[builder(build_fn(error = "OpenAIError"))]
682pub struct InputMessage {
683    /// A list of one or many input items to the model, containing different content types.
684    pub content: Vec<InputContent>,
685    /// The role of the message input. One of `user`, `system`, or `developer`.
686    /// Note: `assistant` is NOT allowed here; use OutputMessage instead.
687    pub role: InputRole,
688    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
689    /// Populated when items are returned via API.
690    #[serde(skip_serializing_if = "Option::is_none")]
691    pub status: Option<OutputStatus>,
692    /////The type of the message input. Always set to `message`.
693    //pub r#type: MessageType,
694}
695
696/// The role for an input message - can only be `user`, `system`, or `developer`.
697/// This type ensures type safety by excluding the `assistant` role (use OutputMessage for that).
698#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
699#[serde(rename_all = "lowercase")]
700pub enum InputRole {
701    #[default]
702    User,
703    System,
704    Developer,
705}
706
707/// Content for EasyInputMessage - can be a simple string or structured list.
708#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
709#[serde(untagged)]
710pub enum EasyInputContent {
711    /// A text input to the model.
712    Text(String),
713    /// A list of one or many input items to the model, containing different content types.
714    ContentList(Vec<InputContent>),
715}
716
717/// Parts of a message: text, image, file, or audio.
718#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
719#[serde(tag = "type", rename_all = "snake_case")]
720pub enum InputContent {
721    /// A text input to the model.
722    InputText(InputTextContent),
723    /// An image input to the model. Learn about
724    /// [image inputs](https://platform.openai.com/docs/guides/vision).
725    InputImage(InputImageContent),
726    /// A file input to the model.
727    InputFile(InputFileContent),
728}
729
730#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
731pub struct InputTextContent {
732    /// The text input to the model.
733    pub text: String,
734    #[serde(skip_serializing_if = "Option::is_none")]
735    pub prompt_cache_breakpoint: Option<PromptCacheBreakpointConfig>,
736}
737
738#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
739#[builder(
740    name = "InputImageArgs",
741    pattern = "mutable",
742    setter(into, strip_option),
743    default
744)]
745#[builder(build_fn(error = "OpenAIError"))]
746pub struct InputImageContent {
747    /// The detail level of the image to be sent to the model. One of `high`, `low`, or `auto`.
748    /// Defaults to `auto` when omitted in JSON input.
749    #[serde(default)]
750    pub detail: ImageDetail,
751    /// The ID of the file to be sent to the model.
752    #[serde(skip_serializing_if = "Option::is_none")]
753    pub file_id: Option<String>,
754    /// The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image
755    /// in a data URL.
756    #[serde(skip_serializing_if = "Option::is_none")]
757    pub image_url: Option<String>,
758    #[serde(skip_serializing_if = "Option::is_none")]
759    pub prompt_cache_breakpoint: Option<PromptCacheBreakpointConfig>,
760}
761
762#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
763#[builder(
764    name = "InputFileArgs",
765    pattern = "mutable",
766    setter(into, strip_option),
767    default
768)]
769#[builder(build_fn(error = "OpenAIError"))]
770pub struct InputFileContent {
771    /// The content of the file to be sent to the model.
772    #[serde(skip_serializing_if = "Option::is_none")]
773    pub file_data: Option<String>,
774    /// The ID of the file to be sent to the model.
775    #[serde(skip_serializing_if = "Option::is_none")]
776    pub file_id: Option<String>,
777    /// The URL of the file to be sent to the model.
778    #[serde(skip_serializing_if = "Option::is_none")]
779    pub file_url: Option<String>,
780    /// The name of the file to be sent to the model.
781    #[serde(skip_serializing_if = "Option::is_none")]
782    pub filename: Option<String>,
783    /// The detail level of the file to be sent to the model. Use `auto` to let the system select the detail
784    /// level; for GPT-5.6 and later models, `auto` uses high-quality rendering, which may increase input
785    /// token usage. Use `low` for lower-cost rendering, or `high` to render the file at higher quality.
786    /// Defaults to `auto`.
787    #[serde(skip_serializing_if = "Option::is_none")]
788    pub detail: Option<FileInputDetail>,
789    #[serde(skip_serializing_if = "Option::is_none")]
790    pub prompt_cache_breakpoint: Option<PromptCacheBreakpointConfig>,
791}
792
793/// The conversation that this response belonged to. Input items and output items from this
794/// response were automatically added to this conversation.
795#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
796pub struct Conversation {
797    /// The unique ID of the conversation that this response was associated with.
798    pub id: String,
799}
800
801#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
802#[serde(untagged)]
803pub enum ConversationParam {
804    /// The unique ID of the conversation.
805    ConversationID(String),
806    /// The conversation that this response belongs to.
807    Object(Conversation),
808}
809
810#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
811pub enum IncludeEnum {
812    #[serde(rename = "file_search_call.results")]
813    FileSearchCallResults,
814    #[serde(rename = "web_search_call.results")]
815    WebSearchCallResults,
816    #[serde(rename = "web_search_call.action.sources")]
817    WebSearchCallActionSources,
818    #[serde(rename = "message.input_image.image_url")]
819    MessageInputImageImageUrl,
820    #[serde(rename = "computer_call_output.output.image_url")]
821    ComputerCallOutputOutputImageUrl,
822    #[serde(rename = "code_interpreter_call.outputs")]
823    CodeInterpreterCallOutputs,
824    #[serde(rename = "reasoning.encrypted_content")]
825    ReasoningEncryptedContent,
826    #[serde(rename = "message.output_text.logprobs")]
827    MessageOutputTextLogprobs,
828}
829
830#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
831pub struct ResponseStreamOptions {
832    /// When true, stream obfuscation will be enabled. Stream obfuscation adds
833    /// random characters to an `obfuscation` field on streaming delta events to
834    /// normalize payload sizes as a mitigation to certain side-channel attacks.
835    /// These obfuscation fields are included by default, but add a small amount
836    /// of overhead to the data stream. You can set `include_obfuscation` to
837    /// false to optimize for bandwidth if you trust the network links between
838    /// your application and the OpenAI API.
839    #[serde(skip_serializing_if = "Option::is_none")]
840    pub include_obfuscation: Option<bool>,
841}
842
843/// Builder for a Responses API request.
844#[derive(Clone, Serialize, Deserialize, Debug, Default, Builder, PartialEq)]
845#[builder(
846    name = "CreateResponseArgs",
847    pattern = "mutable",
848    setter(into, strip_option),
849    default
850)]
851#[builder(build_fn(error = "OpenAIError"))]
852pub struct CreateResponse {
853    /// Whether to run the model response in the background.
854    /// [Learn more](https://platform.openai.com/docs/guides/background).
855    #[serde(skip_serializing_if = "Option::is_none")]
856    pub background: Option<bool>,
857
858    /// The conversation that this response belongs to. Items from this conversation are prepended to
859    ///  `input_items` for this response request.
860    ///
861    /// Input items and output items from this response are automatically added to this conversation after
862    /// this response completes.
863    #[serde(skip_serializing_if = "Option::is_none")]
864    pub conversation: Option<ConversationParam>,
865
866    /// Specify additional output data to include in the model response. Currently supported
867    /// values are:
868    ///
869    /// - `web_search_call.action.sources`: Include the sources of the web search tool call.
870    ///
871    /// - `code_interpreter_call.outputs`: Includes the outputs of python code execution in code
872    ///   interpreter tool call items.
873    ///
874    /// - `computer_call_output.output.image_url`: Include image urls from the computer call
875    ///   output.
876    ///
877    /// - `file_search_call.results`: Include the search results of the file search tool call.
878    ///
879    /// - `message.input_image.image_url`: Include image urls from the input message.
880    ///
881    /// - `message.output_text.logprobs`: Include logprobs with assistant messages.
882    ///
883    /// - `reasoning.encrypted_content`: Includes an encrypted version of reasoning tokens in
884    ///   reasoning item outputs. This enables reasoning items to be used in multi-turn
885    ///   conversations when using the Responses API statelessly (like when the `store` parameter is
886    ///   set to `false`, or when an organization is enrolled in the zero data retention program).
887    #[serde(skip_serializing_if = "Option::is_none")]
888    pub include: Option<Vec<IncludeEnum>>,
889
890    /// Text, image, or file inputs to the model, used to generate a response.
891    ///
892    /// Learn more:
893    /// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
894    /// - [Image inputs](https://platform.openai.com/docs/guides/images)
895    /// - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
896    /// - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
897    /// - [Function calling](https://platform.openai.com/docs/guides/function-calling)
898    pub input: InputParam,
899
900    /// A system (or developer) message inserted into the model's context.
901    ///
902    /// When using along with `previous_response_id`, the instructions from a previous
903    /// response will not be carried over to the next response. This makes it simple
904    /// to swap out system (or developer) messages in new responses.
905    #[serde(skip_serializing_if = "Option::is_none")]
906    pub instructions: Option<String>,
907
908    /// An upper bound for the number of tokens that can be generated for a response, including
909    /// visible output tokens and [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
910    #[serde(skip_serializing_if = "Option::is_none")]
911    pub max_output_tokens: Option<u32>,
912
913    /// The maximum number of total calls to built-in tools that can be processed in a response. This
914    /// maximum number applies across all built-in tool calls, not per individual tool. Any further
915    /// attempts to call a tool by the model will be ignored.
916    #[serde(skip_serializing_if = "Option::is_none")]
917    pub max_tool_calls: Option<u32>,
918
919    /// Set of 16 key-value pairs that can be attached to an object. This can be
920    /// useful for storing additional information about the object in a structured
921    /// format, and querying for objects via API or the dashboard.
922    ///
923    /// Keys are strings with a maximum length of 64 characters. Values are
924    /// strings with a maximum length of 512 characters.
925    #[serde(skip_serializing_if = "Option::is_none")]
926    pub metadata: Option<HashMap<String, String>>,
927
928    /// Model ID used to generate the response, like `gpt-6-astra`. OpenAI
929    /// offers a wide range of models with different capabilities, performance
930    /// characteristics, and price points. Refer to the [model guide](/docs/models)
931    /// to browse and compare available models.
932    #[serde(skip_serializing_if = "Option::is_none")]
933    pub model: Option<String>,
934
935    /// Whether to allow the model to run tool calls in parallel.
936    #[serde(skip_serializing_if = "Option::is_none")]
937    pub parallel_tool_calls: Option<bool>,
938
939    /// The unique ID of the previous response to the model. Use this to create multi-turn conversations.
940    /// Learn more about [conversation state](https://platform.openai.com/docs/guides/conversation-state).
941    /// Cannot be used in conjunction with `conversation`.
942    #[serde(skip_serializing_if = "Option::is_none")]
943    pub previous_response_id: Option<String>,
944
945    /// Reference to a prompt template and its variables.
946    /// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
947    #[serde(skip_serializing_if = "Option::is_none")]
948    pub prompt: Option<Prompt>,
949
950    /// Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces
951    /// the `user` field. [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
952    #[serde(skip_serializing_if = "Option::is_none")]
953    pub prompt_cache_key: Option<String>,
954
955    /// The retention policy for the prompt cache. Set to `24h` to enable extended prompt caching,
956    /// which keeps cached prefixes active for longer, up to a maximum of 24 hours. [Learn
957    /// more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
958    #[serde(skip_serializing_if = "Option::is_none")]
959    #[deprecated(note = "Use prompt_cache_options instead.")]
960    pub prompt_cache_retention: Option<PromptCacheRetention>,
961
962    /// **gpt-5 and o-series models only**
963    /// Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
964    #[serde(skip_serializing_if = "Option::is_none")]
965    pub reasoning: Option<Reasoning>,
966
967    /// A stable identifier used to help detect users of your application that may be violating OpenAI's
968    /// usage policies.
969    ///
970    /// The IDs should be a string that uniquely identifies each user. We recommend hashing their username
971    /// or email address, in order to avoid sending us any identifying information. [Learn
972    /// more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
973    #[serde(skip_serializing_if = "Option::is_none")]
974    pub safety_identifier: Option<String>,
975
976    /// Specifies the processing type used for serving the request.
977    /// - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
978    /// - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
979    /// - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
980    /// - When not set, the default behavior is 'auto'.
981    ///
982    /// When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
983    #[serde(skip_serializing_if = "Option::is_none")]
984    pub service_tier: Option<ServiceTierResponses>,
985
986    /// Whether to store the generated model response for later retrieval via API.
987    #[serde(skip_serializing_if = "Option::is_none")]
988    pub store: Option<bool>,
989
990    /// If set to true, the model response data will be streamed to the client
991    /// as it is generated using [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format).
992    /// See the [Streaming section below](https://platform.openai.com/docs/api-reference/responses-streaming)
993    /// for more information.
994    #[serde(skip_serializing_if = "Option::is_none")]
995    pub stream: Option<bool>,
996
997    /// Options for streaming responses. Only set this when you set `stream: true`.
998    #[serde(skip_serializing_if = "Option::is_none")]
999    pub stream_options: Option<ResponseStreamOptions>,
1000
1001    /// What sampling temperature to use, between 0 and 2. Higher values like 0.8
1002    /// will make the output more random, while lower values like 0.2 will make it
1003    /// more focused and deterministic. We generally recommend altering this or
1004    /// `top_p` but not both.
1005    #[serde(skip_serializing_if = "Option::is_none")]
1006    pub temperature: Option<f32>,
1007
1008    /// Configuration options for a text response from the model. Can be plain
1009    /// text or structured JSON data. Learn more:
1010    /// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
1011    /// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
1012    #[serde(skip_serializing_if = "Option::is_none")]
1013    pub text: Option<ResponseTextParam>,
1014
1015    /// How the model should select which tool (or tools) to use when generating
1016    /// a response. See the `tools` parameter to see how to specify which tools
1017    /// the model can call.
1018    #[serde(skip_serializing_if = "Option::is_none")]
1019    pub tool_choice: Option<ToolChoiceParam>,
1020
1021    /// An array of tools the model may call while generating a response. You
1022    /// can specify which tool to use by setting the `tool_choice` parameter.
1023    ///
1024    /// We support the following categories of tools:
1025    /// - **Built-in tools**: Tools that are provided by OpenAI that extend the
1026    ///   model's capabilities, like [web search](https://platform.openai.com/docs/guides/tools-web-search)
1027    ///   or [file search](https://platform.openai.com/docs/guides/tools-file-search). Learn more about
1028    ///   [built-in tools](https://platform.openai.com/docs/guides/tools).
1029    /// - **MCP Tools**: Integrations with third-party systems via custom MCP servers
1030    ///   or predefined connectors such as Google Drive and SharePoint. Learn more about
1031    ///   [MCP Tools](https://platform.openai.com/docs/guides/tools-connectors-mcp).
1032    /// - **Function calls (custom tools)**: Functions that are defined by you,
1033    ///   enabling the model to call your own code with strongly typed arguments
1034    ///   and outputs. Learn more about
1035    ///   [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use
1036    ///   custom tools to call your own code.
1037    #[serde(skip_serializing_if = "Option::is_none")]
1038    pub tools: Option<Vec<Tool>>,
1039
1040    /// An integer between 0 and 20 specifying the number of most likely tokens to return at each
1041    /// token position, each with an associated log probability. In some cases, the number of returned
1042    /// tokens may be fewer than requested.
1043    #[serde(skip_serializing_if = "Option::is_none")]
1044    pub top_logprobs: Option<u8>,
1045
1046    /// An alternative to sampling with temperature, called nucleus sampling,
1047    /// where the model considers the results of the tokens with top_p probability
1048    /// mass. So 0.1 means only the tokens comprising the top 10% probability mass
1049    /// are considered.
1050    ///
1051    /// We generally recommend altering this or `temperature` but not both.
1052    #[serde(skip_serializing_if = "Option::is_none")]
1053    pub top_p: Option<f32>,
1054
1055    ///The truncation strategy to use for the model response.
1056    /// - `auto`: If the input to this Response exceeds
1057    ///   the model's context window size, the model will truncate the
1058    ///   response to fit the context window by dropping items from the beginning of the conversation.
1059    /// - `disabled` (default): If the input size will exceed the context window
1060    ///   size for a model, the request will fail with a 400 error.
1061    #[serde(skip_serializing_if = "Option::is_none")]
1062    #[deprecated(note = "Deprecated by the API; use context_management for compaction.")]
1063    pub truncation: Option<Truncation>,
1064
1065    /// Context management configuration for this request.
1066    #[serde(skip_serializing_if = "Option::is_none")]
1067    pub context_management: Option<Vec<ContextManagementParam>>,
1068
1069    #[serde(skip_serializing_if = "Option::is_none")]
1070    pub prompt_cache_options: Option<ResponsePromptCacheOptionsParam>,
1071
1072    #[serde(skip_serializing_if = "Option::is_none")]
1073    pub moderation: Option<ModerationParam>,
1074
1075    /// Domain-specific access programs to use for this request.
1076    #[serde(skip_serializing_if = "Option::is_none")]
1077    pub access_programs: Option<AccessProgramsParam>,
1078}
1079
1080#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1081#[serde(untagged)]
1082pub enum ResponsePromptVariables {
1083    String(String),
1084    Content(InputContent),
1085    Custom(serde_json::Value),
1086}
1087
1088#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1089pub struct Prompt {
1090    /// The unique identifier of the prompt template to use.
1091    pub id: String,
1092
1093    /// Optional version of the prompt template.
1094    #[serde(skip_serializing_if = "Option::is_none")]
1095    pub version: Option<String>,
1096
1097    /// Optional map of values to substitute in for variables in your
1098    /// prompt. The substitution values can either be strings, or other
1099    /// Response input types like images or files.
1100    #[serde(skip_serializing_if = "Option::is_none")]
1101    pub variables: Option<ResponsePromptVariables>,
1102}
1103
1104/// Truncation strategies.
1105#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1106#[serde(rename_all = "lowercase")]
1107pub enum Truncation {
1108    Auto,
1109    Disabled,
1110}
1111
1112#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1113pub struct Billing {
1114    pub payer: String,
1115}
1116
1117/// o-series reasoning settings.
1118#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1119#[builder(
1120    name = "ReasoningArgs",
1121    pattern = "mutable",
1122    setter(into, strip_option),
1123    default
1124)]
1125#[builder(build_fn(error = "OpenAIError"))]
1126pub struct Reasoning {
1127    /// Constrains effort on reasoning for
1128    /// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
1129    /// Currently supported values are `minimal`, `low`, `medium`, and `high`. Reducing
1130    /// reasoning effort can result in faster responses and fewer tokens used
1131    /// on reasoning in a response.
1132    ///
1133    /// Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
1134    #[serde(skip_serializing_if = "Option::is_none")]
1135    pub effort: Option<ReasoningEffort>,
1136    /// A summary of the reasoning performed by the model. This can be
1137    /// useful for debugging and understanding the model's reasoning process.
1138    /// One of `auto`, `concise`, or `detailed`.
1139    ///
1140    /// `concise` is supported for `computer-use-preview` models and all reasoning models after
1141    /// `gpt-5`.
1142    #[serde(skip_serializing_if = "Option::is_none")]
1143    pub summary: Option<ReasoningSummary>,
1144    /// Controls the reasoning execution mode for the request.
1145    ///
1146    /// When returned on a response, this is the effective execution mode.
1147    #[serde(skip_serializing_if = "Option::is_none")]
1148    pub mode: Option<ReasoningModeEnum>,
1149
1150    /// Controls which reasoning items are rendered back to the model on later turns.
1151    ///
1152    /// If omitted or set to `auto`, the model determines the context mode. The
1153    /// `gpt-5.6` model family defaults to `all_turns`; earlier models default to `current_turn`.
1154    ///
1155    /// When returned on a response, this is the effective reasoning context mode used for the response.
1156    #[serde(skip_serializing_if = "Option::is_none")]
1157    pub context: Option<ReasoningContext>,
1158}
1159
1160#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
1161#[serde(rename_all = "snake_case")]
1162pub enum ReasoningContext {
1163    Auto,
1164    CurrentTurn,
1165    AllTurns,
1166}
1167
1168/// o-series reasoning settings.
1169#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
1170#[serde(rename_all = "lowercase")]
1171pub enum Verbosity {
1172    Low,
1173    Medium,
1174    High,
1175}
1176
1177#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1178#[serde(rename_all = "lowercase")]
1179pub enum ReasoningSummary {
1180    Auto,
1181    Concise,
1182    Detailed,
1183}
1184
1185/// The retention policy for the prompt cache.
1186#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1187pub enum PromptCacheRetention {
1188    #[serde(rename = "in_memory")]
1189    InMemory,
1190    #[serde(rename = "24h")]
1191    Hours24,
1192}
1193
1194/// The detail level of a file input sent to the model.
1195#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1196#[serde(rename_all = "lowercase")]
1197pub enum FileInputDetail {
1198    Low,
1199    High,
1200    Auto,
1201}
1202
1203/// Configuration for text response format.
1204#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1205pub struct ResponseTextParam {
1206    /// An object specifying the format that the model must output.
1207    ///
1208    /// Configuring `{ "type": "json_schema" }` enables Structured Outputs,
1209    /// which ensures the model will match your supplied JSON schema. Learn more in the
1210    /// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
1211    ///
1212    /// The default format is `{ "type": "text" }` with no additional options.
1213    ///
1214    /// **Not recommended for gpt-4o and newer models:**
1215    ///
1216    /// Setting to `{ "type": "json_object" }` enables the older JSON mode, which
1217    /// ensures the message the model generates is valid JSON. Using `json_schema`
1218    /// is preferred for models that support it.
1219    #[serde(default)]
1220    pub format: TextResponseFormatConfiguration,
1221
1222    /// Constrains the verbosity of the model's response. Lower values will result in
1223    /// more concise responses, while higher values will result in more verbose responses.
1224    ///
1225    /// Currently supported values are `low`, `medium`, and `high`.
1226    #[serde(skip_serializing_if = "Option::is_none")]
1227    pub verbosity: Option<Verbosity>,
1228}
1229
1230#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Default)]
1231#[serde(tag = "type", rename_all = "snake_case")]
1232pub enum TextResponseFormatConfiguration {
1233    /// Default response format. Used to generate text responses.
1234    #[default]
1235    Text,
1236    /// JSON object response format. An older method of generating JSON responses.
1237    /// Using `json_schema` is recommended for models that support it.
1238    /// Note that the model will not generate JSON without a system or user message
1239    /// instructing it to do so.
1240    JsonObject,
1241    /// JSON Schema response format. Used to generate structured JSON responses.
1242    /// Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
1243    JsonSchema(ResponseFormatJsonSchema),
1244}
1245
1246/// Definitions for model-callable tools.
1247#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1248#[serde(tag = "type", rename_all = "snake_case")]
1249pub enum Tool {
1250    /// Defines a function in your own code the model can choose to call. Learn more about [function
1251    /// calling](https://platform.openai.com/docs/guides/tools).
1252    Function(FunctionTool),
1253    /// A tool that searches for relevant content from uploaded files. Learn more about the [file search
1254    /// tool](https://platform.openai.com/docs/guides/tools-file-search).
1255    FileSearch(FileSearchTool),
1256    /// A tool that controls a virtual computer. Learn more about the [computer
1257    /// use tool](https://platform.openai.com/docs/guides/tools-computer-use).
1258    ComputerUsePreview(ComputerUsePreviewTool),
1259    /// Search the Internet for sources related to the prompt. Learn more about the
1260    /// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
1261    WebSearch(WebSearchTool),
1262    /// type: web_search_2025_08_26
1263    #[serde(rename = "web_search_2025_08_26")]
1264    WebSearch20250826(WebSearchTool),
1265    /// Give the model access to additional tools via remote Model Context Protocol
1266    /// (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
1267    Mcp(MCPTool),
1268    /// A tool that runs Python code to help generate a response to a prompt.
1269    CodeInterpreter(CodeInterpreterTool),
1270
1271    ProgrammaticToolCalling,
1272    /// A tool that generates images using a model like `gpt-image-1`.
1273    ImageGeneration(ImageGenTool),
1274    /// A tool that allows the model to execute shell commands in a local environment.
1275    LocalShell,
1276    /// A tool that allows the model to execute shell commands.
1277    Shell(FunctionShellToolParam),
1278    /// A custom tool that processes input using a specified format. Learn more about   [custom
1279    /// tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
1280    Custom(CustomToolParam),
1281    /// A tool that controls a virtual computer. Learn more about the
1282    /// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
1283    Computer,
1284    /// Groups function/custom tools under a shared namespace.
1285    Namespace(NamespaceToolParam),
1286    /// Hosted or BYOT tool search configuration for deferred tools.
1287    ToolSearch(ToolSearchToolParam),
1288    /// This tool searches the web for relevant results to use in a response. Learn more about the [web search
1289    ///tool](https://platform.openai.com/docs/guides/tools-web-search).
1290    WebSearchPreview(WebSearchTool),
1291    /// type: web_search_preview_2025_03_11
1292    #[serde(rename = "web_search_preview_2025_03_11")]
1293    WebSearchPreview20250311(WebSearchTool),
1294    /// Allows the assistant to create, delete, or update files using unified diffs.
1295    ApplyPatch(ApplyPatchToolParam),
1296}
1297
1298#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1299pub struct CustomToolParam {
1300    /// The name of the custom tool, used to identify it in tool calls.
1301    pub name: String,
1302    /// Optional description of the custom tool, used to provide more context.
1303    pub description: Option<String>,
1304    /// The input format for the custom tool. Default is unconstrained text.
1305    pub format: CustomToolParamFormat,
1306    /// Whether this tool should be deferred and discovered via tool search.
1307    #[serde(skip_serializing_if = "Option::is_none")]
1308    pub defer_loading: Option<bool>,
1309    /// Whether the tool response can be returned asynchronously versus immediately returned on next
1310    /// response creation.
1311    #[serde(skip_serializing_if = "Option::is_none")]
1312    pub r#async: Option<bool>,
1313
1314    #[serde(skip_serializing_if = "Option::is_none")]
1315    pub allowed_callers: Option<Vec<CallableToolAllowedCaller>>,
1316}
1317
1318#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1319#[serde(tag = "type", rename_all = "lowercase")]
1320pub enum CustomToolParamFormat {
1321    /// Unconstrained free-form text.
1322    #[default]
1323    Text,
1324    /// A grammar defined by the user.
1325    Grammar(CustomGrammarFormatParam),
1326}
1327
1328#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1329#[builder(
1330    name = "FileSearchToolArgs",
1331    pattern = "mutable",
1332    setter(into, strip_option),
1333    default
1334)]
1335#[builder(build_fn(error = "OpenAIError"))]
1336pub struct FileSearchTool {
1337    /// The IDs of the vector stores to search.
1338    pub vector_store_ids: Vec<String>,
1339    /// The maximum number of results to return. This number should be between 1 and 50 inclusive.
1340    #[serde(skip_serializing_if = "Option::is_none")]
1341    pub max_num_results: Option<u32>,
1342    /// A filter to apply.
1343    #[serde(skip_serializing_if = "Option::is_none")]
1344    pub filters: Option<Filter>,
1345    /// Ranking options for search.
1346    #[serde(skip_serializing_if = "Option::is_none")]
1347    pub ranking_options: Option<RankingOptions>,
1348}
1349
1350#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1351#[builder(
1352    name = "FunctionToolArgs",
1353    pattern = "mutable",
1354    setter(into, strip_option),
1355    default
1356)]
1357pub struct FunctionTool {
1358    /// The name of the function to call.
1359    pub name: String,
1360    /// A JSON schema object describing the parameters of the function.
1361    #[serde(skip_serializing_if = "Option::is_none")]
1362    pub parameters: Option<serde_json::Value>,
1363    /// Whether to enforce strict parameter validation. Default `true`.
1364    #[serde(skip_serializing_if = "Option::is_none")]
1365    pub strict: Option<bool>,
1366    /// A description of the function. Used by the model to determine whether or not to call the
1367    /// function.
1368    #[serde(skip_serializing_if = "Option::is_none")]
1369    pub description: Option<String>,
1370    /// Whether this function is deferred and loaded via tool search.
1371    #[serde(skip_serializing_if = "Option::is_none")]
1372    pub defer_loading: Option<bool>,
1373    #[serde(skip_serializing_if = "Option::is_none")]
1374    pub r#async: Option<bool>,
1375
1376    #[serde(skip_serializing_if = "Option::is_none")]
1377    pub output_schema: Option<serde_json::Value>,
1378
1379    #[serde(skip_serializing_if = "Option::is_none")]
1380    pub allowed_callers: Option<Vec<CallableToolAllowedCaller>>,
1381}
1382
1383#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1384pub struct WebSearchToolFilters {
1385    /// Allowed domains for the search. If not provided, all domains are allowed.
1386    /// Subdomains of the provided domains are allowed as well.
1387    ///
1388    /// Example: `["pubmed.ncbi.nlm.nih.gov"]`
1389    #[serde(skip_serializing_if = "Option::is_none")]
1390    pub allowed_domains: Option<Vec<String>>,
1391}
1392
1393#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1394#[builder(
1395    name = "WebSearchToolArgs",
1396    pattern = "mutable",
1397    setter(into, strip_option),
1398    default
1399)]
1400pub struct WebSearchTool {
1401    /// Filters for the search.
1402    #[serde(skip_serializing_if = "Option::is_none")]
1403    pub filters: Option<WebSearchToolFilters>,
1404    /// The approximate location of the user. If omitted or null, defaults to the
1405    /// United States. To avoid this fallback, pass `{"type": "approximate"}` without
1406    /// location fields. To localize results, provide the relevant location fields.
1407    #[serde(skip_serializing_if = "Option::is_none")]
1408    pub user_location: Option<WebSearchApproximateLocation>,
1409    /// High level guidance for the amount of context window space to use for the search. One of `low`,
1410    /// `medium`, or `high`. `medium` is the default.
1411    #[serde(skip_serializing_if = "Option::is_none")]
1412    pub search_context_size: Option<WebSearchToolSearchContextSize>,
1413    /// The types of content to search for.
1414    #[serde(skip_serializing_if = "Option::is_none")]
1415    pub search_content_types: Option<Vec<SearchContentType>>,
1416    /// Allow live internet access for web search. Defaults to true when omitted. When false, the web search
1417    /// tool runs in offline/cache-only mode and will not fetch new external content.
1418    #[serde(skip_serializing_if = "Option::is_none")]
1419    pub external_web_access: Option<bool>,
1420}
1421
1422#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
1423#[serde(rename_all = "lowercase")]
1424pub enum WebSearchToolSearchContextSize {
1425    Low,
1426    #[default]
1427    Medium,
1428    High,
1429}
1430
1431#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
1432#[serde(rename_all = "lowercase")]
1433pub enum ComputerEnvironment {
1434    Windows,
1435    Mac,
1436    Linux,
1437    Ubuntu,
1438    #[default]
1439    Browser,
1440}
1441
1442#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1443#[builder(
1444    name = "ComputerUsePreviewToolArgs",
1445    pattern = "mutable",
1446    setter(into, strip_option),
1447    default
1448)]
1449pub struct ComputerUsePreviewTool {
1450    /// The type of computer environment to control.
1451    environment: ComputerEnvironment,
1452    /// The width of the computer display.
1453    display_width: u32,
1454    /// The height of the computer display.
1455    display_height: u32,
1456}
1457
1458#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1459pub enum RankVersionType {
1460    #[serde(rename = "auto")]
1461    Auto,
1462    #[serde(rename = "default-2024-11-15")]
1463    Default20241115,
1464}
1465
1466#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1467pub struct HybridSearch {
1468    /// The weight of the embedding in the reciprocal ranking fusion.
1469    pub embedding_weight: f32,
1470    /// The weight of the text in the reciprocal ranking fusion.
1471    pub text_weight: f32,
1472}
1473
1474/// Options for search result ranking.
1475#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1476pub struct RankingOptions {
1477    /// Weights that control how reciprocal rank fusion balances semantic embedding matches versus
1478    /// sparse keyword matches when hybrid search is enabled.
1479    #[serde(skip_serializing_if = "Option::is_none")]
1480    pub hybrid_search: Option<HybridSearch>,
1481    /// The ranker to use for the file search.
1482    pub ranker: RankVersionType,
1483    /// The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will
1484    /// attempt to return only the most relevant results, but may return fewer results.
1485    #[serde(skip_serializing_if = "Option::is_none")]
1486    pub score_threshold: Option<f32>,
1487}
1488
1489#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
1490#[serde(rename_all = "lowercase")]
1491pub enum WebSearchApproximateLocationType {
1492    #[default]
1493    Approximate,
1494}
1495
1496/// Approximate user location for web search.
1497#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1498#[builder(
1499    name = "WebSearchApproximateLocationArgs",
1500    pattern = "mutable",
1501    setter(into, strip_option),
1502    default
1503)]
1504#[builder(build_fn(error = "OpenAIError"))]
1505pub struct WebSearchApproximateLocation {
1506    /// The type of location approximation. Defaults to `approximate` when omitted in JSON input.
1507    #[serde(default)]
1508    pub r#type: WebSearchApproximateLocationType,
1509    /// Free text input for the city of the user, e.g. `San Francisco`.
1510    #[serde(skip_serializing_if = "Option::is_none")]
1511    pub city: Option<String>,
1512    /// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user,
1513    /// e.g. `US`.
1514    #[serde(skip_serializing_if = "Option::is_none")]
1515    pub country: Option<String>,
1516    /// Free text input for the region of the user, e.g. `California`.
1517    #[serde(skip_serializing_if = "Option::is_none")]
1518    pub region: Option<String>,
1519    /// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g.
1520    /// `America/Los_Angeles`.
1521    #[serde(skip_serializing_if = "Option::is_none")]
1522    pub timezone: Option<String>,
1523}
1524
1525/// Container configuration for a code interpreter.
1526#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1527#[serde(tag = "type", rename_all = "snake_case")]
1528pub enum CodeInterpreterToolContainer {
1529    /// Configuration for a code interpreter container. Optionally specify the IDs of the
1530    /// files to run the code on.
1531    Auto(CodeInterpreterContainerAuto),
1532
1533    /// The container ID.
1534    #[serde(untagged)]
1535    ContainerID(String),
1536}
1537
1538/// Auto configuration for code interpreter container.
1539#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1540pub struct CodeInterpreterContainerAuto {
1541    /// An optional list of uploaded files to make available to your code.
1542    #[serde(skip_serializing_if = "Option::is_none")]
1543    pub file_ids: Option<Vec<String>>,
1544
1545    #[serde(skip_serializing_if = "Option::is_none")]
1546    pub memory_limit: Option<u64>,
1547}
1548
1549#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1550#[builder(
1551    name = "CodeInterpreterToolArgs",
1552    pattern = "mutable",
1553    setter(into, strip_option),
1554    default
1555)]
1556#[builder(build_fn(error = "OpenAIError"))]
1557pub struct CodeInterpreterTool {
1558    /// The code interpreter container. Can be a container ID or an object that
1559    /// specifies uploaded file IDs to make available to your code, along with an
1560    /// optional `memory_limit` setting.
1561    pub container: CodeInterpreterToolContainer,
1562    #[serde(skip_serializing_if = "Option::is_none")]
1563    pub allowed_callers: Option<Vec<CallableToolAllowedCaller>>,
1564}
1565
1566#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1567pub struct ImageGenToolInputImageMask {
1568    /// Base64-encoded mask image.
1569    #[serde(skip_serializing_if = "Option::is_none")]
1570    pub image_url: Option<String>,
1571    /// File ID for the mask image.
1572    #[serde(skip_serializing_if = "Option::is_none")]
1573    pub file_id: Option<String>,
1574}
1575
1576#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1577#[serde(rename_all = "lowercase")]
1578pub enum InputFidelity {
1579    #[default]
1580    High,
1581    Low,
1582}
1583
1584#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1585#[serde(rename_all = "lowercase")]
1586pub enum ImageGenToolModeration {
1587    #[default]
1588    Auto,
1589    Low,
1590}
1591
1592/// Whether to generate a new image or edit an existing image.
1593#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1594#[serde(rename_all = "lowercase")]
1595pub enum ImageGenActionEnum {
1596    /// Generate a new image.
1597    Generate,
1598    /// Edit an existing image.
1599    Edit,
1600    /// Automatically determine whether to generate or edit.
1601    #[default]
1602    Auto,
1603}
1604
1605/// Image generation tool definition.
1606#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1607#[builder(
1608    name = "ImageGenerationArgs",
1609    pattern = "mutable",
1610    setter(into, strip_option),
1611    default
1612)]
1613#[builder(build_fn(error = "OpenAIError"))]
1614pub struct ImageGenTool {
1615    /// Set the background of the generated image. One of `transparent`,
1616    /// `opaque`, or `auto`. Transparent backgrounds are available for
1617    /// supported GPT Image models. For `gpt-image-2` and
1618    /// `gpt-image-2-2026-04-21`, this support is in preview. When using
1619    /// `transparent`, set the output format to `png` or `webp`. Default: `auto`.
1620    #[serde(skip_serializing_if = "Option::is_none")]
1621    pub background: Option<ImageGenToolBackground>,
1622    /// Control how much effort the model will exert to match the style and features, especially facial features,
1623    /// of input images. This parameter is only supported for `gpt-image-1`. Unsupported
1624    /// for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.
1625    #[serde(skip_serializing_if = "Option::is_none")]
1626    pub input_fidelity: Option<InputFidelity>,
1627    /// Optional mask for inpainting. Contains `image_url`
1628    /// (string, optional) and `file_id` (string, optional).
1629    #[serde(skip_serializing_if = "Option::is_none")]
1630    pub input_image_mask: Option<ImageGenToolInputImageMask>,
1631    /// The image generation model to use. Default: `gpt-image-1`.
1632    #[serde(skip_serializing_if = "Option::is_none")]
1633    pub model: Option<String>,
1634    /// Moderation level for the generated image. Default: `auto`.
1635    #[serde(skip_serializing_if = "Option::is_none")]
1636    pub moderation: Option<ImageGenToolModeration>,
1637    /// Compression level for the output image. Default: 100.
1638    #[serde(skip_serializing_if = "Option::is_none")]
1639    pub output_compression: Option<u8>,
1640    /// The output format of the generated image. One of `png`, `webp`, or
1641    /// `jpeg`. Default: `png`.
1642    #[serde(skip_serializing_if = "Option::is_none")]
1643    pub output_format: Option<ImageGenToolOutputFormat>,
1644    /// Number of partial images to generate in streaming mode, from 0 (default value) to 3.
1645    #[serde(skip_serializing_if = "Option::is_none")]
1646    pub partial_images: Option<u8>,
1647    /// The quality of the generated image. One of `low`, `medium`, `high`,
1648    /// `xhigh`, `max`, or `auto`. Default: `auto`.
1649    #[serde(skip_serializing_if = "Option::is_none")]
1650    pub quality: Option<ImageGenToolQuality>,
1651    /// The size of the generated images. For `gpt-image-2`, `gpt-image-2-2026-04-21`,
1652    /// `gpt-image-2.5-sunburst`, `gpt-image-2.5-sunburst-2026-09-08`, `gpt-image-2.5-flare`, and
1653    /// `gpt-image-2.5-flare-2026-09-08`, arbitrary resolutions are supported as `WIDTHxHEIGHT` strings, for
1654    /// example `1536x864`. Width and height must both be divisible by 16 and the requested aspect ratio
1655    /// must be between 1:3 and 3:1. Resolutions above `2560x1440` are experimental, and the maximum
1656    /// supported resolution is `3840x2160`. The requested size must also satisfy the model's current pixel
1657    /// and edge limits. The standard sizes `1024x1024`, `1536x1024`, and `1024x1536` are supported by the
1658    /// GPT image models; `auto` is supported for models that allow automatic sizing.
1659    #[serde(skip_serializing_if = "Option::is_none")]
1660    pub size: Option<ImageGenToolSize>,
1661    /// Whether to generate a new image or edit an existing image. Default: `auto`.
1662    #[serde(skip_serializing_if = "Option::is_none")]
1663    pub action: Option<ImageGenActionEnum>,
1664}
1665
1666#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1667#[serde(rename_all = "lowercase")]
1668pub enum ImageGenToolBackground {
1669    Transparent,
1670    Opaque,
1671    #[default]
1672    Auto,
1673}
1674
1675#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1676#[serde(rename_all = "lowercase")]
1677pub enum ImageGenToolOutputFormat {
1678    #[default]
1679    Png,
1680    Webp,
1681    Jpeg,
1682}
1683
1684#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1685#[serde(rename_all = "lowercase")]
1686pub enum ImageGenToolQuality {
1687    Low,
1688    Medium,
1689    High,
1690    XHigh,
1691    Max,
1692    #[default]
1693    Auto,
1694}
1695
1696#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1697#[serde(rename_all = "lowercase")]
1698pub enum ImageGenToolSize {
1699    #[default]
1700    Auto,
1701    #[serde(rename = "1024x1024")]
1702    Size1024x1024,
1703    #[serde(rename = "1024x1536")]
1704    Size1024x1536,
1705    #[serde(rename = "1536x1024")]
1706    Size1536x1024,
1707    #[serde(untagged)]
1708    Other(String),
1709}
1710
1711#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1712#[serde(rename_all = "lowercase")]
1713pub enum ToolChoiceAllowedMode {
1714    Auto,
1715    Required,
1716}
1717
1718#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1719pub struct ToolChoiceAllowed {
1720    /// Constrains the tools available to the model to a pre-defined set.
1721    ///
1722    /// `auto` allows the model to pick from among the allowed tools and generate a
1723    /// message.
1724    ///
1725    /// `required` requires the model to call one or more of the allowed tools.
1726    pub mode: ToolChoiceAllowedMode,
1727    /// A list of tool definitions that the model should be allowed to call.
1728    ///
1729    /// For the Responses API, the list of tool definitions might look like:
1730    /// ```json
1731    /// [
1732    ///   { "type": "function", "name": "get_weather" },
1733    ///   { "type": "mcp", "server_label": "deepwiki" },
1734    ///   { "type": "image_generation" }
1735    /// ]
1736    /// ```
1737    pub tools: Vec<serde_json::Value>,
1738}
1739
1740/// The type of hosted tool the model should to use. Learn more about
1741/// [built-in tools](https://platform.openai.com/docs/guides/tools).
1742#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1743#[serde(tag = "type", rename_all = "snake_case")]
1744pub enum ToolChoiceTypes {
1745    FileSearch,
1746    WebSearchPreview,
1747    Computer,
1748    ComputerUsePreview,
1749    ComputerUse,
1750    #[serde(rename = "web_search_preview_2025_03_11")]
1751    WebSearchPreview20250311,
1752    CodeInterpreter,
1753    ImageGeneration,
1754}
1755
1756#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1757pub struct ToolChoiceFunction {
1758    /// The name of the function to call.
1759    pub name: String,
1760}
1761
1762#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1763pub struct ToolChoiceMCP {
1764    /// The name of the tool to call on the server.
1765    pub name: String,
1766    /// The label of the MCP server to use.
1767    pub server_label: String,
1768}
1769
1770#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1771pub struct ToolChoiceCustom {
1772    /// The name of the custom tool to call.
1773    pub name: String,
1774}
1775
1776#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1777#[serde(tag = "type", rename_all = "snake_case")]
1778pub enum ToolChoiceParam {
1779    /// Constrains the tools available to the model to a pre-defined set.
1780    AllowedTools(ToolChoiceAllowed),
1781
1782    /// Use this option to force the model to call a specific function.
1783    Function(ToolChoiceFunction),
1784
1785    /// Use this option to force the model to call a specific tool on a remote MCP server.
1786    Mcp(ToolChoiceMCP),
1787
1788    /// Use this option to force the model to call a custom tool.
1789    Custom(ToolChoiceCustom),
1790
1791    ProgrammaticToolCalling,
1792
1793    /// Forces the model to call the apply_patch tool when executing a tool call.
1794    ApplyPatch,
1795
1796    /// Forces the model to call the function shell tool when a tool call is required.
1797    Shell,
1798
1799    /// Indicates that the model should use a built-in tool to generate a response.
1800    /// [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
1801    #[serde(untagged)]
1802    BuiltIn(ToolChoiceTypes),
1803
1804    /// Controls which (if any) tool is called by the model.
1805    ///
1806    /// `none` means the model will not call any tool and instead generates a message.
1807    ///
1808    /// `auto` means the model can pick between generating a message or calling one or
1809    /// more tools.
1810    ///
1811    /// `required` means the model must call one or more tools.
1812    #[serde(untagged)]
1813    Option(ToolChoiceOptions),
1814}
1815
1816#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1817#[serde(rename_all = "lowercase")]
1818pub enum ToolChoiceOptions {
1819    None,
1820    Auto,
1821    Required,
1822}
1823
1824#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1825#[serde(rename_all = "snake_case")]
1826pub enum ResponseErrorCode {
1827    ServerError,
1828    RateLimitExceeded,
1829    InvalidPrompt,
1830    DataResidencyMismatch,
1831    BioPolicy,
1832    MisalignmentPolicyViolation,
1833    VectorStoreTimeout,
1834    InvalidImage,
1835    InvalidImageFormat,
1836    InvalidBase64Image,
1837    InvalidImageUrl,
1838    ImageTooLarge,
1839    ImageTooSmall,
1840    ImageParseError,
1841    ImageContentPolicyViolation,
1842    InvalidImageMode,
1843    ImageFileTooLarge,
1844    UnsupportedImageMediaType,
1845    EmptyImageFile,
1846    FailedToDownloadImage,
1847    ImageFileNotFound,
1848    #[serde(untagged)]
1849    Other(String),
1850}
1851
1852/// An error that occurred while generating the response.
1853#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1854pub struct ResponseError {
1855    /// A machine-readable error code that was returned.
1856    pub code: ResponseErrorCode,
1857    /// A human-readable description of the error that was returned.
1858    pub message: String,
1859    #[serde(skip_serializing_if = "Option::is_none")]
1860    pub misalignment: Option<MisalignmentErrorDetailsResource>,
1861    /// The related request parameter.
1862    #[serde(skip_serializing_if = "Option::is_none")]
1863    pub param: Option<String>,
1864    /// The error type.
1865    #[serde(skip_serializing_if = "Option::is_none")]
1866    pub r#type: Option<String>,
1867}
1868
1869/// Details about an incomplete response.
1870#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1871pub struct IncompleteDetails {
1872    /// The reason why the response is incomplete.
1873    pub reason: String,
1874}
1875
1876#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1877pub struct TopLogProb {
1878    pub bytes: Vec<u8>,
1879    pub logprob: f64,
1880    pub token: String,
1881}
1882
1883#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1884pub struct LogProb {
1885    pub bytes: Vec<u8>,
1886    pub logprob: f64,
1887    pub token: String,
1888    pub top_logprobs: Vec<TopLogProb>,
1889}
1890
1891#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1892pub struct ResponseTopLobProb {
1893    /// The log probability of this token.
1894    pub logprob: f64,
1895    /// A possible text token.
1896    pub token: String,
1897}
1898
1899#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1900pub struct ResponseLogProb {
1901    /// The log probability of this token.
1902    pub logprob: f64,
1903    /// A possible text token.
1904    pub token: String,
1905    /// The log probability of the top 20 most likely tokens.
1906    pub top_logprobs: Vec<ResponseTopLobProb>,
1907}
1908
1909/// A simple text output from the model.
1910#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1911pub struct OutputTextContent {
1912    /// The annotations of the text output.
1913    pub annotations: Vec<Annotation>,
1914    pub logprobs: Option<Vec<LogProb>>,
1915    /// The text output from the model.
1916    pub text: String,
1917}
1918
1919/// An annotation that applies to a span of output text.
1920#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1921#[serde(tag = "type", rename_all = "snake_case")]
1922pub enum Annotation {
1923    /// A citation to a file.
1924    FileCitation(FileCitationBody),
1925    /// A citation for a web resource used to generate a model response.
1926    UrlCitation(UrlCitationBody),
1927    /// A citation for a container file used to generate a model response.
1928    ContainerFileCitation(ContainerFileCitationBody),
1929    /// A path to a file.
1930    FilePath(FilePath),
1931}
1932
1933#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1934pub struct FileCitationBody {
1935    /// The ID of the file.
1936    file_id: String,
1937    /// The filename of the file cited.
1938    filename: String,
1939    /// The index of the file in the list of files.
1940    index: u32,
1941}
1942
1943#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1944pub struct UrlCitationBody {
1945    /// The index of the last character of the URL citation in the message.
1946    end_index: u32,
1947    /// The index of the first character of the URL citation in the message.
1948    start_index: u32,
1949    /// The title of the web resource.
1950    title: String,
1951    /// The URL of the web resource.
1952    url: String,
1953}
1954
1955#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1956pub struct ContainerFileCitationBody {
1957    /// The ID of the container file.
1958    container_id: String,
1959    /// The index of the last character of the container file citation in the message.
1960    end_index: u32,
1961    /// The ID of the file.
1962    file_id: String,
1963    /// The filename of the container file cited.
1964    filename: String,
1965    /// The index of the first character of the container file citation in the message.
1966    start_index: u32,
1967}
1968
1969#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1970pub struct FilePath {
1971    /// The ID of the file.
1972    file_id: String,
1973    /// The index of the file in the list of files.
1974    index: u32,
1975}
1976
1977/// A refusal explanation from the model.
1978#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1979pub struct RefusalContent {
1980    /// The refusal explanation from the model.
1981    pub refusal: String,
1982}
1983
1984/// A message generated by the model.
1985#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1986pub struct OutputMessage {
1987    /// The content of the output message.
1988    pub content: Vec<OutputMessageContent>,
1989    /// The unique ID of the output message.
1990    pub id: String,
1991    /// The role of the output message. Always `assistant`.
1992    pub role: AssistantRole,
1993    /// Labels this assistant message as intermediate commentary (`commentary`) or
1994    /// the final answer (`final_answer`).
1995    #[serde(skip_serializing_if = "Option::is_none")]
1996    pub phase: Option<MessagePhase>,
1997    /// The status of the message input. One of `in_progress`, `completed`, or
1998    /// `incomplete`. Populated when input items are returned via API.
1999    pub status: OutputStatus,
2000    ///// The type of the output message. Always `message`.
2001    //pub r#type: MessageType,
2002}
2003
2004#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2005#[serde(rename_all = "lowercase")]
2006pub enum MessageType {
2007    #[default]
2008    Message,
2009}
2010
2011/// The role for an output message - always `assistant`.
2012/// This type ensures type safety by only allowing the assistant role.
2013#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
2014#[serde(rename_all = "lowercase")]
2015pub enum AssistantRole {
2016    #[default]
2017    Assistant,
2018}
2019
2020#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2021#[serde(tag = "type", rename_all = "snake_case")]
2022pub enum OutputMessageContent {
2023    /// A text output from the model.
2024    OutputText(OutputTextContent),
2025    /// A refusal from the model.
2026    Refusal(RefusalContent),
2027}
2028
2029#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2030#[serde(tag = "type", rename_all = "snake_case")]
2031pub enum OutputContent {
2032    /// A text output from the model.
2033    OutputText(OutputTextContent),
2034    /// A refusal from the model.
2035    Refusal(RefusalContent),
2036    /// Reasoning text from the model.
2037    ReasoningText(ReasoningTextContent),
2038}
2039
2040#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2041pub struct ReasoningTextContent {
2042    /// The reasoning text from the model.
2043    pub text: String,
2044}
2045
2046/// [ReasoningTextContent] used elsewhere which adds type,
2047/// but here in [ReasoningItem] content field we need type too hence an enum:
2048#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2049#[serde(tag = "type", rename_all = "snake_case")]
2050pub enum ReasoningItemContent {
2051    ReasoningText(ReasoningTextContent),
2052}
2053
2054/// A reasoning item representing the model's chain of thought, including summary paragraphs.
2055#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2056pub struct ReasoningItem {
2057    /// Unique identifier of the reasoning content.
2058    pub id: Option<String>,
2059    /// Reasoning summary content.
2060    pub summary: Vec<SummaryPart>,
2061    /// Reasoning text content.
2062    #[serde(skip_serializing_if = "Option::is_none")]
2063    pub content: Option<Vec<ReasoningItemContent>>,
2064    /// The encrypted content of the reasoning item - populated when a response is generated with
2065    /// `reasoning.encrypted_content` in the `include` parameter.
2066    #[serde(skip_serializing_if = "Option::is_none")]
2067    pub encrypted_content: Option<String>,
2068    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2069    /// Populated when items are returned via API.
2070    #[serde(skip_serializing_if = "Option::is_none")]
2071    pub status: Option<OutputStatus>,
2072}
2073
2074#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2075#[serde(tag = "type", rename_all = "snake_case")]
2076pub enum SummaryPart {
2077    SummaryText(SummaryTextContent),
2078}
2079
2080/// File search tool call output.
2081#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2082pub struct FileSearchToolCall {
2083    /// The unique ID of the file search tool call.
2084    pub id: String,
2085    /// The queries used to search for files.
2086    pub queries: Vec<String>,
2087    /// The status of the file search tool call. One of `in_progress`, `searching`,
2088    /// `incomplete`,`failed`, or `completed`.
2089    pub status: FileSearchToolCallStatus,
2090    /// The results of the file search tool call.
2091    #[serde(skip_serializing_if = "Option::is_none")]
2092    pub results: Option<Vec<FileSearchToolCallResult>>,
2093}
2094
2095#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2096#[serde(rename_all = "snake_case")]
2097pub enum FileSearchToolCallStatus {
2098    InProgress,
2099    Searching,
2100    Incomplete,
2101    Failed,
2102    Completed,
2103}
2104
2105/// A single result from a file search.
2106#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2107pub struct FileSearchToolCallResult {
2108    /// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
2109    /// additional information about the object in a structured format, and querying for objects
2110    /// API or the dashboard. Keys are strings with a maximum length of 64 characters
2111    /// . Values are strings with a maximum length of 512 characters, booleans, or numbers.
2112    pub attributes: HashMap<String, serde_json::Value>,
2113    /// The unique ID of the file.
2114    pub file_id: String,
2115    /// The name of the file.
2116    pub filename: String,
2117    /// The relevance score of the file - a value between 0 and 1.
2118    pub score: f32,
2119    /// The text that was retrieved from the file.
2120    pub text: String,
2121}
2122
2123#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2124pub struct ComputerCallSafetyCheckParam {
2125    /// The ID of the pending safety check.
2126    pub id: String,
2127    /// The type of the pending safety check.
2128    #[serde(skip_serializing_if = "Option::is_none")]
2129    pub code: Option<String>,
2130    /// Details about the pending safety check.
2131    #[serde(skip_serializing_if = "Option::is_none")]
2132    pub message: Option<String>,
2133}
2134
2135#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2136#[serde(rename_all = "snake_case")]
2137pub enum WebSearchCallStatus {
2138    InProgress,
2139    Searching,
2140    Completed,
2141    Failed,
2142    Incomplete,
2143}
2144
2145#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2146pub struct WebSearchActionSearchSource {
2147    /// The type of source. Always `url`.
2148    pub r#type: String,
2149    /// The URL of the source.
2150    pub url: String,
2151}
2152
2153#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2154pub struct WebSearchActionSearch {
2155    /// The search query.
2156    #[deprecated(note = "Use queries instead.")]
2157    #[serde(skip_serializing_if = "Option::is_none")]
2158    pub query: Option<String>,
2159
2160    /// Search queries
2161    pub queries: Option<Vec<String>>,
2162    /// The sources used in the search.
2163    pub sources: Option<Vec<WebSearchActionSearchSource>>,
2164}
2165
2166#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2167pub struct WebSearchActionOpenPage {
2168    /// The URL opened by the model.
2169    pub url: Option<String>,
2170}
2171
2172#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2173pub struct WebSearchActionFind {
2174    /// The URL of the page searched for the pattern, when available.
2175    pub url: Option<String>,
2176    /// The pattern or text to search for within the page.
2177    pub pattern: String,
2178}
2179
2180#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2181#[serde(tag = "type", rename_all = "snake_case")]
2182pub enum WebSearchToolCallAction {
2183    /// Action type "search" - Performs a web search query.
2184    Search(WebSearchActionSearch),
2185    /// Action type "open_page" - Opens a specific URL from search results.
2186    OpenPage(WebSearchActionOpenPage),
2187    /// Action type "find": Searches for a pattern within a loaded page.
2188    Find(WebSearchActionFind),
2189    /// Action type "find_in_page": <https://platform.openai.com/docs/guides/tools-web-search#output-and-citations>
2190    FindInPage(WebSearchActionFind),
2191}
2192
2193/// Web search tool call output.
2194#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2195pub struct WebSearchToolCall {
2196    /// An object describing the specific action taken in this web search call. Includes
2197    /// details on how the model used the web (search, open_page, find, find_in_page).
2198    ///
2199    /// This is optional because `response.output_item.added` events can include
2200    /// in-progress web search calls before OpenAI has populated the action.
2201    /// See <https://github.com/64bit/async-openai/issues/548>.
2202    #[serde(skip_serializing_if = "Option::is_none")]
2203    pub action: Option<WebSearchToolCallAction>,
2204    /// The unique ID of the web search tool call.
2205    pub id: String,
2206    /// The status of the web search tool call.
2207    pub status: WebSearchCallStatus,
2208}
2209
2210/// Output from a computer tool call.
2211#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2212pub struct ComputerToolCall {
2213    #[serde(skip_serializing_if = "Option::is_none")]
2214    pub action: Option<ComputerAction>,
2215    /// Flattened batched actions for `computer_use`. Each action includes a
2216    /// `type` discriminator and action-specific fields.
2217    #[serde(skip_serializing_if = "Option::is_none")]
2218    pub actions: Option<Vec<ComputerAction>>,
2219    /// An identifier used when responding to the tool call with output.
2220    pub call_id: String,
2221    /// The unique ID of the computer call.
2222    pub id: String,
2223    /// The pending safety checks for the computer call.
2224    pub pending_safety_checks: Vec<ComputerCallSafetyCheckParam>,
2225    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2226    /// Populated when items are returned via API.
2227    pub status: OutputStatus,
2228}
2229
2230/// An x/y coordinate pair.
2231#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2232pub struct CoordParam {
2233    /// The x-coordinate.
2234    pub x: i32,
2235    /// The y-coordinate.
2236    pub y: i32,
2237}
2238
2239/// Represents all user‐triggered actions.
2240#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2241#[serde(tag = "type", rename_all = "snake_case")]
2242pub enum ComputerAction {
2243    /// A click action.
2244    Click(ClickParam),
2245
2246    /// A double click action.
2247    DoubleClick(DoubleClickAction),
2248
2249    /// A drag action.
2250    Drag(DragParam),
2251
2252    /// A collection of keypresses the model would like to perform.
2253    Keypress(KeyPressAction),
2254
2255    /// A mouse move action.
2256    Move(MoveParam),
2257
2258    /// A screenshot action.
2259    Screenshot,
2260
2261    /// A scroll action.
2262    Scroll(ScrollParam),
2263
2264    /// An action to type in text.
2265    Type(TypeParam),
2266
2267    /// A wait action.
2268    Wait,
2269}
2270
2271#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2272#[serde(rename_all = "lowercase")]
2273pub enum ClickButtonType {
2274    Left,
2275    Right,
2276    Wheel,
2277    Back,
2278    Forward,
2279}
2280
2281/// A click action.
2282#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2283pub struct ClickParam {
2284    /// Indicates which mouse button was pressed during the click. One of `left`,
2285    /// `right`, `wheel`, `back`, or `forward`.
2286    pub button: ClickButtonType,
2287    /// The x-coordinate where the click occurred.
2288    pub x: i32,
2289    /// The y-coordinate where the click occurred.
2290    pub y: i32,
2291    /// The keys being held while clicking.
2292    #[serde(skip_serializing_if = "Option::is_none")]
2293    pub keys: Option<Vec<String>>,
2294}
2295
2296/// A double click action.
2297#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2298pub struct DoubleClickAction {
2299    /// The x-coordinate where the double click occurred.
2300    pub x: i32,
2301    /// The y-coordinate where the double click occurred.
2302    pub y: i32,
2303    /// The keys being held while double clicking.
2304    pub keys: Option<Vec<String>>,
2305}
2306
2307/// A drag action.
2308#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2309pub struct DragParam {
2310    /// An array of coordinates representing the path of the drag action.
2311    pub path: Vec<CoordParam>,
2312    /// The keys being held while dragging the mouse.
2313    #[serde(skip_serializing_if = "Option::is_none")]
2314    pub keys: Option<Vec<String>>,
2315}
2316
2317/// A keypress action.
2318#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2319pub struct KeyPressAction {
2320    /// The combination of keys the model is requesting to be pressed.
2321    /// This is an array of strings, each representing a key.
2322    pub keys: Vec<String>,
2323}
2324
2325/// A mouse move action.
2326#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2327pub struct MoveParam {
2328    /// The x-coordinate to move to.
2329    pub x: i32,
2330    /// The y-coordinate to move to.
2331    pub y: i32,
2332    /// The keys being held while moving the mouse.
2333    #[serde(skip_serializing_if = "Option::is_none")]
2334    pub keys: Option<Vec<String>>,
2335}
2336
2337/// A scroll action.
2338#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2339pub struct ScrollParam {
2340    /// The horizontal scroll distance.
2341    pub scroll_x: i32,
2342    /// The vertical scroll distance.
2343    pub scroll_y: i32,
2344    /// The x-coordinate where the scroll occurred.
2345    pub x: i32,
2346    /// The y-coordinate where the scroll occurred.
2347    pub y: i32,
2348    /// The keys being held while scrolling.
2349    #[serde(skip_serializing_if = "Option::is_none")]
2350    pub keys: Option<Vec<String>>,
2351}
2352
2353/// A typing (text entry) action.
2354#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
2355pub struct TypeParam {
2356    /// The text to type.
2357    pub text: String,
2358}
2359
2360#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2361pub struct FunctionToolCall {
2362    /// A JSON string of the arguments to pass to the function.
2363    pub arguments: String,
2364    /// The unique ID of the function tool call generated by the model.
2365    pub call_id: String,
2366    /// The namespace of the function to run.
2367    #[serde(skip_serializing_if = "Option::is_none")]
2368    pub namespace: Option<String>,
2369    /// The name of the function to run.
2370    pub name: String,
2371    /// The unique ID of the function tool call.
2372    #[serde(skip_serializing_if = "Option::is_none")]
2373    pub id: Option<String>,
2374    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2375    /// Populated when items are returned via API.
2376    #[serde(skip_serializing_if = "Option::is_none")]
2377    pub status: Option<OutputStatus>,
2378    #[serde(skip_serializing_if = "Option::is_none")]
2379    pub caller: Option<ToolCallCaller>,
2380    /// Whether the function tool call runs asynchronously.
2381    #[serde(skip_serializing_if = "Option::is_none")]
2382    pub r#async: Option<bool>,
2383}
2384
2385/// A function tool call item returned by the API.
2386#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2387pub struct FunctionToolCallResource {
2388    /// A JSON string of the arguments to pass to the function.
2389    pub arguments: String,
2390    /// The unique ID of the function tool call generated by the model.
2391    pub call_id: String,
2392    /// The namespace of the function to run.
2393    #[serde(skip_serializing_if = "Option::is_none")]
2394    pub namespace: Option<String>,
2395    /// The name of the function to run.
2396    pub name: String,
2397    /// The unique ID of the function tool call.
2398    pub id: String,
2399    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2400    pub status: FunctionCallStatus,
2401    /// The identifier of the actor that created the item.
2402    #[serde(skip_serializing_if = "Option::is_none")]
2403    pub created_by: Option<String>,
2404    #[serde(skip_serializing_if = "Option::is_none")]
2405    pub caller: Option<ToolCallCaller>,
2406    /// Whether the function tool call runs asynchronously.
2407    #[serde(skip_serializing_if = "Option::is_none")]
2408    pub r#async: Option<bool>,
2409}
2410
2411/// A function tool call output item returned by the API.
2412#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2413pub struct FunctionToolCallOutputResource {
2414    /// The unique ID of the function tool call generated by the model.
2415    #[serde(skip_serializing_if = "Option::is_none")]
2416    pub call_id: Option<String>,
2417    /// Text, image, or file output of the function tool call.
2418    pub output: FunctionCallOutput,
2419    /// The unique ID of the function tool call output.
2420    pub id: String,
2421    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2422    pub status: FunctionCallOutputStatusEnum,
2423    /// The identifier of the actor that created the item.
2424    #[serde(skip_serializing_if = "Option::is_none")]
2425    pub created_by: Option<String>,
2426    /// The name of the tool that produced the output.
2427    #[serde(skip_serializing_if = "Option::is_none")]
2428    pub name: Option<String>,
2429    /// The namespace of the tool that produced the output.
2430    #[serde(skip_serializing_if = "Option::is_none")]
2431    pub namespace: Option<String>,
2432    #[serde(skip_serializing_if = "Option::is_none")]
2433    pub caller: Option<ToolCallCaller>,
2434}
2435
2436#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2437#[serde(rename_all = "snake_case")]
2438pub enum ImageGenToolCallStatus {
2439    InProgress,
2440    Completed,
2441    Generating,
2442    Failed,
2443}
2444
2445#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2446pub struct ImageGenToolCall {
2447    /// The unique ID of the image generation call.
2448    pub id: String,
2449    /// The generated image encoded in base64.
2450    pub result: Option<String>,
2451    /// The status of the image generation call.
2452    pub status: ImageGenToolCallStatus,
2453    /// The image dimensions as a `WIDTHxHEIGHT` string, for example `1536x864`.
2454    #[serde(skip_serializing_if = "Option::is_none")]
2455    pub size: Option<ImageGenToolSize>,
2456    /// The quality of the image generated by the image generation tool call.
2457    #[serde(skip_serializing_if = "Option::is_none")]
2458    pub quality: Option<ImageGenToolQuality>,
2459    /// The background used for the generated image.
2460    #[serde(skip_serializing_if = "Option::is_none")]
2461    pub background: Option<ImageGenToolBackground>,
2462    /// The output format.
2463    #[serde(skip_serializing_if = "Option::is_none")]
2464    pub output_format: Option<ImageGenToolOutputFormat>,
2465    /// The action performed.
2466    #[serde(skip_serializing_if = "Option::is_none")]
2467    pub action: Option<ImageGenActionEnum>,
2468    /// The revised prompt.
2469    #[serde(skip_serializing_if = "Option::is_none")]
2470    pub revised_prompt: Option<String>,
2471    /// Details of a moderation failure, when available.
2472    #[serde(skip_serializing_if = "Option::is_none")]
2473    pub error: Option<ImageGenToolCallError>,
2474}
2475
2476#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2477#[serde(rename_all = "snake_case")]
2478pub enum CodeInterpreterToolCallStatus {
2479    InProgress,
2480    Completed,
2481    Incomplete,
2482    Interpreting,
2483    Failed,
2484}
2485
2486/// Output of a code interpreter request.
2487#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2488pub struct CodeInterpreterToolCall {
2489    /// The code to run, or null if not available.
2490    #[serde(skip_serializing_if = "Option::is_none")]
2491    pub code: Option<String>,
2492    /// ID of the container used to run the code.
2493    pub container_id: String,
2494    /// The unique ID of the code interpreter tool call.
2495    pub id: String,
2496    /// The outputs generated by the code interpreter, such as logs or images.
2497    /// Can be null if no outputs are available.
2498    #[serde(skip_serializing_if = "Option::is_none")]
2499    pub outputs: Option<Vec<CodeInterpreterToolCallOutput>>,
2500    /// The status of the code interpreter tool call.
2501    /// Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.
2502    pub status: CodeInterpreterToolCallStatus,
2503}
2504
2505/// Individual result from a code interpreter: either logs or files.
2506#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2507#[serde(tag = "type", rename_all = "snake_case")]
2508pub enum CodeInterpreterToolCallOutput {
2509    /// Code interpreter output logs
2510    Logs(CodeInterpreterOutputLogs),
2511    /// Code interpreter output image
2512    Image(CodeInterpreterOutputImage),
2513}
2514
2515#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2516pub struct CodeInterpreterOutputLogs {
2517    /// The logs output from the code interpreter.
2518    pub logs: String,
2519}
2520
2521#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2522pub struct CodeInterpreterOutputImage {
2523    /// The URL of the image output from the code interpreter.
2524    pub url: String,
2525}
2526
2527#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2528pub struct CodeInterpreterFile {
2529    /// The ID of the file.
2530    file_id: String,
2531    /// The MIME type of the file.
2532    mime_type: String,
2533}
2534
2535#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2536pub struct LocalShellToolCall {
2537    /// Execute a shell command on the server.
2538    pub action: LocalShellExecAction,
2539    /// The unique ID of the local shell tool call generated by the model.
2540    pub call_id: String,
2541    /// The unique ID of the local shell call.
2542    pub id: String,
2543    /// The status of the local shell call.
2544    pub status: OutputStatus,
2545}
2546
2547/// Define the shape of a local shell action (exec).
2548#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2549pub struct LocalShellExecAction {
2550    /// The command to run.
2551    pub command: Vec<String>,
2552    /// Environment variables to set for the command.
2553    pub env: HashMap<String, String>,
2554    /// Optional timeout in milliseconds for the command.
2555    pub timeout_ms: Option<u64>,
2556    /// Optional user to run the command as.
2557    pub user: Option<String>,
2558    /// Optional working directory to run the command in.
2559    pub working_directory: Option<String>,
2560}
2561
2562/// Commands and limits describing how to run the shell tool call.
2563#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2564pub struct FunctionShellActionParam {
2565    /// Ordered shell commands for the execution environment to run.
2566    pub commands: Vec<String>,
2567    /// Maximum wall-clock time in milliseconds to allow the shell commands to run.
2568    #[serde(skip_serializing_if = "Option::is_none")]
2569    pub timeout_ms: Option<u64>,
2570    /// Maximum number of UTF-8 characters to capture from combined stdout and stderr output.
2571    #[serde(skip_serializing_if = "Option::is_none")]
2572    pub max_output_length: Option<u64>,
2573}
2574
2575/// Status values reported for shell tool calls.
2576#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2577#[serde(rename_all = "snake_case")]
2578pub enum FunctionShellCallItemStatus {
2579    InProgress,
2580    Completed,
2581    Incomplete,
2582}
2583
2584/// The environment for a shell call item (request side).
2585#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2586#[serde(tag = "type", rename_all = "snake_case")]
2587pub enum FunctionShellCallItemEnvironment {
2588    /// Use a local computer environment.
2589    Local(LocalEnvironmentParam),
2590    /// Reference an existing container by ID.
2591    ContainerReference(ContainerReferenceParam),
2592}
2593
2594/// A tool representing a request to execute one or more shell commands.
2595#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2596pub struct FunctionShellCallItemParam {
2597    /// The unique ID of the shell tool call. Populated when this item is returned via API.
2598    #[serde(skip_serializing_if = "Option::is_none")]
2599    pub id: Option<String>,
2600    /// The unique ID of the shell tool call generated by the model.
2601    pub call_id: String,
2602    /// The shell commands and limits that describe how to run the tool call.
2603    pub action: FunctionShellActionParam,
2604    /// The status of the shell call. One of `in_progress`, `completed`, or `incomplete`.
2605    #[serde(skip_serializing_if = "Option::is_none")]
2606    pub status: Option<FunctionShellCallItemStatus>,
2607    /// The environment to execute the shell commands in.
2608    #[serde(skip_serializing_if = "Option::is_none")]
2609    pub environment: Option<FunctionShellCallItemEnvironment>,
2610    #[serde(skip_serializing_if = "Option::is_none")]
2611    pub caller: Option<ToolCallCaller>,
2612}
2613
2614/// Indicates that the shell commands finished and returned an exit code.
2615#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2616pub struct FunctionShellCallOutputExitOutcomeParam {
2617    /// The exit code returned by the shell process.
2618    pub exit_code: i32,
2619}
2620
2621/// The exit or timeout outcome associated with this chunk.
2622#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2623#[serde(tag = "type", rename_all = "snake_case")]
2624pub enum FunctionShellCallOutputOutcomeParam {
2625    Timeout,
2626    Exit(FunctionShellCallOutputExitOutcomeParam),
2627}
2628
2629/// Captured stdout and stderr for a portion of a shell tool call output.
2630#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2631pub struct FunctionShellCallOutputContentParam {
2632    /// Captured stdout output for this chunk of the shell call.
2633    pub stdout: String,
2634    /// Captured stderr output for this chunk of the shell call.
2635    pub stderr: String,
2636    /// The exit or timeout outcome associated with this chunk.
2637    pub outcome: FunctionShellCallOutputOutcomeParam,
2638}
2639
2640/// The streamed output items emitted by a shell tool call.
2641#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2642pub struct FunctionShellCallOutputItemParam {
2643    /// The unique ID of the shell tool call output. Populated when this item is returned via API.
2644    #[serde(skip_serializing_if = "Option::is_none")]
2645    pub id: Option<String>,
2646    /// The unique ID of the shell tool call generated by the model.
2647    pub call_id: String,
2648    /// Captured chunks of stdout and stderr output, along with their associated outcomes.
2649    pub output: Vec<FunctionShellCallOutputContentParam>,
2650    /// The maximum number of UTF-8 characters captured for this shell call's combined output.
2651    #[serde(skip_serializing_if = "Option::is_none")]
2652    pub max_output_length: Option<u64>,
2653    #[serde(skip_serializing_if = "Option::is_none")]
2654    pub caller: Option<ToolCallCaller>,
2655    #[serde(skip_serializing_if = "Option::is_none")]
2656    pub status: Option<FunctionShellCallItemStatus>,
2657}
2658
2659/// Status values reported for apply_patch tool calls.
2660#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2661#[serde(rename_all = "snake_case")]
2662pub enum ApplyPatchCallStatusParam {
2663    InProgress,
2664    Completed,
2665}
2666
2667/// Instruction for creating a new file via the apply_patch tool.
2668#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2669pub struct ApplyPatchCreateFileOperationParam {
2670    /// Path of the file to create relative to the workspace root.
2671    pub path: String,
2672    /// Unified diff content to apply when creating the file.
2673    pub diff: String,
2674}
2675
2676/// Instruction for deleting an existing file via the apply_patch tool.
2677#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2678pub struct ApplyPatchDeleteFileOperationParam {
2679    /// Path of the file to delete relative to the workspace root.
2680    pub path: String,
2681}
2682
2683/// Instruction for updating an existing file via the apply_patch tool.
2684#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2685pub struct ApplyPatchUpdateFileOperationParam {
2686    /// Path of the file to update relative to the workspace root.
2687    pub path: String,
2688    /// Unified diff content to apply to the existing file.
2689    pub diff: String,
2690}
2691
2692/// One of the create_file, delete_file, or update_file operations supplied to the apply_patch tool.
2693#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2694#[serde(tag = "type", rename_all = "snake_case")]
2695pub enum ApplyPatchOperationParam {
2696    CreateFile(ApplyPatchCreateFileOperationParam),
2697    DeleteFile(ApplyPatchDeleteFileOperationParam),
2698    UpdateFile(ApplyPatchUpdateFileOperationParam),
2699}
2700
2701/// A tool call representing a request to create, delete, or update files using diff patches.
2702#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2703pub struct ApplyPatchToolCallItemParam {
2704    /// The unique ID of the apply patch tool call. Populated when this item is returned via API.
2705    #[serde(skip_serializing_if = "Option::is_none")]
2706    pub id: Option<String>,
2707    /// The unique ID of the apply patch tool call generated by the model.
2708    pub call_id: String,
2709    /// The status of the apply patch tool call. One of `in_progress` or `completed`.
2710    pub status: ApplyPatchCallStatusParam,
2711    /// The specific create, delete, or update instruction for the apply_patch tool call.
2712    pub operation: ApplyPatchOperationParam,
2713    #[serde(skip_serializing_if = "Option::is_none")]
2714    pub caller: Option<ToolCallCaller>,
2715}
2716
2717/// Outcome values reported for apply_patch tool call outputs.
2718#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2719#[serde(rename_all = "snake_case")]
2720pub enum ApplyPatchCallOutputStatusParam {
2721    Completed,
2722    Failed,
2723}
2724
2725/// The streamed output emitted by an apply patch tool call.
2726#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2727pub struct ApplyPatchToolCallOutputItemParam {
2728    /// The unique ID of the apply patch tool call output. Populated when this item is returned via API.
2729    #[serde(skip_serializing_if = "Option::is_none")]
2730    pub id: Option<String>,
2731    /// The unique ID of the apply patch tool call generated by the model.
2732    pub call_id: String,
2733    /// The status of the apply patch tool call output. One of `completed` or `failed`.
2734    pub status: ApplyPatchCallOutputStatusParam,
2735    /// Optional human-readable log text from the apply patch tool (e.g., patch results or errors).
2736    #[serde(skip_serializing_if = "Option::is_none")]
2737    pub output: Option<String>,
2738    #[serde(skip_serializing_if = "Option::is_none")]
2739    pub caller: Option<ToolCallCaller>,
2740}
2741
2742/// Shell exec action
2743/// Execute a shell command.
2744#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2745pub struct FunctionShellAction {
2746    /// A list of commands to run.
2747    pub commands: Vec<String>,
2748    /// Optional timeout in milliseconds for the commands.
2749    pub timeout_ms: Option<u64>,
2750    /// Optional maximum number of characters to return from each command.
2751    pub max_output_length: Option<u64>,
2752}
2753
2754/// Status values reported for function shell tool calls.
2755#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2756#[serde(rename_all = "snake_case")]
2757pub enum FunctionShellCallStatus {
2758    InProgress,
2759    Completed,
2760    Incomplete,
2761}
2762
2763/// Status values reported for function shell tool call outputs.
2764#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2765#[serde(rename_all = "snake_case")]
2766pub enum FunctionShellCallOutputStatusEnum {
2767    InProgress,
2768    Completed,
2769    Incomplete,
2770}
2771
2772/// The environment for a shell call (response side).
2773#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2774#[serde(tag = "type", rename_all = "snake_case")]
2775pub enum FunctionShellCallEnvironment {
2776    /// A local computer environment.
2777    Local,
2778    /// A referenced container.
2779    ContainerReference(ContainerReferenceResource),
2780}
2781
2782/// A tool call that executes one or more shell commands in a managed environment.
2783#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2784pub struct FunctionShellCall {
2785    /// The unique ID of the function shell tool call. Populated when this item is returned via API.
2786    pub id: String,
2787    /// The unique ID of the function shell tool call generated by the model.
2788    pub call_id: String,
2789    /// The shell commands and limits that describe how to run the tool call.
2790    pub action: FunctionShellAction,
2791    /// The status of the shell call. One of `in_progress`, `completed`, or `incomplete`.
2792    pub status: FunctionShellCallStatus,
2793    /// The environment in which the shell commands were executed.
2794    pub environment: Option<FunctionShellCallEnvironment>,
2795    /// The ID of the entity that created this tool call.
2796    #[serde(skip_serializing_if = "Option::is_none")]
2797    pub created_by: Option<String>,
2798    #[serde(skip_serializing_if = "Option::is_none")]
2799    pub caller: Option<ToolCallCaller>,
2800}
2801
2802/// The content of a shell tool call output that was emitted.
2803#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2804pub struct FunctionShellCallOutputContent {
2805    /// The standard output that was captured.
2806    pub stdout: String,
2807    /// The standard error output that was captured.
2808    pub stderr: String,
2809    /// Represents either an exit outcome (with an exit code) or a timeout outcome for a shell call output chunk.
2810    #[serde(flatten)]
2811    pub outcome: FunctionShellCallOutputOutcome,
2812    /// The identifier of the actor that created the item.
2813    #[serde(skip_serializing_if = "Option::is_none")]
2814    pub created_by: Option<String>,
2815}
2816
2817/// Function shell call outcome
2818#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2819#[serde(tag = "type", rename_all = "snake_case")]
2820pub enum FunctionShellCallOutputOutcome {
2821    Timeout,
2822    Exit(FunctionShellCallOutputExitOutcome),
2823}
2824
2825/// Indicates that the shell commands finished and returned an exit code.
2826#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2827pub struct FunctionShellCallOutputExitOutcome {
2828    /// Exit code from the shell process.
2829    pub exit_code: i32,
2830}
2831
2832/// The output of a shell tool call that was emitted.
2833#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2834pub struct FunctionShellCallOutput {
2835    /// The unique ID of the shell call output. Populated when this item is returned via API.
2836    pub id: String,
2837    /// The unique ID of the shell tool call generated by the model.
2838    pub call_id: String,
2839    /// The status of the shell call output. One of `in_progress`, `completed`, or `incomplete`.
2840    pub status: FunctionShellCallOutputStatusEnum,
2841    /// An array of shell call output contents
2842    pub output: Vec<FunctionShellCallOutputContent>,
2843    /// The maximum length of the shell command output. This is generated by the model and should be
2844    /// passed back with the raw output.
2845    pub max_output_length: Option<u64>,
2846    /// The identifier of the actor that created the item.
2847    #[serde(skip_serializing_if = "Option::is_none")]
2848    pub created_by: Option<String>,
2849    #[serde(skip_serializing_if = "Option::is_none")]
2850    pub caller: Option<ToolCallCaller>,
2851}
2852
2853/// Status values reported for apply_patch tool calls.
2854#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2855#[serde(rename_all = "snake_case")]
2856pub enum ApplyPatchCallStatus {
2857    InProgress,
2858    Completed,
2859}
2860
2861/// Instruction describing how to create a file via the apply_patch tool.
2862#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2863pub struct ApplyPatchCreateFileOperation {
2864    /// Path of the file to create.
2865    pub path: String,
2866    /// Diff to apply.
2867    pub diff: String,
2868}
2869
2870/// Instruction describing how to delete a file via the apply_patch tool.
2871#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2872pub struct ApplyPatchDeleteFileOperation {
2873    /// Path of the file to delete.
2874    pub path: String,
2875}
2876
2877/// Instruction describing how to update a file via the apply_patch tool.
2878#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2879pub struct ApplyPatchUpdateFileOperation {
2880    /// Path of the file to update.
2881    pub path: String,
2882    /// Diff to apply.
2883    pub diff: String,
2884}
2885
2886/// One of the create_file, delete_file, or update_file operations applied via apply_patch.
2887#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2888#[serde(tag = "type", rename_all = "snake_case")]
2889pub enum ApplyPatchOperation {
2890    CreateFile(ApplyPatchCreateFileOperation),
2891    DeleteFile(ApplyPatchDeleteFileOperation),
2892    UpdateFile(ApplyPatchUpdateFileOperation),
2893}
2894
2895/// A tool call that applies file diffs by creating, deleting, or updating files.
2896#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2897pub struct ApplyPatchToolCall {
2898    /// The unique ID of the apply patch tool call. Populated when this item is returned via API.
2899    pub id: String,
2900    /// The unique ID of the apply patch tool call generated by the model.
2901    pub call_id: String,
2902    /// The status of the apply patch tool call. One of `in_progress` or `completed`.
2903    pub status: ApplyPatchCallStatus,
2904    /// One of the create_file, delete_file, or update_file operations applied via apply_patch.
2905    pub operation: ApplyPatchOperation,
2906    /// The ID of the entity that created this tool call.
2907    #[serde(skip_serializing_if = "Option::is_none")]
2908    pub created_by: Option<String>,
2909    #[serde(skip_serializing_if = "Option::is_none")]
2910    pub caller: Option<ToolCallCaller>,
2911}
2912
2913/// Outcome values reported for apply_patch tool call outputs.
2914#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2915#[serde(rename_all = "snake_case")]
2916pub enum ApplyPatchCallOutputStatus {
2917    Completed,
2918    Failed,
2919}
2920
2921/// The output emitted by an apply patch tool call.
2922#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2923pub struct ApplyPatchToolCallOutput {
2924    /// The unique ID of the apply patch tool call output. Populated when this item is returned via API.
2925    pub id: String,
2926    /// The unique ID of the apply patch tool call generated by the model.
2927    pub call_id: String,
2928    /// The status of the apply patch tool call output. One of `completed` or `failed`.
2929    pub status: ApplyPatchCallOutputStatus,
2930    /// Optional textual output returned by the apply patch tool.
2931    pub output: Option<String>,
2932    /// The ID of the entity that created this tool call output.
2933    #[serde(skip_serializing_if = "Option::is_none")]
2934    pub created_by: Option<String>,
2935    #[serde(skip_serializing_if = "Option::is_none")]
2936    pub caller: Option<ToolCallCaller>,
2937}
2938
2939/// Output of an MCP server tool invocation.
2940#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2941pub struct MCPToolCall {
2942    /// A JSON string of the arguments passed to the tool.
2943    pub arguments: String,
2944    /// The unique ID of the tool call.
2945    pub id: String,
2946    /// The name of the tool that was run.
2947    pub name: String,
2948    /// The label of the MCP server running the tool.
2949    pub server_label: String,
2950    /// Unique identifier for the MCP tool call approval request. Include this value
2951    /// in a subsequent `mcp_approval_response` input to approve or reject the corresponding
2952    /// tool call.
2953    pub approval_request_id: Option<String>,
2954    /// The error from the tool call, if any.
2955    pub error: Option<MCPToolCallError>,
2956    /// The output from the tool call.
2957    pub output: Option<String>,
2958    /// The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
2959    /// `calling`, or `failed`.
2960    pub status: Option<MCPToolCallStatus>,
2961}
2962
2963#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2964#[serde(rename_all = "snake_case")]
2965pub enum MCPToolCallStatus {
2966    InProgress,
2967    Completed,
2968    Incomplete,
2969    Calling,
2970    Failed,
2971}
2972
2973#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2974pub struct MCPListTools {
2975    /// The unique ID of the list.
2976    pub id: String,
2977    /// The label of the MCP server.
2978    pub server_label: String,
2979    /// The tools available on the server.
2980    pub tools: Vec<MCPListToolsTool>,
2981    /// Error message if listing failed.
2982    #[serde(skip_serializing_if = "Option::is_none")]
2983    pub error: Option<String>,
2984}
2985
2986#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
2987pub struct MCPApprovalRequest {
2988    /// JSON string of arguments for the tool.
2989    pub arguments: String,
2990    /// The unique ID of the approval request.
2991    pub id: String,
2992    /// The name of the tool to run.
2993    pub name: String,
2994    /// The label of the MCP server making the request.
2995    pub server_label: String,
2996}
2997
2998#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2999#[serde(untagged)]
3000pub enum Instructions {
3001    /// A text input to the model, equivalent to a text input with the `developer` role.
3002    Text(String),
3003    /// A list of one or many input items to the model, containing different content types.
3004    Array(Vec<InputItem>),
3005}
3006
3007/// The complete response returned by the Responses API.
3008#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3009pub struct Response {
3010    /// Whether to run the model response in the background.
3011    /// [Learn more](https://platform.openai.com/docs/guides/background).
3012    #[serde(skip_serializing_if = "Option::is_none")]
3013    pub background: Option<bool>,
3014
3015    /// Billing information for the response.
3016    #[serde(skip_serializing_if = "Option::is_none")]
3017    pub billing: Option<Billing>,
3018
3019    /// The conversation that this response belongs to. Input items and output
3020    /// items from this response are automatically added to this conversation.
3021    #[serde(skip_serializing_if = "Option::is_none")]
3022    pub conversation: Option<Conversation>,
3023
3024    /// Unix timestamp (in seconds) when this Response was created.
3025    pub created_at: u64,
3026
3027    /// Unix timestamp (in seconds) of when this Response was completed.
3028    /// Only present when the status is `completed`.
3029    #[serde(skip_serializing_if = "Option::is_none")]
3030    pub completed_at: Option<u64>,
3031
3032    /// An error object returned when the model fails to generate a Response.
3033    #[serde(skip_serializing_if = "Option::is_none")]
3034    pub error: Option<ResponseError>,
3035
3036    /// Unique identifier for this response.
3037    pub id: String,
3038
3039    /// Details about why the response is incomplete, if any.
3040    #[serde(skip_serializing_if = "Option::is_none")]
3041    pub incomplete_details: Option<IncompleteDetails>,
3042
3043    /// A system (or developer) message inserted into the model's context.
3044    ///
3045    /// When using along with `previous_response_id`, the instructions from a previous response
3046    /// will not be carried over to the next response. This makes it simple to swap out
3047    /// system (or developer) messages in new responses.
3048    #[serde(skip_serializing_if = "Option::is_none")]
3049    pub instructions: Option<Instructions>,
3050
3051    /// An upper bound for the number of tokens that can be generated for a response,
3052    /// including visible output tokens and
3053    /// [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
3054    #[serde(skip_serializing_if = "Option::is_none")]
3055    pub max_output_tokens: Option<u32>,
3056
3057    /// Set of 16 key-value pairs that can be attached to an object. This can be
3058    /// useful for storing additional information about the object in a structured
3059    /// format, and querying for objects via API or the dashboard.
3060    ///
3061    /// Keys are strings with a maximum length of 64 characters. Values are strings
3062    /// with a maximum length of 512 characters.
3063    #[serde(skip_serializing_if = "Option::is_none")]
3064    pub metadata: Option<HashMap<String, String>>,
3065
3066    /// Model ID used to generate the response, like `gpt-6-astra`. OpenAI
3067    /// offers a wide range of models with different capabilities, performance
3068    /// characteristics, and price points. Refer to the [model guide](/docs/models)
3069    /// to browse and compare available models.
3070    pub model: String,
3071
3072    /// The object type of this resource - always set to `response`.
3073    pub object: String,
3074
3075    /// An array of content items generated by the model.
3076    ///
3077    /// - The length and order of items in the output array is dependent on the model's response.
3078    /// - Rather than accessing the first item in the output array and assuming it's an assistant
3079    ///   message with the content generated by the model, you might consider using
3080    ///   the `output_text` property where supported in SDKs.
3081    pub output: Vec<OutputItem>,
3082
3083    /// SDK-only convenience property that contains the aggregated text output from all
3084    /// `output_text` items in the `output` array, if any are present.
3085    /// Supported in the Python and JavaScript SDKs.
3086    // #[serde(skip_serializing_if = "Option::is_none")]
3087    // pub output_text: Option<String>,
3088
3089    /// Whether to allow the model to run tool calls in parallel.
3090    #[serde(skip_serializing_if = "Option::is_none")]
3091    pub parallel_tool_calls: Option<bool>,
3092
3093    /// The unique ID of the previous response to the model. Use this to create multi-turn conversations.
3094    /// Learn more about [conversation state](https://platform.openai.com/docs/guides/conversation-state).
3095    /// Cannot be used in conjunction with `conversation`.
3096    #[serde(skip_serializing_if = "Option::is_none")]
3097    pub previous_response_id: Option<String>,
3098
3099    /// Reference to a prompt template and its variables.
3100    /// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
3101    #[serde(skip_serializing_if = "Option::is_none")]
3102    pub prompt: Option<Prompt>,
3103
3104    /// Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces
3105    /// the `user` field. [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
3106    #[serde(skip_serializing_if = "Option::is_none")]
3107    pub prompt_cache_key: Option<String>,
3108
3109    /// The retention policy for the prompt cache. Set to `24h` to enable extended prompt caching,
3110    /// which keeps cached prefixes active for longer, up to a maximum of 24 hours. [Learn
3111    /// more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
3112    #[serde(skip_serializing_if = "Option::is_none")]
3113    #[deprecated(note = "Use prompt_cache_options instead.")]
3114    pub prompt_cache_retention: Option<PromptCacheRetention>,
3115
3116    /// **gpt-5 and o-series models only**
3117    /// Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
3118    #[serde(skip_serializing_if = "Option::is_none")]
3119    pub reasoning: Option<Reasoning>,
3120
3121    /// A stable identifier used to help detect users of your application that may be violating OpenAI's
3122    /// usage policies.
3123    ///
3124    /// The IDs should be a string that uniquely identifies each user. We recommend hashing their username
3125    /// or email address, in order to avoid sending us any identifying information. [Learn
3126    /// more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
3127    #[serde(skip_serializing_if = "Option::is_none")]
3128    pub safety_identifier: Option<String>,
3129
3130    /// Specifies the processing type used for serving the request.
3131    /// - If set to 'auto', then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use 'default'.
3132    /// - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
3133    /// - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or '[priority](https://openai.com/api-priority-processing/)', then the request will be processed with the corresponding service tier.
3134    /// - When not set, the default behavior is 'auto'.
3135    ///
3136    /// When the `service_tier` parameter is set, the response body will include the `service_tier` value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
3137    #[serde(skip_serializing_if = "Option::is_none")]
3138    pub service_tier: Option<ServiceTierResponses>,
3139
3140    /// The status of the response generation.
3141    /// One of `completed`, `failed`, `in_progress`, `cancelled`, `queued`, or `incomplete`.
3142    pub status: Status,
3143
3144    /// What sampling temperature was used, between 0 and 2. Higher values like 0.8 make
3145    /// outputs more random, lower values like 0.2 make output more focused and deterministic.
3146    ///
3147    /// We generally recommend altering this or `top_p` but not both.
3148    #[serde(skip_serializing_if = "Option::is_none")]
3149    pub temperature: Option<f32>,
3150
3151    /// Configuration options for a text response from the model. Can be plain
3152    /// text or structured JSON data. Learn more:
3153    /// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
3154    /// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
3155    #[serde(skip_serializing_if = "Option::is_none")]
3156    pub text: Option<ResponseTextParam>,
3157
3158    /// How the model should select which tool (or tools) to use when generating
3159    /// a response. See the `tools` parameter to see how to specify which tools
3160    /// the model can call.
3161    #[serde(skip_serializing_if = "Option::is_none")]
3162    pub tool_choice: Option<ToolChoiceParam>,
3163
3164    /// An array of tools the model may call while generating a response. You
3165    /// can specify which tool to use by setting the `tool_choice` parameter.
3166    ///
3167    /// We support the following categories of tools:
3168    /// - **Built-in tools**: Tools that are provided by OpenAI that extend the
3169    ///   model's capabilities, like [web search](https://platform.openai.com/docs/guides/tools-web-search)
3170    ///   or [file search](https://platform.openai.com/docs/guides/tools-file-search). Learn more about
3171    ///   [built-in tools](https://platform.openai.com/docs/guides/tools).
3172    /// - **MCP Tools**: Integrations with third-party systems via custom MCP servers
3173    ///   or predefined connectors such as Google Drive and SharePoint. Learn more about
3174    ///   [MCP Tools](https://platform.openai.com/docs/guides/tools-connectors-mcp).
3175    /// - **Function calls (custom tools)**: Functions that are defined by you,
3176    ///   enabling the model to call your own code with strongly typed arguments
3177    ///   and outputs. Learn more about
3178    ///   [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use
3179    ///   custom tools to call your own code.
3180    #[serde(skip_serializing_if = "Option::is_none")]
3181    pub tools: Option<Vec<Tool>>,
3182
3183    /// An integer between 0 and 20 specifying the number of most likely tokens to return at each
3184    /// token position, each with an associated log probability.
3185    #[serde(skip_serializing_if = "Option::is_none")]
3186    pub top_logprobs: Option<u8>,
3187
3188    /// An alternative to sampling with temperature, called nucleus sampling,
3189    /// where the model considers the results of the tokens with top_p probability
3190    /// mass. So 0.1 means only the tokens comprising the top 10% probability mass
3191    /// are considered.
3192    ///
3193    /// We generally recommend altering this or `temperature` but not both.
3194    #[serde(skip_serializing_if = "Option::is_none")]
3195    pub top_p: Option<f32>,
3196
3197    ///The truncation strategy to use for the model response.
3198    /// - `auto`: If the input to this Response exceeds
3199    ///   the model's context window size, the model will truncate the
3200    ///   response to fit the context window by dropping items from the beginning of the conversation.
3201    /// - `disabled` (default): If the input size will exceed the context window
3202    ///   size for a model, the request will fail with a 400 error.
3203    #[serde(skip_serializing_if = "Option::is_none")]
3204    pub truncation: Option<Truncation>,
3205
3206    /// Represents token usage details including input tokens, output tokens,
3207    /// a breakdown of output tokens, and the total tokens used.
3208    #[serde(skip_serializing_if = "Option::is_none")]
3209    pub usage: Option<ResponseUsage>,
3210
3211    #[serde(skip_serializing_if = "Option::is_none")]
3212    pub prompt_cache_options: Option<PromptCacheOptions>,
3213
3214    #[serde(skip_serializing_if = "Option::is_none")]
3215    pub prompt_cache_diagnostics: Option<PromptCacheDiagnostics>,
3216
3217    #[serde(skip_serializing_if = "Option::is_none")]
3218    pub moderation: Option<Moderation>,
3219
3220    /// Domain-specific access programs applied to this response.
3221    #[serde(skip_serializing_if = "Option::is_none")]
3222    pub access_programs: Option<AccessProgramsBody>,
3223
3224    /// Usage reported by hosted tools, separate from base model `usage`. The field
3225    /// can be omitted when tool usage is unavailable. When present, tool families
3226    /// with no recorded usage have zero counts.
3227    ///
3228    /// `image_gen` sums available token counts across image generation calls.
3229    /// Calls with missing or incomplete usage records may be skipped. Output
3230    /// token details and cached input counts can be omitted. An omitted cache
3231    /// count means cache usage is unknown.
3232    ///
3233    /// `web_search.num_requests` counts billable searches. Discounted searches
3234    /// and actions such as opening a page are excluded. Use billing records to
3235    /// reconcile final charges.
3236    #[serde(skip_serializing_if = "Option::is_none")]
3237    pub tool_usage: Option<ResponseToolUsage>,
3238}
3239
3240#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3241#[serde(rename_all = "snake_case")]
3242pub enum Status {
3243    Completed,
3244    Failed,
3245    InProgress,
3246    Cancelled,
3247    Queued,
3248    Incomplete,
3249}
3250
3251/// Output item
3252#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3253#[serde(tag = "type")]
3254#[serde(rename_all = "snake_case")]
3255pub enum OutputItem {
3256    /// An output message from the model.
3257    Message(OutputMessage),
3258    /// The results of a file search tool call. See the
3259    /// [file search guide](https://platform.openai.com/docs/guides/tools-file-search)
3260    /// for more information.
3261    FileSearchCall(FileSearchToolCall),
3262    /// A tool call to run a function. See the
3263    /// [function calling guide](https://platform.openai.com/docs/guides/function-calling)
3264    /// for more information.
3265    FunctionCall(FunctionToolCall),
3266    /// The output of a function tool call.
3267    FunctionCallOutput(FunctionToolCallOutputResource),
3268    /// The results of a web search tool call. See the
3269    /// [web search guide](https://platform.openai.com/docs/guides/tools-web-search)
3270    /// for more information.
3271    WebSearchCall(WebSearchToolCall),
3272    /// A tool call to a computer use tool. See the
3273    /// [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use)
3274    /// for more information.
3275    ComputerCall(ComputerToolCall),
3276    /// The output of a computer tool call.
3277    ComputerCallOutput(ComputerToolCallOutputResource),
3278    /// A description of the chain of thought used by a reasoning model while generating
3279    /// a response. Be sure to include these items in your `input` to the Responses API for
3280    /// subsequent turns of a conversation if you are manually
3281    /// [managing context](https://platform.openai.com/docs/guides/conversation-state).
3282    Reasoning(ReasoningItem),
3283    Program(Program),
3284    ProgramOutput(ProgramOutput),
3285    /// A tool search call.
3286    ToolSearchCall(ToolSearchCall),
3287    /// A tool search output.
3288    ToolSearchOutput(ToolSearchOutput),
3289    AdditionalTools(AdditionalTools),
3290    /// A compaction item generated by the [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
3291    Compaction(CompactionBody),
3292    /// An image generation request made by the model.
3293    ImageGenerationCall(ImageGenToolCall),
3294    /// A tool call to run code.
3295    CodeInterpreterCall(CodeInterpreterToolCall),
3296    /// A tool call to run a command on the local shell.
3297    LocalShellCall(LocalShellToolCall),
3298    /// A tool call that executes one or more shell commands in a managed environment.
3299    ShellCall(FunctionShellCall),
3300    /// The output of a shell tool call.
3301    ShellCallOutput(FunctionShellCallOutput),
3302    /// A tool call that applies file diffs by creating, deleting, or updating files.
3303    ApplyPatchCall(ApplyPatchToolCall),
3304    /// The output emitted by an apply patch tool call.
3305    ApplyPatchCallOutput(ApplyPatchToolCallOutput),
3306    /// An invocation of a tool on an MCP server.
3307    McpCall(MCPToolCall),
3308    /// A list of tools available on an MCP server.
3309    McpListTools(MCPListTools),
3310    /// A request for human approval of a tool invocation.
3311    McpApprovalRequest(MCPApprovalRequest),
3312    /// A call to a custom tool created by the model.
3313    CustomToolCall(CustomToolCall),
3314    /// The output of a custom tool call.
3315    CustomToolCallOutput(CustomToolCallOutputResource),
3316}
3317
3318#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3319#[non_exhaustive]
3320pub struct CustomToolCall {
3321    /// An identifier used to map this custom tool call to a tool call output.
3322    pub call_id: String,
3323    /// The namespace of the custom tool being called.
3324    #[serde(skip_serializing_if = "Option::is_none")]
3325    pub namespace: Option<String>,
3326    /// The input for the custom tool call generated by the model.
3327    pub input: String,
3328    /// The name of the custom tool being called.
3329    pub name: String,
3330    /// The unique ID of the custom tool call in the OpenAI platform.
3331    pub id: String,
3332    #[serde(skip_serializing_if = "Option::is_none")]
3333    pub caller: Option<ToolCallCaller>,
3334    /// Whether the custom tool call runs asynchronously.
3335    #[serde(skip_serializing_if = "Option::is_none")]
3336    pub r#async: Option<bool>,
3337}
3338
3339/// A custom tool call item returned by the API.
3340#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3341#[non_exhaustive]
3342pub struct CustomToolCallResource {
3343    /// An identifier used to map this custom tool call to a tool call output.
3344    pub call_id: String,
3345    /// The namespace of the custom tool being called.
3346    #[serde(skip_serializing_if = "Option::is_none")]
3347    pub namespace: Option<String>,
3348    /// The input for the custom tool call generated by the model.
3349    pub input: String,
3350    /// The name of the custom tool being called.
3351    pub name: String,
3352    /// The unique ID of the custom tool call in the OpenAI platform.
3353    pub id: String,
3354    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3355    pub status: FunctionCallStatus,
3356    /// The identifier of the actor that created the item.
3357    #[serde(skip_serializing_if = "Option::is_none")]
3358    pub created_by: Option<String>,
3359    #[serde(skip_serializing_if = "Option::is_none")]
3360    pub caller: Option<ToolCallCaller>,
3361    /// Whether the custom tool call runs asynchronously.
3362    #[serde(skip_serializing_if = "Option::is_none")]
3363    pub r#async: Option<bool>,
3364}
3365
3366#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3367pub struct DeleteResponse {
3368    pub object: String,
3369    pub deleted: bool,
3370    pub id: String,
3371}
3372
3373#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3374pub struct AnyItemReference {
3375    pub r#type: Option<String>,
3376    pub id: String,
3377}
3378
3379#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3380#[serde(tag = "type", rename_all = "snake_case")]
3381pub enum ItemResourceItem {
3382    Message(MessageItem),
3383    FileSearchCall(FileSearchToolCall),
3384    ComputerCall(ComputerToolCall),
3385    ComputerCallOutput(ComputerToolCallOutputResource),
3386    WebSearchCall(WebSearchToolCall),
3387    FunctionCall(FunctionToolCallResource),
3388    FunctionCallOutput(FunctionToolCallOutputResource),
3389    ToolSearchCall(ToolSearchCall),
3390    ToolSearchOutput(ToolSearchOutput),
3391    AdditionalTools(AdditionalTools),
3392    ConfigurationUpdate(ResponseConfigurationUpdate),
3393    Reasoning(ReasoningItem),
3394    Program(Program),
3395    ProgramOutput(ProgramOutput),
3396    Compaction(CompactionBody),
3397    ImageGenerationCall(ImageGenToolCall),
3398    CodeInterpreterCall(CodeInterpreterToolCall),
3399    LocalShellCall(LocalShellToolCall),
3400    LocalShellCallOutput(LocalShellToolCallOutput),
3401    ShellCall(FunctionShellCallItemParam),
3402    ShellCallOutput(FunctionShellCallOutputItemParam),
3403    ApplyPatchCall(ApplyPatchToolCallItemParam),
3404    ApplyPatchCallOutput(ApplyPatchToolCallOutputItemParam),
3405    McpListTools(MCPListTools),
3406    McpApprovalRequest(MCPApprovalRequest),
3407    McpApprovalResponse(MCPApprovalResponse),
3408    McpCall(MCPToolCall),
3409    CustomToolCall(CustomToolCallResource),
3410    CustomToolCallOutput(CustomToolCallOutputResource),
3411}
3412
3413#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3414#[serde(untagged)]
3415pub enum ItemResource {
3416    ItemReference(AnyItemReference),
3417    Item(ItemResourceItem),
3418}
3419
3420/// A list of Response items.
3421#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3422pub struct ResponseItemList {
3423    /// The type of object returned, must be `list`.
3424    pub object: String,
3425    /// The ID of the first item in the list.
3426    pub first_id: Option<String>,
3427    /// The ID of the last item in the list.
3428    pub last_id: Option<String>,
3429    /// Whether there are more items in the list.
3430    pub has_more: bool,
3431    /// The list of items.
3432    pub data: Vec<ItemResource>,
3433}
3434
3435#[derive(Clone, Serialize, Deserialize, Debug, Default, Builder, PartialEq)]
3436#[builder(
3437    name = "TokenCountsBodyArgs",
3438    pattern = "mutable",
3439    setter(into, strip_option),
3440    default
3441)]
3442#[builder(build_fn(error = "OpenAIError"))]
3443pub struct TokenCountsBody {
3444    /// The conversation that this response belongs to. Items from this
3445    /// conversation are prepended to `input_items` for this response request.
3446    /// Input items and output items from this response are automatically added to this
3447    /// conversation after this response completes.
3448    #[serde(skip_serializing_if = "Option::is_none")]
3449    pub conversation: Option<ConversationParam>,
3450
3451    /// Text, image, or file inputs to the model, used to generate a response
3452    #[serde(skip_serializing_if = "Option::is_none")]
3453    pub input: Option<InputParam>,
3454
3455    /// A system (or developer) message inserted into the model's context.
3456    ///
3457    /// When used along with `previous_response_id`, the instructions from a previous response will
3458    /// not be carried over to the next response. This makes it simple to swap out system (or
3459    /// developer) messages in new responses.
3460    #[serde(skip_serializing_if = "Option::is_none")]
3461    pub instructions: Option<String>,
3462
3463    /// Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
3464    /// wide range of models with different capabilities, performance characteristics,
3465    /// and price points. Refer to the [model guide](https://platform.openai.com/docs/models)
3466    /// to browse and compare available models.
3467    #[serde(skip_serializing_if = "Option::is_none")]
3468    pub model: Option<String>,
3469
3470    /// Whether to allow the model to run tool calls in parallel.
3471    #[serde(skip_serializing_if = "Option::is_none")]
3472    pub parallel_tool_calls: Option<bool>,
3473
3474    /// The unique ID of the previous response to the model. Use this to create multi-turn
3475    /// conversations. Learn more about [conversation state](https://platform.openai.com/docs/guides/conversation-state).
3476    /// Cannot be used in conjunction with `conversation`.
3477    #[serde(skip_serializing_if = "Option::is_none")]
3478    pub previous_response_id: Option<String>,
3479
3480    /// **gpt-5 and o-series models only**
3481    /// Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
3482    #[serde(skip_serializing_if = "Option::is_none")]
3483    pub reasoning: Option<Reasoning>,
3484
3485    /// Configuration options for a text response from the model. Can be plain
3486    /// text or structured JSON data. Learn more:
3487    /// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
3488    /// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
3489    #[serde(skip_serializing_if = "Option::is_none")]
3490    pub text: Option<ResponseTextParam>,
3491
3492    /// How the model should select which tool (or tools) to use when generating
3493    /// a response. See the `tools` parameter to see how to specify which tools
3494    /// the model can call.
3495    #[serde(skip_serializing_if = "Option::is_none")]
3496    pub tool_choice: Option<ToolChoiceParam>,
3497
3498    /// An array of tools the model may call while generating a response. You can specify which tool
3499    /// to use by setting the `tool_choice` parameter.
3500    #[serde(skip_serializing_if = "Option::is_none")]
3501    pub tools: Option<Vec<Tool>>,
3502
3503    ///The truncation strategy to use for the model response.
3504    /// - `auto`: If the input to this Response exceeds
3505    ///   the model's context window size, the model will truncate the
3506    ///   response to fit the context window by dropping items from the beginning of the conversation.
3507    /// - `disabled` (default): If the input size will exceed the context window
3508    ///   size for a model, the request will fail with a 400 error.
3509    #[serde(skip_serializing_if = "Option::is_none")]
3510    #[deprecated(note = "Deprecated by the API")]
3511    pub truncation: Option<Truncation>,
3512    /// A model-owned style preset to apply to this request. Omit this parameter to use the model's default
3513    /// style. Supported values may expand over time. Values must be at most 64 characters.
3514    #[serde(skip_serializing_if = "Option::is_none")]
3515    pub personality: Option<PersonalityEnum>,
3516}
3517
3518#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3519pub struct TokenCountsResource {
3520    pub object: String,
3521    pub input_tokens: u32,
3522}
3523
3524/// A compaction item generated by the `/v1/responses/compact` API.
3525#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3526pub struct CompactionSummaryItemParam {
3527    /// The ID of the compaction item.
3528    #[serde(skip_serializing_if = "Option::is_none")]
3529    pub id: Option<String>,
3530    /// The encrypted content of the compaction summary.
3531    pub encrypted_content: String,
3532}
3533
3534/// A compaction item generated by the `/v1/responses/compact` API.
3535#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3536pub struct CompactionBody {
3537    /// The unique ID of the compaction item.
3538    pub id: String,
3539    /// The encrypted content that was produced by compaction.
3540    pub encrypted_content: String,
3541    /// The identifier of the actor that created the item.
3542    #[serde(skip_serializing_if = "Option::is_none")]
3543    pub created_by: Option<String>,
3544}
3545
3546#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Default)]
3547#[serde(rename_all = "lowercase")]
3548pub enum ServiceTierEnum {
3549    #[default]
3550    Auto,
3551    Default,
3552    Flex,
3553    Priority,
3554    Fast,
3555}
3556
3557/// Request to compact a conversation.
3558/// type in openapi spec: CompactResponseMethodPublicBody
3559#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
3560#[builder(name = "CompactResponseRequestArgs")]
3561#[builder(pattern = "mutable")]
3562#[builder(setter(into, strip_option), default)]
3563#[builder(derive(Debug))]
3564#[builder(build_fn(error = "OpenAIError"))]
3565pub struct CompactResponseRequest {
3566    /// Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide range of models
3567    /// with different capabilities, performance characteristics, and price points. Refer to the
3568    /// [model guide](https://platform.openai.com/docs/models) to browse and compare available models.
3569    pub model: String,
3570
3571    /// Text, image, or file inputs to the model, used to generate a response
3572    #[serde(skip_serializing_if = "Option::is_none")]
3573    pub input: Option<InputParam>,
3574
3575    /// The unique ID of the previous response to the model. Use this to create multi-turn
3576    /// conversations. Learn more about [conversation state](https://platform.openai.com/docs/guides/conversation-state).
3577    /// Cannot be used in conjunction with `conversation`.
3578    #[serde(skip_serializing_if = "Option::is_none")]
3579    pub previous_response_id: Option<String>,
3580
3581    /// A system (or developer) message inserted into the model's context.
3582    ///
3583    /// When used along with `previous_response_id`, the instructions from a previous response will
3584    /// not be carried over to the next response. This makes it simple to swap out system (or
3585    /// developer) messages in new responses.
3586    #[serde(skip_serializing_if = "Option::is_none")]
3587    pub instructions: Option<String>,
3588
3589    /// A key to use when reading from or writing to the prompt cache.
3590    #[serde(skip_serializing_if = "Option::is_none")]
3591    pub prompt_cache_key: Option<String>,
3592
3593    /// How long to retain a prompt cache entry created by this request.
3594    #[serde(skip_serializing_if = "Option::is_none")]
3595    #[deprecated(note = "Use prompt_cache_options instead.")]
3596    pub prompt_cache_retention: Option<PromptCacheRetention>,
3597
3598    /// The service tier to use for this request.
3599    #[serde(skip_serializing_if = "Option::is_none")]
3600    pub service_tier: Option<ServiceTierEnum>,
3601
3602    #[serde(skip_serializing_if = "Option::is_none")]
3603    pub prompt_cache_options: Option<PromptCacheOptionsParam>,
3604}
3605
3606/// The compacted response object.
3607#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3608pub struct CompactResource {
3609    /// The unique identifier for the compacted response.
3610    pub id: String,
3611    /// The object type. Always `response.compaction`.
3612    pub object: String,
3613    /// The compacted list of output items. This is a list of all user messages,
3614    /// followed by a single compaction item.
3615    pub output: Vec<OutputItem>,
3616    /// Unix timestamp (in seconds) when the compacted conversation was created.
3617    pub created_at: u64,
3618    /// Token accounting for the compaction pass, including cached, reasoning, and total tokens.
3619    pub usage: ResponseUsage,
3620}
3621
3622// ============================================================
3623// Container / Environment Types
3624// ============================================================
3625
3626/// A domain-scoped secret injected for allowlisted domains.
3627#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3628pub struct ContainerNetworkPolicyDomainSecretParam {
3629    /// The domain associated with the secret.
3630    pub domain: String,
3631    /// The name of the secret to inject for the domain.
3632    pub name: String,
3633    /// The secret value to inject for the domain.
3634    pub value: String,
3635}
3636
3637/// Details for an allowlist network policy.
3638#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3639pub struct ContainerNetworkPolicyAllowlistDetails {
3640    /// A list of allowed domains.
3641    pub allowed_domains: Vec<String>,
3642    /// Optional domain-scoped secrets for allowlisted domains.
3643    #[serde(skip_serializing_if = "Option::is_none")]
3644    pub domain_secrets: Option<Vec<ContainerNetworkPolicyDomainSecretParam>>,
3645}
3646
3647/// Network access policy for a container.
3648#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3649#[serde(tag = "type", rename_all = "snake_case")]
3650pub enum ContainerNetworkPolicy {
3651    /// Disable all outbound network access.
3652    Disabled,
3653    /// Allow access only to specified domains.
3654    Allowlist(ContainerNetworkPolicyAllowlistDetails),
3655}
3656
3657/// A skill referenced by ID.
3658#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3659pub struct SkillReferenceParam {
3660    /// The ID of the skill to reference.
3661    pub skill_id: String,
3662    /// An optional specific version to use.
3663    #[serde(skip_serializing_if = "Option::is_none")]
3664    pub version: Option<String>,
3665}
3666
3667/// An inline skill source (base64-encoded zip).
3668#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3669pub struct InlineSkillSourceParam {
3670    /// The media type. Always `"application/zip"`.
3671    pub media_type: String,
3672    /// The base64-encoded skill data.
3673    pub data: String,
3674}
3675
3676/// An inline skill definition.
3677#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3678pub struct InlineSkillParam {
3679    /// The name of the skill.
3680    pub name: String,
3681    /// The description of the skill.
3682    pub description: String,
3683    /// The inline source for the skill.
3684    pub source: InlineSkillSourceParam,
3685}
3686
3687/// A skill parameter — either a reference or inline definition.
3688#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3689#[serde(tag = "type", rename_all = "snake_case")]
3690pub enum SkillParam {
3691    /// Reference a skill by ID.
3692    SkillReference(SkillReferenceParam),
3693    /// Provide an inline skill definition.
3694    Inline(InlineSkillParam),
3695}
3696
3697/// Automatically creates a container for the request.
3698#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3699pub struct ContainerAutoParam {
3700    /// An optional list of uploaded file IDs to make available in the container.
3701    #[serde(skip_serializing_if = "Option::is_none")]
3702    pub file_ids: Option<Vec<String>>,
3703    /// Network access policy for the container.
3704    #[serde(skip_serializing_if = "Option::is_none")]
3705    pub network_policy: Option<ContainerNetworkPolicy>,
3706    /// An optional list of skills to make available in the container.
3707    #[serde(skip_serializing_if = "Option::is_none")]
3708    pub skills: Option<Vec<SkillParam>>,
3709}
3710
3711/// A local skill available in a local environment.
3712#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3713pub struct LocalSkillParam {
3714    /// The name of the skill.
3715    pub name: String,
3716    /// The description of the skill.
3717    pub description: String,
3718    /// The path to the directory containing the skill.
3719    pub path: String,
3720}
3721
3722/// Uses a local computer environment.
3723#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3724pub struct LocalEnvironmentParam {
3725    /// An optional list of local skills.
3726    #[serde(skip_serializing_if = "Option::is_none")]
3727    pub skills: Option<Vec<LocalSkillParam>>,
3728}
3729
3730/// References a container created with the /v1/containers endpoint.
3731#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3732pub struct ContainerReferenceParam {
3733    /// The ID of the referenced container.
3734    pub container_id: String,
3735}
3736
3737/// A resource reference to a container by ID.
3738#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3739pub struct ContainerReferenceResource {
3740    /// The ID of the referenced container.
3741    pub container_id: String,
3742}
3743
3744/// The execution environment for a shell tool — container or local.
3745#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3746#[serde(tag = "type", rename_all = "snake_case")]
3747pub enum FunctionShellEnvironment {
3748    /// Automatically creates a container for this request.
3749    ContainerAuto(ContainerAutoParam),
3750    /// Use a local computer environment.
3751    Local(LocalEnvironmentParam),
3752    /// Reference an existing container by ID.
3753    ContainerReference(ContainerReferenceParam),
3754}
3755
3756/// Parameters for the shell function tool.
3757#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3758pub struct FunctionShellToolParam {
3759    /// The execution environment for the shell tool.
3760    #[serde(skip_serializing_if = "Option::is_none")]
3761    pub environment: Option<FunctionShellEnvironment>,
3762    #[serde(skip_serializing_if = "Option::is_none")]
3763    pub allowed_callers: Option<Vec<CallableToolAllowedCaller>>,
3764}
3765
3766#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3767#[serde(rename_all = "lowercase")]
3768pub enum ContextManagementParamType {
3769    Compaction,
3770}
3771
3772/// Context management configuration.
3773#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3774pub struct ContextManagementParam {
3775    /// The context management strategy type.
3776    pub r#type: ContextManagementParamType,
3777    /// Minimum number of tokens to retain before compacting.
3778    #[serde(skip_serializing_if = "Option::is_none")]
3779    pub compact_threshold: Option<u32>,
3780}
3781
3782/// Apply-patch tool configuration.
3783#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
3784pub struct ApplyPatchToolParam {
3785    /// Which callers may invoke this tool.
3786    #[serde(skip_serializing_if = "Option::is_none")]
3787    pub allowed_callers: Option<Vec<CallableToolAllowedCaller>>,
3788}
3789
3790/// Moderation results or errors for the response input and output.
3791#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3792pub struct Moderation {
3793    /// Moderation for the response input.
3794    pub input: ModerationInput,
3795    /// Moderation for the response output.
3796    pub output: ModerationOutput,
3797}
3798
3799/// An error produced while attempting moderation for the response input or output.
3800#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3801pub struct ModerationErrorBody {
3802    /// The error code.
3803    pub code: String,
3804    /// The error message.
3805    pub message: String,
3806}
3807
3808/// Moderation for the response input.
3809#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3810#[serde(tag = "type", rename_all = "snake_case")]
3811pub enum ModerationInput {
3812    ModerationResult(ModerationResultBody),
3813    Error(ModerationErrorBody),
3814}
3815
3816/// Moderation for the response output.
3817#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3818#[serde(tag = "type", rename_all = "snake_case")]
3819pub enum ModerationOutput {
3820    ModerationResult(ModerationResultBody),
3821    Error(ModerationErrorBody),
3822}
3823
3824#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3825#[serde(rename_all = "snake_case")]
3826pub enum CacheMissReasonTypeEnum {
3827    ModelChanged,
3828    PromptCacheKeyChanged,
3829    ToolsChanged,
3830    TextFormatChanged,
3831    ReasoningEffortChanged,
3832    VerbosityChanged,
3833    ContextCompacted,
3834    InputChanged,
3835    ServiceTierChanged,
3836}
3837
3838/// Marks the exact end of a reusable prompt prefix. When ttl is omitted, the breakpoint inherits
3839/// the request TTL. The boundary is not rounded to a token block.
3840#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3841pub struct PromptCacheBreakpointConfig {
3842    /// The breakpoint mode. Always `explicit`.
3843    pub mode: PromptCacheBreakpointConfigMode,
3844
3845    /// The minimum lifetime of this cache breakpoint. Defaults to the request TTL.
3846    #[serde(skip_serializing_if = "Option::is_none")]
3847    pub ttl: Option<PromptCacheBreakpointTTLEnum>,
3848}
3849
3850/// The breakpoint mode. Always `explicit`.
3851#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3852#[serde(rename_all = "lowercase")]
3853pub enum PromptCacheBreakpointConfigMode {
3854    Explicit,
3855}
3856
3857/// Prompt cache diagnostics requested for this response.
3858#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3859#[serde(tag = "type", rename_all = "snake_case")]
3860pub enum PromptCacheDiagnostics {
3861    CacheMiss(PromptCacheMissDiagnosticsBody),
3862    CacheHit,
3863    ComparisonResponseNotFound,
3864    Unavailable,
3865}
3866
3867#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3868pub struct PromptCacheMissDiagnosticsBody {
3869    /// The reason prompt cache reuse did not occur.
3870    pub reason: CacheMissReasonTypeEnum,
3871    /// The estimated number of input tokens affected after the first detected divergence.
3872    pub cache_missed_tokens: u64,
3873    /// The raw token count of the reusable prefix in the compared response.
3874    #[serde(skip_serializing_if = "Option::is_none")]
3875    pub comparison_reusable_tokens: Option<u64>,
3876}
3877
3878/// The prompt-caching options that were applied to the response. Supported for `gpt-5.6` and later
3879/// models.
3880#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3881pub struct PromptCacheOptions {
3882    /// The minimum lifetime applied to each cache breakpoint.
3883    pub ttl: PromptCacheTTLEnum,
3884    /// Whether implicit prompt-cache breakpoints were enabled.
3885    pub mode: PromptCacheModeEnum,
3886    #[serde(skip_serializing_if = "Option::is_none")]
3887    pub comparison_response_id: Option<String>,
3888}
3889
3890#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3891pub struct AdditionalTools {
3892    /// The unique ID of the additional tools item.
3893    pub id: String,
3894    /// The role that provided the additional tools.
3895    pub role: MessageRole,
3896    /// The additional tool definitions made available at this item.
3897    pub tools: Vec<Tool>,
3898}
3899
3900#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3901pub struct AdditionalToolsItemParam {
3902    #[serde(skip_serializing_if = "Option::is_none")]
3903    pub id: Option<String>,
3904    /// The item type. Always `additional_tools`.
3905    /// The role that provided the additional tools. Only `developer` is supported.
3906    pub role: AdditionalToolsItemParamRole,
3907    /// A list of additional tools made available at this item.
3908    pub tools: Vec<Tool>,
3909}
3910
3911/// The role that provided the additional tools. Only `developer` is supported.
3912#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3913#[serde(rename_all = "lowercase")]
3914pub enum AdditionalToolsItemParamRole {
3915    Developer,
3916}
3917
3918#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3919#[serde(rename_all = "lowercase")]
3920pub enum CallableToolAllowedCaller {
3921    Direct,
3922    Programmatic,
3923}
3924
3925/// Compacts the current context. Must be the final input item.
3926#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3927pub struct CompactionTriggerItemParam {
3928    #[serde(skip_serializing_if = "Option::is_none")]
3929    pub id: Option<String>,
3930}
3931
3932#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3933pub struct ContainerFileCitationParam {
3934    /// The citation type. Always `container_file_citation`.
3935    pub r#type: String,
3936    /// The index of the first character of the citation in the message.
3937    pub start_index: u64,
3938    /// The index of the last character of the citation in the message.
3939    pub end_index: u64,
3940    /// The ID of the container.
3941    pub container_id: String,
3942    /// The ID of the container file.
3943    pub file_id: String,
3944    /// The filename of the container file cited.
3945    pub filename: String,
3946}
3947
3948#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3949pub struct FileCitationParam {
3950    /// The citation type. Always `file_citation`.
3951    pub r#type: String,
3952    /// The index of the file in the list of files.
3953    pub index: u64,
3954    /// The ID of the file.
3955    pub file_id: String,
3956    /// The filename of the file cited.
3957    pub filename: String,
3958}
3959
3960#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3961pub struct HTTPError {
3962    pub code: i64,
3963    pub message: String,
3964}
3965
3966#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3967pub struct MCPProtocolError {
3968    pub code: i64,
3969    pub message: String,
3970}
3971
3972#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3973#[serde(tag = "type", rename_all = "snake_case")]
3974pub enum MCPToolCallError {
3975    McpProtocolError(MCPProtocolError),
3976    McpToolExecutionError(MCPToolExecutionError),
3977    HttpError(HTTPError),
3978}
3979
3980#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3981pub struct MCPToolExecutionError {
3982    pub content: serde_json::Value,
3983}
3984
3985#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
3986#[serde(rename_all = "lowercase")]
3987pub enum PersonalityEnum {
3988    Friendly,
3989    Pragmatic,
3990    Other(String),
3991}
3992
3993#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
3994pub struct Program {
3995    /// The unique ID of the program item.
3996    pub id: String,
3997    /// The stable call ID of the program item.
3998    pub call_id: String,
3999    /// The JavaScript source executed by programmatic tool calling.
4000    pub code: String,
4001    /// Opaque program replay fingerprint that must be round-tripped.
4002    pub fingerprint: String,
4003}
4004
4005#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4006pub struct ProgramItemParam {
4007    /// The unique ID of this program item.
4008    pub id: String,
4009    /// The stable call ID of the program item.
4010    pub call_id: String,
4011    /// The JavaScript source executed by programmatic tool calling.
4012    pub code: String,
4013    /// Opaque program replay fingerprint that must be round-tripped.
4014    pub fingerprint: String,
4015}
4016
4017#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4018pub struct ProgramOutput {
4019    /// The unique ID of the program output item.
4020    pub id: String,
4021    /// The call ID of the program item.
4022    pub call_id: String,
4023    /// The result produced by the program item.
4024    pub result: String,
4025    /// The terminal status of the program output item.
4026    pub status: ProgramOutputStatus,
4027}
4028
4029#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4030pub struct ProgramOutputItemParam {
4031    /// The unique ID of this program output item.
4032    pub id: String,
4033    /// The call ID of the program item.
4034    pub call_id: String,
4035    /// The result produced by the program item.
4036    pub result: String,
4037    /// The terminal status of the program output.
4038    pub status: ProgramOutputItemStatus,
4039}
4040
4041#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4042#[serde(rename_all = "lowercase")]
4043pub enum ProgramOutputItemStatus {
4044    Completed,
4045    Incomplete,
4046}
4047
4048#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4049#[serde(rename_all = "lowercase")]
4050pub enum ProgramOutputStatus {
4051    Completed,
4052    Incomplete,
4053}
4054
4055#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4056pub struct ProgramToolCallCaller {
4057    /// The call ID of the program item that produced this tool call.
4058    pub caller_id: String,
4059}
4060
4061#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4062#[serde(rename_all = "lowercase")]
4063pub enum ReasoningModeEnum {
4064    Pro,
4065    Standard,
4066    #[serde(untagged)]
4067    Other(String),
4068}
4069
4070/// A configuration update that applies to subsequent responses until it is
4071/// replaced by another configuration update.
4072#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4073pub struct ResponseConfigurationUpdate {
4074    /// The unique ID of the configuration update item.
4075    pub id: String,
4076    /// The reasoning configuration applied by this update.
4077    #[serde(skip_serializing_if = "Option::is_none")]
4078    pub reasoning: Option<ResponseConfigurationUpdateReasoning>,
4079
4080    /// The text output configuration for subsequent responses.
4081    #[serde(skip_serializing_if = "Option::is_none")]
4082    pub text: Option<ResponseConfigurationUpdateText>,
4083}
4084
4085/// An update to the conversation's response configuration. The configuration
4086/// remains in effect for subsequent responses until it is replaced by another
4087/// configuration update.
4088#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4089pub struct ResponseConfigurationUpdateItemParam {
4090    #[serde(skip_serializing_if = "Option::is_none")]
4091    pub id: Option<String>,
4092    /// Updates to reasoning configuration. Only effort is supported.
4093    #[serde(skip_serializing_if = "Option::is_none")]
4094    pub reasoning: Option<ResponseConfigurationUpdateReasoning>,
4095
4096    /// The text output configuration for subsequent responses.
4097    #[serde(skip_serializing_if = "Option::is_none")]
4098    pub text: Option<ResponseConfigurationUpdateText>,
4099}
4100
4101/// The reasoning configuration applied by this update.
4102#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4103pub struct ResponseConfigurationUpdateReasoning {
4104    /// The reasoning effort used for subsequent responses until another
4105    /// configuration update replaces it.
4106    #[serde(skip_serializing_if = "Option::is_none")]
4107    pub effort: Option<ReasoningEffort>,
4108}
4109
4110/// Options for prompt caching. Supported for `gpt-5.6` and later models. By default, OpenAI
4111/// automatically chooses one implicit cache breakpoint. You can add explicit breakpoints to content
4112/// blocks with `prompt_cache_breakpoint`. Each request can write up to four breakpoints. For cache
4113/// matching, OpenAI considers up to the latest 80 breakpoints in the conversation, without a content-
4114/// block lookback limit. Set `mode` to `explicit` to disable the implicit breakpoint. The `ttl`
4115/// defaults to `30m`, which is currently the only supported value. See the [prompt caching
4116/// guide](https://platform.openai.com/docs/guides/prompt-caching) for current details.
4117#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4118pub struct ResponsePromptCacheOptionsParam {
4119    /// The minimum lifetime applied to every implicit and explicit cache breakpoint written by the request.
4120    /// Defaults to `30m`, which is currently the only supported value. The backend may retain cache entries
4121    /// for longer.
4122    #[serde(skip_serializing_if = "Option::is_none")]
4123    pub ttl: Option<PromptCacheTTLEnum>,
4124    /// Controls whether OpenAI automatically creates an implicit cache breakpoint. Defaults to `implicit`.
4125    /// With `implicit`, OpenAI creates one implicit breakpoint and writes up to the latest three explicit
4126    /// breakpoints in the request. With `explicit`, OpenAI does not create an implicit breakpoint and
4127    /// writes up to the latest four explicit breakpoints. If there are no explicit breakpoints, the request
4128    /// does not use prompt caching.
4129    #[serde(skip_serializing_if = "Option::is_none")]
4130    pub mode: Option<PromptCacheModeEnum>,
4131    #[serde(skip_serializing_if = "Option::is_none")]
4132    pub comparison_response_id: Option<String>,
4133
4134    /// Prepares the prompt cache without generating output. Defaults to `false`. When set to `true`,
4135    /// overrides the `generate` field to `false`.
4136    #[serde(skip_serializing_if = "Option::is_none")]
4137    pub prewarm: Option<bool>,
4138}
4139
4140/// Specifies the processing type used for serving the request.
4141///   - If set to 'auto', then the request will be processed with the service tier configured in the
4142///     Project settings. Unless otherwise configured, the Project will use 'default'.
4143///   - If set to 'default', then the request will be processed with the standard pricing and
4144///     performance for the selected model.
4145///   - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)', then the request will be processed with the
4146///     Flex Processing service tier.
4147///   - To opt-in to [Fast mode](https://platform.openai.com/api/docs/guides/fast-mode) at the request level, include the
4148///     `service_tier=fast` or `service_tier=priority` parameter for Responses or Chat Completions. The
4149///     response will show `service_tier=priority` regardless of if you specify `service_tier=fast` or
4150///     `priority` in your request.
4151///   - If set to 'ultrafast', then the request will be processed with the access-controlled Ultrafast
4152///     Processing service tier. This tier is currently available for `gpt-5.6-sol`; a response served
4153///     through it will show `service_tier=ultrafast`.
4154///   - When not set, the default behavior is 'auto'.
4155///
4156///   When the `service_tier` parameter is set, the response body will include the `service_tier` value
4157/// based on the processing mode actually used to serve the request. This response value may be
4158/// different from the value set in the parameter.
4159#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4160#[serde(rename_all = "lowercase")]
4161pub enum ServiceTierResponses {
4162    Auto,
4163    Default,
4164    Flex,
4165    Scale,
4166    Priority,
4167    Fast,
4168    Ultrafast,
4169}
4170
4171/// The execution context that produced this tool call.
4172#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4173#[serde(tag = "type", rename_all = "lowercase")]
4174pub enum ToolCallCaller {
4175    Direct,
4176    Program(ProgramToolCallCaller),
4177}
4178
4179#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4180pub struct UrlCitationParam {
4181    /// The citation type. Always `url_citation`.
4182    pub r#type: String,
4183    /// The index of the first character of the citation in the message.
4184    pub start_index: u64,
4185    /// The index of the last character of the citation in the message.
4186    pub end_index: u64,
4187    /// The URL of the cited resource.
4188    pub url: String,
4189    /// The title of the cited resource.
4190    pub title: String,
4191}
4192
4193#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4194pub struct ResponseConfigurationUpdateText {
4195    pub format: ResponseConfigurationUpdateTextFormat,
4196}
4197
4198#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4199#[serde(tag = "type", rename_all = "snake_case")]
4200pub enum ResponseConfigurationUpdateTextFormat {
4201    Text,
4202    JsonSchema(ResponseFormatJsonSchema),
4203}
4204
4205#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4206pub struct AccessProgramsBody {
4207    /// The effective Cyber access program used for this response.
4208    pub cyber: CyberAccessProgramEnum,
4209}
4210
4211#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4212#[serde(rename_all = "snake_case")]
4213pub enum CyberAccessProgramEnum {
4214    Standard,
4215    DaybreakBlue,
4216    DaybreakRed,
4217}
4218
4219/// Domain-specific access programs to use for this request.
4220#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4221pub struct AccessProgramsParam {
4222    /// The Cyber access program to use for this request. Supported values are `standard`, `daybreak_blue`, and `daybreak_red`. If omitted, the API resolves the program from the model's Cyber tier and your organization and project access, subject to model-specific eligibility restrictions. By default, models without a Cyber tier use Standard. Blue-tier models use Daybreak Blue when authorized; otherwise they fall back to Standard unless the model requires Daybreak access. Red-tier models use Daybreak Red and require authorization. Requests that require unavailable Daybreak access return 403. An implicit Standard fallback is represented by null in the response's access_programs field, rather than an explicit Standard selection.
4223    #[serde(skip_serializing_if = "Option::is_none")]
4224    pub cyber: Option<CyberAccessProgramEnum>,
4225}
4226
4227/// Aggregated usage details for billable tools that ran while generating the response.
4228#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4229pub struct ResponseToolUsage {
4230    /// Aggregated usage statistics for image generation tool calls.
4231    pub image_gen: ImageGenToolUsage,
4232    /// Aggregated billable usage statistics for web search tool calls.
4233    pub web_search: WebSearchUsage,
4234}
4235
4236/// Usage details for web search requests that ran while generating the response.
4237#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4238pub struct WebSearchUsage {
4239    /// The number of billable web search requests issued.
4240    pub num_requests: u32,
4241}
4242
4243/// Token usage for image generation tool calls in a response.
4244#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4245pub struct ImageGenToolUsage {
4246    /// The number of tokens (images and text) in the input prompt.
4247    pub input_tokens: u32,
4248    /// The total number of tokens (images and text) used for the image generation.
4249    pub total_tokens: u32,
4250    /// The number of output tokens generated by the model.
4251    pub output_tokens: u32,
4252    #[serde(skip_serializing_if = "Option::is_none")]
4253    pub output_tokens_details: Option<ImageGenOutputTokensDetails>,
4254    pub input_tokens_details: ImageGenInputUsageDetails,
4255    #[serde(skip_serializing_if = "Option::is_none")]
4256    pub cached_tokens: Option<u32>,
4257    #[serde(skip_serializing_if = "Option::is_none")]
4258    pub cached_tokens_details: Option<CachedUsageDetails>,
4259}
4260
4261#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4262pub struct CachedUsageDetails {
4263    pub cached_text_tokens: u32,
4264    pub cached_image_tokens: u32,
4265}
4266
4267/// An error returned by the image generation tool.
4268#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4269pub struct ImageGenToolCallError {
4270    #[serde(skip_serializing_if = "Option::is_none")]
4271    pub code: Option<String>,
4272    /// The error type.
4273    pub r#type: String,
4274    /// A description of the error.
4275    pub message: String,
4276    #[serde(skip_serializing_if = "Option::is_none")]
4277    pub param: Option<String>,
4278    /// Public details for a `moderation_blocked` error, when available.
4279    #[serde(skip_serializing_if = "Option::is_none")]
4280    pub moderation_details: Option<ImageGenToolCallModerationDetails>,
4281}
4282
4283#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4284pub struct ImageGenToolCallModerationDetails {
4285    /// The stage where moderation blocked the image generation call.
4286    pub moderation_stage: ImageGenToolCallModerationDetailsModerationStage,
4287    /// Public moderation categories. New category values may be added over time.
4288    pub categories: Vec<String>,
4289}
4290
4291/// The stage where moderation blocked the image generation call.
4292#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4293#[serde(rename_all = "snake_case")]
4294pub enum ImageGenToolCallModerationDetailsModerationStage {
4295    Input,
4296    Output,
4297    Unknown,
4298}
4299
4300#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
4301#[serde(tag = "type", rename_all = "snake_case")]
4302pub enum ToolSearchOutputTool {
4303    /// Defines a function in your own code the model can choose to call. Learn more about [function
4304    /// calling](https://platform.openai.com/docs/guides/tools).
4305    Function(FunctionTool),
4306    /// A tool that searches for relevant content from uploaded files. Learn more about the [file search
4307    /// tool](https://platform.openai.com/docs/guides/tools-file-search).
4308    FileSearch(FileSearchTool),
4309    /// A tool that controls a virtual computer. Learn more about the
4310    /// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
4311    Computer,
4312    /// A tool that controls a virtual computer. Learn more about the [computer
4313    /// use tool](https://platform.openai.com/docs/guides/tools-computer-use).
4314    ComputerUsePreview(ComputerUsePreviewTool),
4315    /// Search the Internet for sources related to the prompt. Learn more about the
4316    /// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
4317    WebSearch(WebSearchTool),
4318    /// type: web_search_2025_08_26
4319    #[serde(rename = "web_search_2025_08_26")]
4320    WebSearch20250826(WebSearchTool),
4321    /// Give the model access to additional tools via remote Model Context Protocol
4322    /// (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
4323    Mcp(MCPTool),
4324    /// A tool that runs Python code to help generate a response to a prompt.
4325    CodeInterpreter(CodeInterpreterTool),
4326
4327    ProgrammaticToolCalling,
4328    /// A tool that generates images using a model like `gpt-image-1`.
4329    ImageGeneration(ImageGenTool),
4330    /// A tool that allows the model to execute shell commands in a local environment.
4331    LocalShell,
4332    /// A tool that allows the model to execute shell commands.
4333    Shell(FunctionShellToolParam),
4334    /// A custom tool that processes input using a specified format. Learn more about   [custom
4335    /// tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
4336    Custom(CustomToolParam),
4337
4338    /// Groups function/custom tools under a shared namespace.
4339    Namespace(ToolSearchOutputNamespaceToolParam),
4340    /// Hosted or BYOT tool search configuration for deferred tools.
4341    ToolSearch(ToolSearchToolParam),
4342    /// This tool searches the web for relevant results to use in a response. Learn more about the [web search
4343    ///tool](https://platform.openai.com/docs/guides/tools-web-search).
4344    WebSearchPreview(WebSearchTool),
4345    /// type: web_search_preview_2025_03_11
4346    #[serde(rename = "web_search_preview_2025_03_11")]
4347    WebSearchPreview20250311(WebSearchTool),
4348    /// Allows the assistant to create, delete, or update files using unified diffs.
4349    ApplyPatch(ApplyPatchToolParam),
4350}
4351
4352/// A namespace containing loaded function and custom tool definitions.
4353#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
4354pub struct ToolSearchOutputNamespaceToolParam {
4355    pub name: String,
4356    pub description: String,
4357    pub tools: Vec<NamespaceToolParamTool>,
4358}
4359
4360/// Loaded function tool parameters have the same shape as function tool parameters.
4361pub type ToolSearchOutputFunctionToolParam = FunctionToolParam;