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