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.
993    #[serde(skip_serializing_if = "Option::is_none")]
994    pub top_logprobs: Option<u8>,
995
996    /// An alternative to sampling with temperature, called nucleus sampling,
997    /// where the model considers the results of the tokens with top_p probability
998    /// mass. So 0.1 means only the tokens comprising the top 10% probability mass
999    /// are considered.
1000    ///
1001    /// We generally recommend altering this or `temperature` but not both.
1002    #[serde(skip_serializing_if = "Option::is_none")]
1003    pub top_p: Option<f32>,
1004
1005    ///The truncation strategy to use for the model response.
1006    /// - `auto`: If the input to this Response exceeds
1007    ///   the model's context window size, the model will truncate the
1008    ///   response to fit the context window by dropping items from the beginning of the conversation.
1009    /// - `disabled` (default): If the input size will exceed the context window
1010    ///   size for a model, the request will fail with a 400 error.
1011    #[serde(skip_serializing_if = "Option::is_none")]
1012    pub truncation: Option<Truncation>,
1013}
1014
1015#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1016#[serde(untagged)]
1017pub enum ResponsePromptVariables {
1018    String(String),
1019    Content(InputContent),
1020    Custom(serde_json::Value),
1021}
1022
1023#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1024pub struct Prompt {
1025    /// The unique identifier of the prompt template to use.
1026    pub id: String,
1027
1028    /// Optional version of the prompt template.
1029    #[serde(skip_serializing_if = "Option::is_none")]
1030    pub version: Option<String>,
1031
1032    /// Optional map of values to substitute in for variables in your
1033    /// prompt. The substitution values can either be strings, or other
1034    /// Response input types like images or files.
1035    #[serde(skip_serializing_if = "Option::is_none")]
1036    pub variables: Option<ResponsePromptVariables>,
1037}
1038
1039#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Default)]
1040#[serde(rename_all = "lowercase")]
1041pub enum ServiceTier {
1042    #[default]
1043    Auto,
1044    Default,
1045    Flex,
1046    Scale,
1047    Priority,
1048}
1049
1050/// Truncation strategies.
1051#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1052#[serde(rename_all = "lowercase")]
1053pub enum Truncation {
1054    Auto,
1055    Disabled,
1056}
1057
1058#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1059pub struct Billing {
1060    pub payer: String,
1061}
1062
1063/// o-series reasoning settings.
1064#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1065#[builder(
1066    name = "ReasoningArgs",
1067    pattern = "mutable",
1068    setter(into, strip_option),
1069    default
1070)]
1071#[builder(build_fn(error = "OpenAIError"))]
1072pub struct Reasoning {
1073    /// Constrains effort on reasoning for
1074    /// [reasoning models](https://platform.openai.com/docs/guides/reasoning).
1075    /// Currently supported values are `minimal`, `low`, `medium`, and `high`. Reducing
1076    /// reasoning effort can result in faster responses and fewer tokens used
1077    /// on reasoning in a response.
1078    ///
1079    /// Note: The `gpt-5-pro` model defaults to (and only supports) `high` reasoning effort.
1080    #[serde(skip_serializing_if = "Option::is_none")]
1081    pub effort: Option<ReasoningEffort>,
1082    /// A summary of the reasoning performed by the model. This can be
1083    /// useful for debugging and understanding the model's reasoning process.
1084    /// One of `auto`, `concise`, or `detailed`.
1085    ///
1086    /// `concise` is supported for `computer-use-preview` models and all reasoning models after
1087    /// `gpt-5`.
1088    #[serde(skip_serializing_if = "Option::is_none")]
1089    pub summary: Option<ReasoningSummary>,
1090}
1091
1092/// o-series reasoning settings.
1093#[derive(Clone, Serialize, Debug, Deserialize, PartialEq)]
1094#[serde(rename_all = "lowercase")]
1095pub enum Verbosity {
1096    Low,
1097    Medium,
1098    High,
1099}
1100
1101#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1102#[serde(rename_all = "lowercase")]
1103pub enum ReasoningSummary {
1104    Auto,
1105    Concise,
1106    Detailed,
1107}
1108
1109/// The retention policy for the prompt cache.
1110#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1111pub enum PromptCacheRetention {
1112    #[serde(rename = "in_memory")]
1113    InMemory,
1114    #[serde(rename = "24h")]
1115    Hours24,
1116}
1117
1118/// The detail level of a file input sent to the model.
1119#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1120#[serde(rename_all = "lowercase")]
1121pub enum FileInputDetail {
1122    Low,
1123    High,
1124}
1125
1126/// Configuration for text response format.
1127#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1128pub struct ResponseTextParam {
1129    /// An object specifying the format that the model must output.
1130    ///
1131    /// Configuring `{ "type": "json_schema" }` enables Structured Outputs,
1132    /// which ensures the model will match your supplied JSON schema. Learn more in the
1133    /// [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
1134    ///
1135    /// The default format is `{ "type": "text" }` with no additional options.
1136    ///
1137    /// **Not recommended for gpt-4o and newer models:**
1138    ///
1139    /// Setting to `{ "type": "json_object" }` enables the older JSON mode, which
1140    /// ensures the message the model generates is valid JSON. Using `json_schema`
1141    /// is preferred for models that support it.
1142    #[serde(default)]
1143    pub format: TextResponseFormatConfiguration,
1144
1145    /// Constrains the verbosity of the model's response. Lower values will result in
1146    /// more concise responses, while higher values will result in more verbose responses.
1147    ///
1148    /// Currently supported values are `low`, `medium`, and `high`.
1149    #[serde(skip_serializing_if = "Option::is_none")]
1150    pub verbosity: Option<Verbosity>,
1151}
1152
1153#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Default)]
1154#[serde(tag = "type", rename_all = "snake_case")]
1155pub enum TextResponseFormatConfiguration {
1156    /// Default response format. Used to generate text responses.
1157    #[default]
1158    Text,
1159    /// JSON object response format. An older method of generating JSON responses.
1160    /// Using `json_schema` is recommended for models that support it.
1161    /// Note that the model will not generate JSON without a system or user message
1162    /// instructing it to do so.
1163    JsonObject,
1164    /// JSON Schema response format. Used to generate structured JSON responses.
1165    /// Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
1166    JsonSchema(ResponseFormatJsonSchema),
1167}
1168
1169/// Definitions for model-callable tools.
1170#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1171#[serde(tag = "type", rename_all = "snake_case")]
1172pub enum Tool {
1173    /// Defines a function in your own code the model can choose to call. Learn more about [function
1174    /// calling](https://platform.openai.com/docs/guides/tools).
1175    Function(FunctionTool),
1176    /// A tool that searches for relevant content from uploaded files. Learn more about the [file search
1177    /// tool](https://platform.openai.com/docs/guides/tools-file-search).
1178    FileSearch(FileSearchTool),
1179    /// A tool that controls a virtual computer. Learn more about the [computer
1180    /// use tool](https://platform.openai.com/docs/guides/tools-computer-use).
1181    ComputerUsePreview(ComputerUsePreviewTool),
1182    /// Search the Internet for sources related to the prompt. Learn more about the
1183    /// [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
1184    WebSearch(WebSearchTool),
1185    /// type: web_search_2025_08_26
1186    #[serde(rename = "web_search_2025_08_26")]
1187    WebSearch20250826(WebSearchTool),
1188    /// Give the model access to additional tools via remote Model Context Protocol
1189    /// (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
1190    Mcp(MCPTool),
1191    /// A tool that runs Python code to help generate a response to a prompt.
1192    CodeInterpreter(CodeInterpreterTool),
1193    /// A tool that generates images using a model like `gpt-image-1`.
1194    ImageGeneration(ImageGenTool),
1195    /// A tool that allows the model to execute shell commands in a local environment.
1196    LocalShell,
1197    /// A tool that allows the model to execute shell commands.
1198    Shell(FunctionShellToolParam),
1199    /// A custom tool that processes input using a specified format. Learn more about   [custom
1200    /// tools](https://platform.openai.com/docs/guides/function-calling#custom-tools)
1201    Custom(CustomToolParam),
1202    /// A tool that controls a virtual computer. Learn more about the
1203    /// [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
1204    Computer(ComputerTool),
1205    /// Groups function/custom tools under a shared namespace.
1206    Namespace(NamespaceToolParam),
1207    /// Hosted or BYOT tool search configuration for deferred tools.
1208    ToolSearch(ToolSearchToolParam),
1209    /// This tool searches the web for relevant results to use in a response. Learn more about the [web search
1210    ///tool](https://platform.openai.com/docs/guides/tools-web-search).
1211    WebSearchPreview(WebSearchTool),
1212    /// type: web_search_preview_2025_03_11
1213    #[serde(rename = "web_search_preview_2025_03_11")]
1214    WebSearchPreview20250311(WebSearchTool),
1215    /// Allows the assistant to create, delete, or update files using unified diffs.
1216    ApplyPatch,
1217}
1218
1219#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1220pub struct CustomToolParam {
1221    /// The name of the custom tool, used to identify it in tool calls.
1222    pub name: String,
1223    /// Optional description of the custom tool, used to provide more context.
1224    pub description: Option<String>,
1225    /// The input format for the custom tool. Default is unconstrained text.
1226    pub format: CustomToolParamFormat,
1227    /// Whether this tool should be deferred and discovered via tool search.
1228    #[serde(skip_serializing_if = "Option::is_none")]
1229    pub defer_loading: Option<bool>,
1230}
1231
1232#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1233#[serde(tag = "type", rename_all = "lowercase")]
1234pub enum CustomToolParamFormat {
1235    /// Unconstrained free-form text.
1236    #[default]
1237    Text,
1238    /// A grammar defined by the user.
1239    Grammar(CustomGrammarFormatParam),
1240}
1241
1242#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1243#[builder(
1244    name = "FileSearchToolArgs",
1245    pattern = "mutable",
1246    setter(into, strip_option),
1247    default
1248)]
1249#[builder(build_fn(error = "OpenAIError"))]
1250pub struct FileSearchTool {
1251    /// The IDs of the vector stores to search.
1252    pub vector_store_ids: Vec<String>,
1253    /// The maximum number of results to return. This number should be between 1 and 50 inclusive.
1254    #[serde(skip_serializing_if = "Option::is_none")]
1255    pub max_num_results: Option<u32>,
1256    /// A filter to apply.
1257    #[serde(skip_serializing_if = "Option::is_none")]
1258    pub filters: Option<Filter>,
1259    /// Ranking options for search.
1260    #[serde(skip_serializing_if = "Option::is_none")]
1261    pub ranking_options: Option<RankingOptions>,
1262}
1263
1264#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1265#[builder(
1266    name = "FunctionToolArgs",
1267    pattern = "mutable",
1268    setter(into, strip_option),
1269    default
1270)]
1271pub struct FunctionTool {
1272    /// The name of the function to call.
1273    pub name: String,
1274    /// A JSON schema object describing the parameters of the function.
1275    #[serde(skip_serializing_if = "Option::is_none")]
1276    pub parameters: Option<serde_json::Value>,
1277    /// Whether to enforce strict parameter validation. Default `true`.
1278    #[serde(skip_serializing_if = "Option::is_none")]
1279    pub strict: Option<bool>,
1280    /// A description of the function. Used by the model to determine whether or not to call the
1281    /// function.
1282    #[serde(skip_serializing_if = "Option::is_none")]
1283    pub description: Option<String>,
1284    /// Whether this function is deferred and loaded via tool search.
1285    #[serde(skip_serializing_if = "Option::is_none")]
1286    pub defer_loading: Option<bool>,
1287}
1288
1289#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1290pub struct WebSearchToolFilters {
1291    /// Allowed domains for the search. If not provided, all domains are allowed.
1292    /// Subdomains of the provided domains are allowed as well.
1293    ///
1294    /// Example: `["pubmed.ncbi.nlm.nih.gov"]`
1295    #[serde(skip_serializing_if = "Option::is_none")]
1296    pub allowed_domains: Option<Vec<String>>,
1297}
1298
1299#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1300#[builder(
1301    name = "WebSearchToolArgs",
1302    pattern = "mutable",
1303    setter(into, strip_option),
1304    default
1305)]
1306pub struct WebSearchTool {
1307    /// Filters for the search.
1308    #[serde(skip_serializing_if = "Option::is_none")]
1309    pub filters: Option<WebSearchToolFilters>,
1310    /// The approximate location of the user.
1311    #[serde(skip_serializing_if = "Option::is_none")]
1312    pub user_location: Option<WebSearchApproximateLocation>,
1313    /// High level guidance for the amount of context window space to use for the search. One of `low`,
1314    /// `medium`, or `high`. `medium` is the default.
1315    #[serde(skip_serializing_if = "Option::is_none")]
1316    pub search_context_size: Option<WebSearchToolSearchContextSize>,
1317    /// The types of content to search for.
1318    #[serde(skip_serializing_if = "Option::is_none")]
1319    pub search_content_types: Option<Vec<SearchContentType>>,
1320}
1321
1322#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
1323#[serde(rename_all = "lowercase")]
1324pub enum WebSearchToolSearchContextSize {
1325    Low,
1326    #[default]
1327    Medium,
1328    High,
1329}
1330
1331#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
1332#[serde(rename_all = "lowercase")]
1333pub enum ComputerEnvironment {
1334    Windows,
1335    Mac,
1336    Linux,
1337    Ubuntu,
1338    #[default]
1339    Browser,
1340}
1341
1342#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1343#[builder(
1344    name = "ComputerUsePreviewToolArgs",
1345    pattern = "mutable",
1346    setter(into, strip_option),
1347    default
1348)]
1349pub struct ComputerUsePreviewTool {
1350    /// The type of computer environment to control.
1351    environment: ComputerEnvironment,
1352    /// The width of the computer display.
1353    display_width: u32,
1354    /// The height of the computer display.
1355    display_height: u32,
1356}
1357
1358#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1359pub enum RankVersionType {
1360    #[serde(rename = "auto")]
1361    Auto,
1362    #[serde(rename = "default-2024-11-15")]
1363    Default20241115,
1364}
1365
1366#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1367pub struct HybridSearch {
1368    /// The weight of the embedding in the reciprocal ranking fusion.
1369    pub embedding_weight: f32,
1370    /// The weight of the text in the reciprocal ranking fusion.
1371    pub text_weight: f32,
1372}
1373
1374/// Options for search result ranking.
1375#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1376pub struct RankingOptions {
1377    /// Weights that control how reciprocal rank fusion balances semantic embedding matches versus
1378    /// sparse keyword matches when hybrid search is enabled.
1379    #[serde(skip_serializing_if = "Option::is_none")]
1380    pub hybrid_search: Option<HybridSearch>,
1381    /// The ranker to use for the file search.
1382    pub ranker: RankVersionType,
1383    /// The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will
1384    /// attempt to return only the most relevant results, but may return fewer results.
1385    #[serde(skip_serializing_if = "Option::is_none")]
1386    pub score_threshold: Option<f32>,
1387}
1388
1389#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
1390#[serde(rename_all = "lowercase")]
1391pub enum WebSearchApproximateLocationType {
1392    #[default]
1393    Approximate,
1394}
1395
1396/// Approximate user location for web search.
1397#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1398#[builder(
1399    name = "WebSearchApproximateLocationArgs",
1400    pattern = "mutable",
1401    setter(into, strip_option),
1402    default
1403)]
1404#[builder(build_fn(error = "OpenAIError"))]
1405pub struct WebSearchApproximateLocation {
1406    /// The type of location approximation. Defaults to `approximate` when omitted in JSON input.
1407    #[serde(default)]
1408    pub r#type: WebSearchApproximateLocationType,
1409    /// Free text input for the city of the user, e.g. `San Francisco`.
1410    #[serde(skip_serializing_if = "Option::is_none")]
1411    pub city: Option<String>,
1412    /// The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user,
1413    /// e.g. `US`.
1414    #[serde(skip_serializing_if = "Option::is_none")]
1415    pub country: Option<String>,
1416    /// Free text input for the region of the user, e.g. `California`.
1417    #[serde(skip_serializing_if = "Option::is_none")]
1418    pub region: Option<String>,
1419    /// The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g.
1420    /// `America/Los_Angeles`.
1421    #[serde(skip_serializing_if = "Option::is_none")]
1422    pub timezone: Option<String>,
1423}
1424
1425/// Container configuration for a code interpreter.
1426#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1427#[serde(tag = "type", rename_all = "snake_case")]
1428pub enum CodeInterpreterToolContainer {
1429    /// Configuration for a code interpreter container. Optionally specify the IDs of the
1430    /// files to run the code on.
1431    Auto(CodeInterpreterContainerAuto),
1432
1433    /// The container ID.
1434    #[serde(untagged)]
1435    ContainerID(String),
1436}
1437
1438/// Auto configuration for code interpreter container.
1439#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1440pub struct CodeInterpreterContainerAuto {
1441    /// An optional list of uploaded files to make available to your code.
1442    #[serde(skip_serializing_if = "Option::is_none")]
1443    pub file_ids: Option<Vec<String>>,
1444
1445    #[serde(skip_serializing_if = "Option::is_none")]
1446    pub memory_limit: Option<u64>,
1447}
1448
1449#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1450#[builder(
1451    name = "CodeInterpreterToolArgs",
1452    pattern = "mutable",
1453    setter(into, strip_option),
1454    default
1455)]
1456#[builder(build_fn(error = "OpenAIError"))]
1457pub struct CodeInterpreterTool {
1458    /// The code interpreter container. Can be a container ID or an object that
1459    /// specifies uploaded file IDs to make available to your code, along with an
1460    /// optional `memory_limit` setting.
1461    pub container: CodeInterpreterToolContainer,
1462}
1463
1464#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1465pub struct ImageGenToolInputImageMask {
1466    /// Base64-encoded mask image.
1467    #[serde(skip_serializing_if = "Option::is_none")]
1468    pub image_url: Option<String>,
1469    /// File ID for the mask image.
1470    #[serde(skip_serializing_if = "Option::is_none")]
1471    pub file_id: Option<String>,
1472}
1473
1474#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1475#[serde(rename_all = "lowercase")]
1476pub enum InputFidelity {
1477    #[default]
1478    High,
1479    Low,
1480}
1481
1482#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1483#[serde(rename_all = "lowercase")]
1484pub enum ImageGenToolModeration {
1485    #[default]
1486    Auto,
1487    Low,
1488}
1489
1490/// Whether to generate a new image or edit an existing image.
1491#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1492#[serde(rename_all = "lowercase")]
1493pub enum ImageGenActionEnum {
1494    /// Generate a new image.
1495    Generate,
1496    /// Edit an existing image.
1497    Edit,
1498    /// Automatically determine whether to generate or edit.
1499    #[default]
1500    Auto,
1501}
1502
1503/// Image generation tool definition.
1504#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
1505#[builder(
1506    name = "ImageGenerationArgs",
1507    pattern = "mutable",
1508    setter(into, strip_option),
1509    default
1510)]
1511#[builder(build_fn(error = "OpenAIError"))]
1512pub struct ImageGenTool {
1513    /// Background type for the generated image. One of `transparent`,
1514    /// `opaque`, or `auto`. Default: `auto`.
1515    #[serde(skip_serializing_if = "Option::is_none")]
1516    pub background: Option<ImageGenToolBackground>,
1517    /// Control how much effort the model will exert to match the style and features, especially facial features,
1518    /// of input images. This parameter is only supported for `gpt-image-1`. Unsupported
1519    /// for `gpt-image-1-mini`. Supports `high` and `low`. Defaults to `low`.
1520    #[serde(skip_serializing_if = "Option::is_none")]
1521    pub input_fidelity: Option<InputFidelity>,
1522    /// Optional mask for inpainting. Contains `image_url`
1523    /// (string, optional) and `file_id` (string, optional).
1524    #[serde(skip_serializing_if = "Option::is_none")]
1525    pub input_image_mask: Option<ImageGenToolInputImageMask>,
1526    /// The image generation model to use. Default: `gpt-image-1`.
1527    #[serde(skip_serializing_if = "Option::is_none")]
1528    pub model: Option<String>,
1529    /// Moderation level for the generated image. Default: `auto`.
1530    #[serde(skip_serializing_if = "Option::is_none")]
1531    pub moderation: Option<ImageGenToolModeration>,
1532    /// Compression level for the output image. Default: 100.
1533    #[serde(skip_serializing_if = "Option::is_none")]
1534    pub output_compression: Option<u8>,
1535    /// The output format of the generated image. One of `png`, `webp`, or
1536    /// `jpeg`. Default: `png`.
1537    #[serde(skip_serializing_if = "Option::is_none")]
1538    pub output_format: Option<ImageGenToolOutputFormat>,
1539    /// Number of partial images to generate in streaming mode, from 0 (default value) to 3.
1540    #[serde(skip_serializing_if = "Option::is_none")]
1541    pub partial_images: Option<u8>,
1542    /// The quality of the generated image. One of `low`, `medium`, `high`,
1543    /// or `auto`. Default: `auto`.
1544    #[serde(skip_serializing_if = "Option::is_none")]
1545    pub quality: Option<ImageGenToolQuality>,
1546    /// The size of the generated image. One of `1024x1024`, `1024x1536`,
1547    /// `1536x1024`, or `auto`. Default: `auto`.
1548    #[serde(skip_serializing_if = "Option::is_none")]
1549    pub size: Option<ImageGenToolSize>,
1550    /// Whether to generate a new image or edit an existing image. Default: `auto`.
1551    #[serde(skip_serializing_if = "Option::is_none")]
1552    pub action: Option<ImageGenActionEnum>,
1553}
1554
1555#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1556#[serde(rename_all = "lowercase")]
1557pub enum ImageGenToolBackground {
1558    Transparent,
1559    Opaque,
1560    #[default]
1561    Auto,
1562}
1563
1564#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1565#[serde(rename_all = "lowercase")]
1566pub enum ImageGenToolOutputFormat {
1567    #[default]
1568    Png,
1569    Webp,
1570    Jpeg,
1571}
1572
1573#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1574#[serde(rename_all = "lowercase")]
1575pub enum ImageGenToolQuality {
1576    Low,
1577    Medium,
1578    High,
1579    #[default]
1580    Auto,
1581}
1582
1583#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1584#[serde(rename_all = "lowercase")]
1585pub enum ImageGenToolSize {
1586    #[default]
1587    Auto,
1588    #[serde(rename = "1024x1024")]
1589    Size1024x1024,
1590    #[serde(rename = "1024x1536")]
1591    Size1024x1536,
1592    #[serde(rename = "1536x1024")]
1593    Size1536x1024,
1594}
1595
1596#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1597#[serde(rename_all = "lowercase")]
1598pub enum ToolChoiceAllowedMode {
1599    Auto,
1600    Required,
1601}
1602
1603#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1604pub struct ToolChoiceAllowed {
1605    /// Constrains the tools available to the model to a pre-defined set.
1606    ///
1607    /// `auto` allows the model to pick from among the allowed tools and generate a
1608    /// message.
1609    ///
1610    /// `required` requires the model to call one or more of the allowed tools.
1611    pub mode: ToolChoiceAllowedMode,
1612    /// A list of tool definitions that the model should be allowed to call.
1613    ///
1614    /// For the Responses API, the list of tool definitions might look like:
1615    /// ```json
1616    /// [
1617    ///   { "type": "function", "name": "get_weather" },
1618    ///   { "type": "mcp", "server_label": "deepwiki" },
1619    ///   { "type": "image_generation" }
1620    /// ]
1621    /// ```
1622    pub tools: Vec<serde_json::Value>,
1623}
1624
1625/// The type of hosted tool the model should to use. Learn more about
1626/// [built-in tools](https://platform.openai.com/docs/guides/tools).
1627#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1628#[serde(tag = "type", rename_all = "snake_case")]
1629pub enum ToolChoiceTypes {
1630    FileSearch,
1631    WebSearchPreview,
1632    Computer,
1633    ComputerUsePreview,
1634    ComputerUse,
1635    #[serde(rename = "web_search_preview_2025_03_11")]
1636    WebSearchPreview20250311,
1637    CodeInterpreter,
1638    ImageGeneration,
1639}
1640
1641#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1642pub struct ToolChoiceFunction {
1643    /// The name of the function to call.
1644    pub name: String,
1645}
1646
1647#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1648pub struct ToolChoiceMCP {
1649    /// The name of the tool to call on the server.
1650    pub name: String,
1651    /// The label of the MCP server to use.
1652    pub server_label: String,
1653}
1654
1655#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1656pub struct ToolChoiceCustom {
1657    /// The name of the custom tool to call.
1658    pub name: String,
1659}
1660
1661#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1662#[serde(tag = "type", rename_all = "snake_case")]
1663pub enum ToolChoiceParam {
1664    /// Constrains the tools available to the model to a pre-defined set.
1665    AllowedTools(ToolChoiceAllowed),
1666
1667    /// Use this option to force the model to call a specific function.
1668    Function(ToolChoiceFunction),
1669
1670    /// Use this option to force the model to call a specific tool on a remote MCP server.
1671    Mcp(ToolChoiceMCP),
1672
1673    /// Use this option to force the model to call a custom tool.
1674    Custom(ToolChoiceCustom),
1675
1676    /// Forces the model to call the apply_patch tool when executing a tool call.
1677    ApplyPatch,
1678
1679    /// Forces the model to call the function shell tool when a tool call is required.
1680    Shell,
1681
1682    /// Indicates that the model should use a built-in tool to generate a response.
1683    /// [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
1684    #[serde(untagged)]
1685    Hosted(ToolChoiceTypes),
1686
1687    /// Controls which (if any) tool is called by the model.
1688    ///
1689    /// `none` means the model will not call any tool and instead generates a message.
1690    ///
1691    /// `auto` means the model can pick between generating a message or calling one or
1692    /// more tools.
1693    ///
1694    /// `required` means the model must call one or more tools.
1695    #[serde(untagged)]
1696    Mode(ToolChoiceOptions),
1697}
1698
1699#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
1700#[serde(rename_all = "lowercase")]
1701pub enum ToolChoiceOptions {
1702    None,
1703    Auto,
1704    Required,
1705}
1706
1707/// An error that occurred while generating the response.
1708#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1709pub struct ErrorObject {
1710    /// A machine-readable error code that was returned.
1711    pub code: String,
1712    /// A human-readable description of the error that was returned.
1713    pub message: String,
1714}
1715
1716/// Details about an incomplete response.
1717#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1718pub struct IncompleteDetails {
1719    /// The reason why the response is incomplete.
1720    pub reason: String,
1721}
1722
1723#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1724pub struct TopLogProb {
1725    pub bytes: Vec<u8>,
1726    pub logprob: f64,
1727    pub token: String,
1728}
1729
1730#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1731pub struct LogProb {
1732    pub bytes: Vec<u8>,
1733    pub logprob: f64,
1734    pub token: String,
1735    pub top_logprobs: Vec<TopLogProb>,
1736}
1737
1738#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1739pub struct ResponseTopLobProb {
1740    /// The log probability of this token.
1741    pub logprob: f64,
1742    /// A possible text token.
1743    pub token: String,
1744}
1745
1746#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1747pub struct ResponseLogProb {
1748    /// The log probability of this token.
1749    pub logprob: f64,
1750    /// A possible text token.
1751    pub token: String,
1752    /// The log probability of the top 20 most likely tokens.
1753    pub top_logprobs: Vec<ResponseTopLobProb>,
1754}
1755
1756/// A simple text output from the model.
1757#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1758pub struct OutputTextContent {
1759    /// The annotations of the text output.
1760    pub annotations: Vec<Annotation>,
1761    pub logprobs: Option<Vec<LogProb>>,
1762    /// The text output from the model.
1763    pub text: String,
1764}
1765
1766/// An annotation that applies to a span of output text.
1767#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1768#[serde(tag = "type", rename_all = "snake_case")]
1769pub enum Annotation {
1770    /// A citation to a file.
1771    FileCitation(FileCitationBody),
1772    /// A citation for a web resource used to generate a model response.
1773    UrlCitation(UrlCitationBody),
1774    /// A citation for a container file used to generate a model response.
1775    ContainerFileCitation(ContainerFileCitationBody),
1776    /// A path to a file.
1777    FilePath(FilePath),
1778}
1779
1780#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1781pub struct FileCitationBody {
1782    /// The ID of the file.
1783    file_id: String,
1784    /// The filename of the file cited.
1785    filename: String,
1786    /// The index of the file in the list of files.
1787    index: u32,
1788}
1789
1790#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1791pub struct UrlCitationBody {
1792    /// The index of the last character of the URL citation in the message.
1793    end_index: u32,
1794    /// The index of the first character of the URL citation in the message.
1795    start_index: u32,
1796    /// The title of the web resource.
1797    title: String,
1798    /// The URL of the web resource.
1799    url: String,
1800}
1801
1802#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1803pub struct ContainerFileCitationBody {
1804    /// The ID of the container file.
1805    container_id: String,
1806    /// The index of the last character of the container file citation in the message.
1807    end_index: u32,
1808    /// The ID of the file.
1809    file_id: String,
1810    /// The filename of the container file cited.
1811    filename: String,
1812    /// The index of the first character of the container file citation in the message.
1813    start_index: u32,
1814}
1815
1816#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1817pub struct FilePath {
1818    /// The ID of the file.
1819    file_id: String,
1820    /// The index of the file in the list of files.
1821    index: u32,
1822}
1823
1824/// A refusal explanation from the model.
1825#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1826pub struct RefusalContent {
1827    /// The refusal explanation from the model.
1828    pub refusal: String,
1829}
1830
1831/// A message generated by the model.
1832#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1833pub struct OutputMessage {
1834    /// The content of the output message.
1835    pub content: Vec<OutputMessageContent>,
1836    /// The unique ID of the output message.
1837    pub id: String,
1838    /// The role of the output message. Always `assistant`.
1839    pub role: AssistantRole,
1840    /// Labels this assistant message as intermediate commentary (`commentary`) or
1841    /// the final answer (`final_answer`).
1842    #[serde(skip_serializing_if = "Option::is_none")]
1843    pub phase: Option<MessagePhase>,
1844    /// The status of the message input. One of `in_progress`, `completed`, or
1845    /// `incomplete`. Populated when input items are returned via API.
1846    pub status: OutputStatus,
1847    ///// The type of the output message. Always `message`.
1848    //pub r#type: MessageType,
1849}
1850
1851#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
1852#[serde(rename_all = "lowercase")]
1853pub enum MessageType {
1854    #[default]
1855    Message,
1856}
1857
1858/// The role for an output message - always `assistant`.
1859/// This type ensures type safety by only allowing the assistant role.
1860#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Default)]
1861#[serde(rename_all = "lowercase")]
1862pub enum AssistantRole {
1863    #[default]
1864    Assistant,
1865}
1866
1867#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1868#[serde(tag = "type", rename_all = "snake_case")]
1869pub enum OutputMessageContent {
1870    /// A text output from the model.
1871    OutputText(OutputTextContent),
1872    /// A refusal from the model.
1873    Refusal(RefusalContent),
1874}
1875
1876#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1877#[serde(tag = "type", rename_all = "snake_case")]
1878pub enum OutputContent {
1879    /// A text output from the model.
1880    OutputText(OutputTextContent),
1881    /// A refusal from the model.
1882    Refusal(RefusalContent),
1883    /// Reasoning text from the model.
1884    ReasoningText(ReasoningTextContent),
1885}
1886
1887#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1888pub struct ReasoningTextContent {
1889    /// The reasoning text from the model.
1890    pub text: String,
1891}
1892
1893/// [ReasoningTextContent] used elsewhere which adds type,
1894/// but here in [ReasoningItem] content field we need type too hence an enum:
1895#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1896#[serde(tag = "type", rename_all = "snake_case")]
1897pub enum ReasoningItemContent {
1898    ReasoningText(ReasoningTextContent),
1899}
1900
1901/// A reasoning item representing the model's chain of thought, including summary paragraphs.
1902#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1903pub struct ReasoningItem {
1904    /// Unique identifier of the reasoning content.
1905    pub id: Option<String>,
1906    /// Reasoning summary content.
1907    pub summary: Vec<SummaryPart>,
1908    /// Reasoning text content.
1909    #[serde(skip_serializing_if = "Option::is_none")]
1910    pub content: Option<Vec<ReasoningItemContent>>,
1911    /// The encrypted content of the reasoning item - populated when a response is generated with
1912    /// `reasoning.encrypted_content` in the `include` parameter.
1913    #[serde(skip_serializing_if = "Option::is_none")]
1914    pub encrypted_content: Option<String>,
1915    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
1916    /// Populated when items are returned via API.
1917    #[serde(skip_serializing_if = "Option::is_none")]
1918    pub status: Option<OutputStatus>,
1919}
1920
1921#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1922#[serde(tag = "type", rename_all = "snake_case")]
1923pub enum SummaryPart {
1924    SummaryText(SummaryTextContent),
1925}
1926
1927/// File search tool call output.
1928#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1929pub struct FileSearchToolCall {
1930    /// The unique ID of the file search tool call.
1931    pub id: String,
1932    /// The queries used to search for files.
1933    pub queries: Vec<String>,
1934    /// The status of the file search tool call. One of `in_progress`, `searching`,
1935    /// `incomplete`,`failed`, or `completed`.
1936    pub status: FileSearchToolCallStatus,
1937    /// The results of the file search tool call.
1938    #[serde(skip_serializing_if = "Option::is_none")]
1939    pub results: Option<Vec<FileSearchToolCallResult>>,
1940}
1941
1942#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1943#[serde(rename_all = "snake_case")]
1944pub enum FileSearchToolCallStatus {
1945    InProgress,
1946    Searching,
1947    Incomplete,
1948    Failed,
1949    Completed,
1950}
1951
1952/// A single result from a file search.
1953#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1954pub struct FileSearchToolCallResult {
1955    /// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
1956    /// additional information about the object in a structured format, and querying for objects
1957    /// API or the dashboard. Keys are strings with a maximum length of 64 characters
1958    /// . Values are strings with a maximum length of 512 characters, booleans, or numbers.
1959    pub attributes: HashMap<String, serde_json::Value>,
1960    /// The unique ID of the file.
1961    pub file_id: String,
1962    /// The name of the file.
1963    pub filename: String,
1964    /// The relevance score of the file - a value between 0 and 1.
1965    pub score: f32,
1966    /// The text that was retrieved from the file.
1967    pub text: String,
1968}
1969
1970#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1971pub struct ComputerCallSafetyCheckParam {
1972    /// The ID of the pending safety check.
1973    pub id: String,
1974    /// The type of the pending safety check.
1975    #[serde(skip_serializing_if = "Option::is_none")]
1976    pub code: Option<String>,
1977    /// Details about the pending safety check.
1978    #[serde(skip_serializing_if = "Option::is_none")]
1979    pub message: Option<String>,
1980}
1981
1982#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1983#[serde(rename_all = "snake_case")]
1984pub enum WebSearchToolCallStatus {
1985    InProgress,
1986    Searching,
1987    Completed,
1988    Failed,
1989}
1990
1991#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1992pub struct WebSearchActionSearchSource {
1993    /// The type of source. Always `url`.
1994    pub r#type: String,
1995    /// The URL of the source.
1996    pub url: String,
1997}
1998
1999#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2000pub struct WebSearchActionSearch {
2001    /// The search query.
2002    pub query: String,
2003    /// The sources used in the search.
2004    pub sources: Option<Vec<WebSearchActionSearchSource>>,
2005}
2006
2007#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2008pub struct WebSearchActionOpenPage {
2009    /// The URL opened by the model.
2010    pub url: Option<String>,
2011}
2012
2013#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2014pub struct WebSearchActionFind {
2015    /// The URL of the page searched for the pattern.
2016    pub url: String,
2017    /// The pattern or text to search for within the page.
2018    pub pattern: String,
2019}
2020
2021#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2022#[serde(tag = "type", rename_all = "snake_case")]
2023pub enum WebSearchToolCallAction {
2024    /// Action type "search" - Performs a web search query.
2025    Search(WebSearchActionSearch),
2026    /// Action type "open_page" - Opens a specific URL from search results.
2027    OpenPage(WebSearchActionOpenPage),
2028    /// Action type "find": Searches for a pattern within a loaded page.
2029    Find(WebSearchActionFind),
2030    /// Action type "find_in_page": <https://platform.openai.com/docs/guides/tools-web-search#output-and-citations>
2031    FindInPage(WebSearchActionFind),
2032}
2033
2034/// Web search tool call output.
2035#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2036pub struct WebSearchToolCall {
2037    /// An object describing the specific action taken in this web search call. Includes
2038    /// details on how the model used the web (search, open_page, find, find_in_page).
2039    ///
2040    /// This is optional because `response.output_item.added` events can include
2041    /// in-progress web search calls before OpenAI has populated the action.
2042    /// See <https://github.com/64bit/async-openai/issues/548>.
2043    #[serde(skip_serializing_if = "Option::is_none")]
2044    pub action: Option<WebSearchToolCallAction>,
2045    /// The unique ID of the web search tool call.
2046    pub id: String,
2047    /// The status of the web search tool call.
2048    pub status: WebSearchToolCallStatus,
2049}
2050
2051/// Output from a computer tool call.
2052#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2053pub struct ComputerToolCall {
2054    #[serde(skip_serializing_if = "Option::is_none")]
2055    pub action: Option<ComputerAction>,
2056    /// Flattened batched actions for `computer_use`. Each action includes a
2057    /// `type` discriminator and action-specific fields.
2058    #[serde(skip_serializing_if = "Option::is_none")]
2059    pub actions: Option<Vec<ComputerAction>>,
2060    /// An identifier used when responding to the tool call with output.
2061    pub call_id: String,
2062    /// The unique ID of the computer call.
2063    pub id: String,
2064    /// The pending safety checks for the computer call.
2065    pub pending_safety_checks: Vec<ComputerCallSafetyCheckParam>,
2066    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2067    /// Populated when items are returned via API.
2068    pub status: OutputStatus,
2069}
2070
2071/// An x/y coordinate pair.
2072#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2073pub struct CoordParam {
2074    /// The x-coordinate.
2075    pub x: i32,
2076    /// The y-coordinate.
2077    pub y: i32,
2078}
2079
2080/// Represents all user‐triggered actions.
2081#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2082#[serde(tag = "type", rename_all = "snake_case")]
2083pub enum ComputerAction {
2084    /// A click action.
2085    Click(ClickParam),
2086
2087    /// A double click action.
2088    DoubleClick(DoubleClickAction),
2089
2090    /// A drag action.
2091    Drag(DragParam),
2092
2093    /// A collection of keypresses the model would like to perform.
2094    Keypress(KeyPressAction),
2095
2096    /// A mouse move action.
2097    Move(MoveParam),
2098
2099    /// A screenshot action.
2100    Screenshot,
2101
2102    /// A scroll action.
2103    Scroll(ScrollParam),
2104
2105    /// An action to type in text.
2106    Type(TypeParam),
2107
2108    /// A wait action.
2109    Wait,
2110}
2111
2112#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2113#[serde(rename_all = "lowercase")]
2114pub enum ClickButtonType {
2115    Left,
2116    Right,
2117    Wheel,
2118    Back,
2119    Forward,
2120}
2121
2122/// A click action.
2123#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2124pub struct ClickParam {
2125    /// Indicates which mouse button was pressed during the click. One of `left`,
2126    /// `right`, `wheel`, `back`, or `forward`.
2127    pub button: ClickButtonType,
2128    /// The x-coordinate where the click occurred.
2129    pub x: i32,
2130    /// The y-coordinate where the click occurred.
2131    pub y: i32,
2132    /// The keys being held while clicking.
2133    #[serde(skip_serializing_if = "Option::is_none")]
2134    pub keys: Option<Vec<String>>,
2135}
2136
2137/// A double click action.
2138#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2139pub struct DoubleClickAction {
2140    /// The x-coordinate where the double click occurred.
2141    pub x: i32,
2142    /// The y-coordinate where the double click occurred.
2143    pub y: i32,
2144    /// The keys being held while double clicking.
2145    pub keys: Option<Vec<String>>,
2146}
2147
2148/// A drag action.
2149#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2150pub struct DragParam {
2151    /// An array of coordinates representing the path of the drag action.
2152    pub path: Vec<CoordParam>,
2153    /// The keys being held while dragging the mouse.
2154    #[serde(skip_serializing_if = "Option::is_none")]
2155    pub keys: Option<Vec<String>>,
2156}
2157
2158/// A keypress action.
2159#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2160pub struct KeyPressAction {
2161    /// The combination of keys the model is requesting to be pressed.
2162    /// This is an array of strings, each representing a key.
2163    pub keys: Vec<String>,
2164}
2165
2166/// A mouse move action.
2167#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2168pub struct MoveParam {
2169    /// The x-coordinate to move to.
2170    pub x: i32,
2171    /// The y-coordinate to move to.
2172    pub y: i32,
2173    /// The keys being held while moving the mouse.
2174    #[serde(skip_serializing_if = "Option::is_none")]
2175    pub keys: Option<Vec<String>>,
2176}
2177
2178/// A scroll action.
2179#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2180pub struct ScrollParam {
2181    /// The horizontal scroll distance.
2182    pub scroll_x: i32,
2183    /// The vertical scroll distance.
2184    pub scroll_y: i32,
2185    /// The x-coordinate where the scroll occurred.
2186    pub x: i32,
2187    /// The y-coordinate where the scroll occurred.
2188    pub y: i32,
2189    /// The keys being held while scrolling.
2190    #[serde(skip_serializing_if = "Option::is_none")]
2191    pub keys: Option<Vec<String>>,
2192}
2193
2194/// A typing (text entry) action.
2195#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
2196pub struct TypeParam {
2197    /// The text to type.
2198    pub text: String,
2199}
2200
2201#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2202pub struct FunctionToolCall {
2203    /// A JSON string of the arguments to pass to the function.
2204    pub arguments: String,
2205    /// The unique ID of the function tool call generated by the model.
2206    pub call_id: String,
2207    /// The namespace of the function to run.
2208    #[serde(skip_serializing_if = "Option::is_none")]
2209    pub namespace: Option<String>,
2210    /// The name of the function to run.
2211    pub name: String,
2212    /// The unique ID of the function tool call.
2213    #[serde(skip_serializing_if = "Option::is_none")]
2214    pub id: Option<String>,
2215    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2216    /// Populated when items are returned via API.
2217    #[serde(skip_serializing_if = "Option::is_none")]
2218    pub status: Option<OutputStatus>,
2219}
2220
2221/// A function tool call item returned by the API.
2222#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2223pub struct FunctionToolCallResource {
2224    /// A JSON string of the arguments to pass to the function.
2225    pub arguments: String,
2226    /// The unique ID of the function tool call generated by the model.
2227    pub call_id: String,
2228    /// The namespace of the function to run.
2229    #[serde(skip_serializing_if = "Option::is_none")]
2230    pub namespace: Option<String>,
2231    /// The name of the function to run.
2232    pub name: String,
2233    /// The unique ID of the function tool call.
2234    pub id: String,
2235    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2236    pub status: FunctionCallStatus,
2237    /// The identifier of the actor that created the item.
2238    #[serde(skip_serializing_if = "Option::is_none")]
2239    pub created_by: Option<String>,
2240}
2241
2242/// A function tool call output item returned by the API.
2243#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2244pub struct FunctionToolCallOutputResource {
2245    /// The unique ID of the function tool call generated by the model.
2246    pub call_id: String,
2247    /// Text, image, or file output of the function tool call.
2248    pub output: FunctionCallOutput,
2249    /// The unique ID of the function tool call output.
2250    pub id: String,
2251    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
2252    pub status: FunctionCallOutputStatusEnum,
2253    /// The identifier of the actor that created the item.
2254    #[serde(skip_serializing_if = "Option::is_none")]
2255    pub created_by: Option<String>,
2256}
2257
2258#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2259#[serde(rename_all = "snake_case")]
2260pub enum ImageGenToolCallStatus {
2261    InProgress,
2262    Completed,
2263    Generating,
2264    Failed,
2265}
2266
2267#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2268pub struct ImageGenToolCall {
2269    /// The unique ID of the image generation call.
2270    pub id: String,
2271    /// The generated image encoded in base64.
2272    pub result: Option<String>,
2273    /// The status of the image generation call.
2274    pub status: ImageGenToolCallStatus,
2275}
2276
2277#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2278#[serde(rename_all = "snake_case")]
2279pub enum CodeInterpreterToolCallStatus {
2280    InProgress,
2281    Completed,
2282    Incomplete,
2283    Interpreting,
2284    Failed,
2285}
2286
2287/// Output of a code interpreter request.
2288#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2289pub struct CodeInterpreterToolCall {
2290    /// The code to run, or null if not available.
2291    #[serde(skip_serializing_if = "Option::is_none")]
2292    pub code: Option<String>,
2293    /// ID of the container used to run the code.
2294    pub container_id: String,
2295    /// The unique ID of the code interpreter tool call.
2296    pub id: String,
2297    /// The outputs generated by the code interpreter, such as logs or images.
2298    /// Can be null if no outputs are available.
2299    #[serde(skip_serializing_if = "Option::is_none")]
2300    pub outputs: Option<Vec<CodeInterpreterToolCallOutput>>,
2301    /// The status of the code interpreter tool call.
2302    /// Valid values are `in_progress`, `completed`, `incomplete`, `interpreting`, and `failed`.
2303    pub status: CodeInterpreterToolCallStatus,
2304}
2305
2306/// Individual result from a code interpreter: either logs or files.
2307#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2308#[serde(tag = "type", rename_all = "snake_case")]
2309pub enum CodeInterpreterToolCallOutput {
2310    /// Code interpreter output logs
2311    Logs(CodeInterpreterOutputLogs),
2312    /// Code interpreter output image
2313    Image(CodeInterpreterOutputImage),
2314}
2315
2316#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2317pub struct CodeInterpreterOutputLogs {
2318    /// The logs output from the code interpreter.
2319    pub logs: String,
2320}
2321
2322#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2323pub struct CodeInterpreterOutputImage {
2324    /// The URL of the image output from the code interpreter.
2325    pub url: String,
2326}
2327
2328#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2329pub struct CodeInterpreterFile {
2330    /// The ID of the file.
2331    file_id: String,
2332    /// The MIME type of the file.
2333    mime_type: String,
2334}
2335
2336#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2337pub struct LocalShellToolCall {
2338    /// Execute a shell command on the server.
2339    pub action: LocalShellExecAction,
2340    /// The unique ID of the local shell tool call generated by the model.
2341    pub call_id: String,
2342    /// The unique ID of the local shell call.
2343    pub id: String,
2344    /// The status of the local shell call.
2345    pub status: OutputStatus,
2346}
2347
2348/// Define the shape of a local shell action (exec).
2349#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2350pub struct LocalShellExecAction {
2351    /// The command to run.
2352    pub command: Vec<String>,
2353    /// Environment variables to set for the command.
2354    pub env: HashMap<String, String>,
2355    /// Optional timeout in milliseconds for the command.
2356    pub timeout_ms: Option<u64>,
2357    /// Optional user to run the command as.
2358    pub user: Option<String>,
2359    /// Optional working directory to run the command in.
2360    pub working_directory: Option<String>,
2361}
2362
2363/// Commands and limits describing how to run the shell tool call.
2364#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2365pub struct FunctionShellActionParam {
2366    /// Ordered shell commands for the execution environment to run.
2367    pub commands: Vec<String>,
2368    /// Maximum wall-clock time in milliseconds to allow the shell commands to run.
2369    #[serde(skip_serializing_if = "Option::is_none")]
2370    pub timeout_ms: Option<u64>,
2371    /// Maximum number of UTF-8 characters to capture from combined stdout and stderr output.
2372    #[serde(skip_serializing_if = "Option::is_none")]
2373    pub max_output_length: Option<u64>,
2374}
2375
2376/// Status values reported for shell tool calls.
2377#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2378#[serde(rename_all = "snake_case")]
2379pub enum FunctionShellCallItemStatus {
2380    InProgress,
2381    Completed,
2382    Incomplete,
2383}
2384
2385/// The environment for a shell call item (request side).
2386#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2387#[serde(tag = "type", rename_all = "snake_case")]
2388pub enum FunctionShellCallItemEnvironment {
2389    /// Use a local computer environment.
2390    Local(LocalEnvironmentParam),
2391    /// Reference an existing container by ID.
2392    ContainerReference(ContainerReferenceParam),
2393}
2394
2395/// A tool representing a request to execute one or more shell commands.
2396#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2397pub struct FunctionShellCallItemParam {
2398    /// The unique ID of the shell tool call. Populated when this item is returned via API.
2399    #[serde(skip_serializing_if = "Option::is_none")]
2400    pub id: Option<String>,
2401    /// The unique ID of the shell tool call generated by the model.
2402    pub call_id: String,
2403    /// The shell commands and limits that describe how to run the tool call.
2404    pub action: FunctionShellActionParam,
2405    /// The status of the shell call. One of `in_progress`, `completed`, or `incomplete`.
2406    #[serde(skip_serializing_if = "Option::is_none")]
2407    pub status: Option<FunctionShellCallItemStatus>,
2408    /// The environment to execute the shell commands in.
2409    #[serde(skip_serializing_if = "Option::is_none")]
2410    pub environment: Option<FunctionShellCallItemEnvironment>,
2411}
2412
2413/// Indicates that the shell commands finished and returned an exit code.
2414#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2415pub struct FunctionShellCallOutputExitOutcomeParam {
2416    /// The exit code returned by the shell process.
2417    pub exit_code: i32,
2418}
2419
2420/// The exit or timeout outcome associated with this chunk.
2421#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2422#[serde(tag = "type", rename_all = "snake_case")]
2423pub enum FunctionShellCallOutputOutcomeParam {
2424    Timeout,
2425    Exit(FunctionShellCallOutputExitOutcomeParam),
2426}
2427
2428/// Captured stdout and stderr for a portion of a shell tool call output.
2429#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2430pub struct FunctionShellCallOutputContentParam {
2431    /// Captured stdout output for this chunk of the shell call.
2432    pub stdout: String,
2433    /// Captured stderr output for this chunk of the shell call.
2434    pub stderr: String,
2435    /// The exit or timeout outcome associated with this chunk.
2436    pub outcome: FunctionShellCallOutputOutcomeParam,
2437}
2438
2439/// The streamed output items emitted by a shell tool call.
2440#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2441pub struct FunctionShellCallOutputItemParam {
2442    /// The unique ID of the shell tool call output. Populated when this item is returned via API.
2443    #[serde(skip_serializing_if = "Option::is_none")]
2444    pub id: Option<String>,
2445    /// The unique ID of the shell tool call generated by the model.
2446    pub call_id: String,
2447    /// Captured chunks of stdout and stderr output, along with their associated outcomes.
2448    pub output: Vec<FunctionShellCallOutputContentParam>,
2449    /// The maximum number of UTF-8 characters captured for this shell call's combined output.
2450    #[serde(skip_serializing_if = "Option::is_none")]
2451    pub max_output_length: Option<u64>,
2452}
2453
2454/// Status values reported for apply_patch tool calls.
2455#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2456#[serde(rename_all = "snake_case")]
2457pub enum ApplyPatchCallStatusParam {
2458    InProgress,
2459    Completed,
2460}
2461
2462/// Instruction for creating a new file via the apply_patch tool.
2463#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2464pub struct ApplyPatchCreateFileOperationParam {
2465    /// Path of the file to create relative to the workspace root.
2466    pub path: String,
2467    /// Unified diff content to apply when creating the file.
2468    pub diff: String,
2469}
2470
2471/// Instruction for deleting an existing file via the apply_patch tool.
2472#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2473pub struct ApplyPatchDeleteFileOperationParam {
2474    /// Path of the file to delete relative to the workspace root.
2475    pub path: String,
2476}
2477
2478/// Instruction for updating an existing file via the apply_patch tool.
2479#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2480pub struct ApplyPatchUpdateFileOperationParam {
2481    /// Path of the file to update relative to the workspace root.
2482    pub path: String,
2483    /// Unified diff content to apply to the existing file.
2484    pub diff: String,
2485}
2486
2487/// One of the create_file, delete_file, or update_file operations supplied to the apply_patch tool.
2488#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2489#[serde(tag = "type", rename_all = "snake_case")]
2490pub enum ApplyPatchOperationParam {
2491    CreateFile(ApplyPatchCreateFileOperationParam),
2492    DeleteFile(ApplyPatchDeleteFileOperationParam),
2493    UpdateFile(ApplyPatchUpdateFileOperationParam),
2494}
2495
2496/// A tool call representing a request to create, delete, or update files using diff patches.
2497#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2498pub struct ApplyPatchToolCallItemParam {
2499    /// The unique ID of the apply patch tool call. Populated when this item is returned via API.
2500    #[serde(skip_serializing_if = "Option::is_none")]
2501    pub id: Option<String>,
2502    /// The unique ID of the apply patch tool call generated by the model.
2503    pub call_id: String,
2504    /// The status of the apply patch tool call. One of `in_progress` or `completed`.
2505    pub status: ApplyPatchCallStatusParam,
2506    /// The specific create, delete, or update instruction for the apply_patch tool call.
2507    pub operation: ApplyPatchOperationParam,
2508}
2509
2510/// Outcome values reported for apply_patch tool call outputs.
2511#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2512#[serde(rename_all = "snake_case")]
2513pub enum ApplyPatchCallOutputStatusParam {
2514    Completed,
2515    Failed,
2516}
2517
2518/// The streamed output emitted by an apply patch tool call.
2519#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2520pub struct ApplyPatchToolCallOutputItemParam {
2521    /// The unique ID of the apply patch tool call output. Populated when this item is returned via API.
2522    #[serde(skip_serializing_if = "Option::is_none")]
2523    pub id: Option<String>,
2524    /// The unique ID of the apply patch tool call generated by the model.
2525    pub call_id: String,
2526    /// The status of the apply patch tool call output. One of `completed` or `failed`.
2527    pub status: ApplyPatchCallOutputStatusParam,
2528    /// Optional human-readable log text from the apply patch tool (e.g., patch results or errors).
2529    #[serde(skip_serializing_if = "Option::is_none")]
2530    pub output: Option<String>,
2531}
2532
2533/// Shell exec action
2534/// Execute a shell command.
2535#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2536pub struct FunctionShellAction {
2537    /// A list of commands to run.
2538    pub commands: Vec<String>,
2539    /// Optional timeout in milliseconds for the commands.
2540    pub timeout_ms: Option<u64>,
2541    /// Optional maximum number of characters to return from each command.
2542    pub max_output_length: Option<u64>,
2543}
2544
2545/// Status values reported for function shell tool calls.
2546#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2547#[serde(rename_all = "snake_case")]
2548pub enum LocalShellCallStatus {
2549    InProgress,
2550    Completed,
2551    Incomplete,
2552}
2553
2554/// The environment for a shell call (response side).
2555#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2556#[serde(tag = "type", rename_all = "snake_case")]
2557pub enum FunctionShellCallEnvironment {
2558    /// A local computer environment.
2559    Local,
2560    /// A referenced container.
2561    ContainerReference(ContainerReferenceResource),
2562}
2563
2564/// A tool call that executes one or more shell commands in a managed environment.
2565#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2566pub struct FunctionShellCall {
2567    /// The unique ID of the function shell tool call. Populated when this item is returned via API.
2568    pub id: String,
2569    /// The unique ID of the function shell tool call generated by the model.
2570    pub call_id: String,
2571    /// The shell commands and limits that describe how to run the tool call.
2572    pub action: FunctionShellAction,
2573    /// The status of the shell call. One of `in_progress`, `completed`, or `incomplete`.
2574    pub status: LocalShellCallStatus,
2575    /// The environment in which the shell commands were executed.
2576    pub environment: Option<FunctionShellCallEnvironment>,
2577    /// The ID of the entity that created this tool call.
2578    #[serde(skip_serializing_if = "Option::is_none")]
2579    pub created_by: Option<String>,
2580}
2581
2582/// The content of a shell tool call output that was emitted.
2583#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2584pub struct FunctionShellCallOutputContent {
2585    /// The standard output that was captured.
2586    pub stdout: String,
2587    /// The standard error output that was captured.
2588    pub stderr: String,
2589    /// Represents either an exit outcome (with an exit code) or a timeout outcome for a shell call output chunk.
2590    #[serde(flatten)]
2591    pub outcome: FunctionShellCallOutputOutcome,
2592    /// The identifier of the actor that created the item.
2593    #[serde(skip_serializing_if = "Option::is_none")]
2594    pub created_by: Option<String>,
2595}
2596
2597/// Function shell call outcome
2598#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2599#[serde(tag = "type", rename_all = "snake_case")]
2600pub enum FunctionShellCallOutputOutcome {
2601    Timeout,
2602    Exit(FunctionShellCallOutputExitOutcome),
2603}
2604
2605/// Indicates that the shell commands finished and returned an exit code.
2606#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2607pub struct FunctionShellCallOutputExitOutcome {
2608    /// Exit code from the shell process.
2609    pub exit_code: i32,
2610}
2611
2612/// The output of a shell tool call that was emitted.
2613#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2614pub struct FunctionShellCallOutput {
2615    /// The unique ID of the shell call output. Populated when this item is returned via API.
2616    pub id: String,
2617    /// The unique ID of the shell tool call generated by the model.
2618    pub call_id: String,
2619    /// An array of shell call output contents
2620    pub output: Vec<FunctionShellCallOutputContent>,
2621    /// The maximum length of the shell command output. This is generated by the model and should be
2622    /// passed back with the raw output.
2623    pub max_output_length: Option<u64>,
2624    /// The identifier of the actor that created the item.
2625    #[serde(skip_serializing_if = "Option::is_none")]
2626    pub created_by: Option<String>,
2627}
2628
2629/// Status values reported for apply_patch tool calls.
2630#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2631#[serde(rename_all = "snake_case")]
2632pub enum ApplyPatchCallStatus {
2633    InProgress,
2634    Completed,
2635}
2636
2637/// Instruction describing how to create a file via the apply_patch tool.
2638#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2639pub struct ApplyPatchCreateFileOperation {
2640    /// Path of the file to create.
2641    pub path: String,
2642    /// Diff to apply.
2643    pub diff: String,
2644}
2645
2646/// Instruction describing how to delete a file via the apply_patch tool.
2647#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2648pub struct ApplyPatchDeleteFileOperation {
2649    /// Path of the file to delete.
2650    pub path: String,
2651}
2652
2653/// Instruction describing how to update a file via the apply_patch tool.
2654#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2655pub struct ApplyPatchUpdateFileOperation {
2656    /// Path of the file to update.
2657    pub path: String,
2658    /// Diff to apply.
2659    pub diff: String,
2660}
2661
2662/// One of the create_file, delete_file, or update_file operations applied via apply_patch.
2663#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2664#[serde(tag = "type", rename_all = "snake_case")]
2665pub enum ApplyPatchOperation {
2666    CreateFile(ApplyPatchCreateFileOperation),
2667    DeleteFile(ApplyPatchDeleteFileOperation),
2668    UpdateFile(ApplyPatchUpdateFileOperation),
2669}
2670
2671/// A tool call that applies file diffs by creating, deleting, or updating files.
2672#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2673pub struct ApplyPatchToolCall {
2674    /// The unique ID of the apply patch tool call. Populated when this item is returned via API.
2675    pub id: String,
2676    /// The unique ID of the apply patch tool call generated by the model.
2677    pub call_id: String,
2678    /// The status of the apply patch tool call. One of `in_progress` or `completed`.
2679    pub status: ApplyPatchCallStatus,
2680    /// One of the create_file, delete_file, or update_file operations applied via apply_patch.
2681    pub operation: ApplyPatchOperation,
2682    /// The ID of the entity that created this tool call.
2683    #[serde(skip_serializing_if = "Option::is_none")]
2684    pub created_by: Option<String>,
2685}
2686
2687/// Outcome values reported for apply_patch tool call outputs.
2688#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
2689#[serde(rename_all = "snake_case")]
2690pub enum ApplyPatchCallOutputStatus {
2691    Completed,
2692    Failed,
2693}
2694
2695/// The output emitted by an apply patch tool call.
2696#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2697pub struct ApplyPatchToolCallOutput {
2698    /// The unique ID of the apply patch tool call output. 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 output. One of `completed` or `failed`.
2703    pub status: ApplyPatchCallOutputStatus,
2704    /// Optional textual output returned by the apply patch tool.
2705    pub output: Option<String>,
2706    /// The ID of the entity that created this tool call output.
2707    #[serde(skip_serializing_if = "Option::is_none")]
2708    pub created_by: Option<String>,
2709}
2710
2711/// Output of an MCP server tool invocation.
2712#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2713pub struct MCPToolCall {
2714    /// A JSON string of the arguments passed to the tool.
2715    pub arguments: String,
2716    /// The unique ID of the tool call.
2717    pub id: String,
2718    /// The name of the tool that was run.
2719    pub name: String,
2720    /// The label of the MCP server running the tool.
2721    pub server_label: String,
2722    /// Unique identifier for the MCP tool call approval request. Include this value
2723    /// in a subsequent `mcp_approval_response` input to approve or reject the corresponding
2724    /// tool call.
2725    pub approval_request_id: Option<String>,
2726    /// Error message from the call, if any.
2727    pub error: Option<String>,
2728    /// The output from the tool call.
2729    pub output: Option<String>,
2730    /// The status of the tool call. One of `in_progress`, `completed`, `incomplete`,
2731    /// `calling`, or `failed`.
2732    pub status: Option<MCPToolCallStatus>,
2733}
2734
2735#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2736#[serde(rename_all = "snake_case")]
2737pub enum MCPToolCallStatus {
2738    InProgress,
2739    Completed,
2740    Incomplete,
2741    Calling,
2742    Failed,
2743}
2744
2745#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2746pub struct MCPListTools {
2747    /// The unique ID of the list.
2748    pub id: String,
2749    /// The label of the MCP server.
2750    pub server_label: String,
2751    /// The tools available on the server.
2752    pub tools: Vec<MCPListToolsTool>,
2753    /// Error message if listing failed.
2754    #[serde(skip_serializing_if = "Option::is_none")]
2755    pub error: Option<String>,
2756}
2757
2758#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2759pub struct MCPApprovalRequest {
2760    /// JSON string of arguments for the tool.
2761    pub arguments: String,
2762    /// The unique ID of the approval request.
2763    pub id: String,
2764    /// The name of the tool to run.
2765    pub name: String,
2766    /// The label of the MCP server making the request.
2767    pub server_label: String,
2768}
2769
2770#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2771#[serde(untagged)]
2772pub enum Instructions {
2773    /// A text input to the model, equivalent to a text input with the `developer` role.
2774    Text(String),
2775    /// A list of one or many input items to the model, containing different content types.
2776    Array(Vec<InputItem>),
2777}
2778
2779/// The complete response returned by the Responses API.
2780#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2781pub struct Response {
2782    /// Whether to run the model response in the background.
2783    /// [Learn more](https://platform.openai.com/docs/guides/background).
2784    #[serde(skip_serializing_if = "Option::is_none")]
2785    pub background: Option<bool>,
2786
2787    /// Billing information for the response.
2788    #[serde(skip_serializing_if = "Option::is_none")]
2789    pub billing: Option<Billing>,
2790
2791    /// The conversation that this response belongs to. Input items and output
2792    /// items from this response are automatically added to this conversation.
2793    #[serde(skip_serializing_if = "Option::is_none")]
2794    pub conversation: Option<Conversation>,
2795
2796    /// Unix timestamp (in seconds) when this Response was created.
2797    pub created_at: u64,
2798
2799    /// Unix timestamp (in seconds) of when this Response was completed.
2800    /// Only present when the status is `completed`.
2801    #[serde(skip_serializing_if = "Option::is_none")]
2802    pub completed_at: Option<u64>,
2803
2804    /// An error object returned when the model fails to generate a Response.
2805    #[serde(skip_serializing_if = "Option::is_none")]
2806    pub error: Option<ErrorObject>,
2807
2808    /// Unique identifier for this response.
2809    pub id: String,
2810
2811    /// Details about why the response is incomplete, if any.
2812    #[serde(skip_serializing_if = "Option::is_none")]
2813    pub incomplete_details: Option<IncompleteDetails>,
2814
2815    /// A system (or developer) message inserted into the model's context.
2816    ///
2817    /// When using along with `previous_response_id`, the instructions from a previous response
2818    /// will not be carried over to the next response. This makes it simple to swap out
2819    /// system (or developer) messages in new responses.
2820    #[serde(skip_serializing_if = "Option::is_none")]
2821    pub instructions: Option<Instructions>,
2822
2823    /// An upper bound for the number of tokens that can be generated for a response,
2824    /// including visible output tokens and
2825    /// [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
2826    #[serde(skip_serializing_if = "Option::is_none")]
2827    pub max_output_tokens: Option<u32>,
2828
2829    /// Set of 16 key-value pairs that can be attached to an object. This can be
2830    /// useful for storing additional information about the object in a structured
2831    /// format, and querying for objects via API or the dashboard.
2832    ///
2833    /// Keys are strings with a maximum length of 64 characters. Values are strings
2834    /// with a maximum length of 512 characters.
2835    #[serde(skip_serializing_if = "Option::is_none")]
2836    pub metadata: Option<HashMap<String, String>>,
2837
2838    /// Model ID used to generate the response, like gpt-4o or o3. OpenAI offers a
2839    /// wide range of models with different capabilities, performance characteristics,
2840    /// and price points. Refer to the [model guide](https://platform.openai.com/docs/models) to browse and compare available models.
2841    pub model: String,
2842
2843    /// The object type of this resource - always set to `response`.
2844    pub object: String,
2845
2846    /// An array of content items generated by the model.
2847    ///
2848    /// - The length and order of items in the output array is dependent on the model's response.
2849    /// - Rather than accessing the first item in the output array and assuming it's an assistant
2850    ///   message with the content generated by the model, you might consider using
2851    ///   the `output_text` property where supported in SDKs.
2852    pub output: Vec<OutputItem>,
2853
2854    /// SDK-only convenience property that contains the aggregated text output from all
2855    /// `output_text` items in the `output` array, if any are present.
2856    /// Supported in the Python and JavaScript SDKs.
2857    // #[serde(skip_serializing_if = "Option::is_none")]
2858    // pub output_text: Option<String>,
2859
2860    /// Whether to allow the model to run tool calls in parallel.
2861    #[serde(skip_serializing_if = "Option::is_none")]
2862    pub parallel_tool_calls: Option<bool>,
2863
2864    /// The unique ID of the previous response to the model. Use this to create multi-turn conversations.
2865    /// Learn more about [conversation state](https://platform.openai.com/docs/guides/conversation-state).
2866    /// Cannot be used in conjunction with `conversation`.
2867    #[serde(skip_serializing_if = "Option::is_none")]
2868    pub previous_response_id: Option<String>,
2869
2870    /// Reference to a prompt template and its variables.
2871    /// [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
2872    #[serde(skip_serializing_if = "Option::is_none")]
2873    pub prompt: Option<Prompt>,
2874
2875    /// Used by OpenAI to cache responses for similar requests to optimize your cache hit rates. Replaces
2876    /// the `user` field. [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
2877    #[serde(skip_serializing_if = "Option::is_none")]
2878    pub prompt_cache_key: Option<String>,
2879
2880    /// The retention policy for the prompt cache. Set to `24h` to enable extended prompt caching,
2881    /// which keeps cached prefixes active for longer, up to a maximum of 24 hours. [Learn
2882    /// more](https://platform.openai.com/docs/guides/prompt-caching#prompt-cache-retention).
2883    #[serde(skip_serializing_if = "Option::is_none")]
2884    pub prompt_cache_retention: Option<PromptCacheRetention>,
2885
2886    /// **gpt-5 and o-series models only**
2887    /// Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
2888    #[serde(skip_serializing_if = "Option::is_none")]
2889    pub reasoning: Option<Reasoning>,
2890
2891    /// A stable identifier used to help detect users of your application that may be violating OpenAI's
2892    /// usage policies.
2893    ///
2894    /// The IDs should be a string that uniquely identifies each user. We recommend hashing their username
2895    /// or email address, in order to avoid sending us any identifying information. [Learn
2896    /// more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
2897    #[serde(skip_serializing_if = "Option::is_none")]
2898    pub safety_identifier: Option<String>,
2899
2900    /// Specifies the processing type used for serving the request.
2901    /// - 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'.
2902    /// - If set to 'default', then the request will be processed with the standard pricing and performance for the selected model.
2903    /// - 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.
2904    /// - When not set, the default behavior is 'auto'.
2905    ///
2906    /// 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.
2907    #[serde(skip_serializing_if = "Option::is_none")]
2908    pub service_tier: Option<ServiceTier>,
2909
2910    /// The status of the response generation.
2911    /// One of `completed`, `failed`, `in_progress`, `cancelled`, `queued`, or `incomplete`.
2912    pub status: Status,
2913
2914    /// What sampling temperature was used, between 0 and 2. Higher values like 0.8 make
2915    /// outputs more random, lower values like 0.2 make output more focused and deterministic.
2916    ///
2917    /// We generally recommend altering this or `top_p` but not both.
2918    #[serde(skip_serializing_if = "Option::is_none")]
2919    pub temperature: Option<f32>,
2920
2921    /// Configuration options for a text response from the model. Can be plain
2922    /// text or structured JSON data. Learn more:
2923    /// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
2924    /// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
2925    #[serde(skip_serializing_if = "Option::is_none")]
2926    pub text: Option<ResponseTextParam>,
2927
2928    /// How the model should select which tool (or tools) to use when generating
2929    /// a response. See the `tools` parameter to see how to specify which tools
2930    /// the model can call.
2931    #[serde(skip_serializing_if = "Option::is_none")]
2932    pub tool_choice: Option<ToolChoiceParam>,
2933
2934    /// An array of tools the model may call while generating a response. You
2935    /// can specify which tool to use by setting the `tool_choice` parameter.
2936    ///
2937    /// We support the following categories of tools:
2938    /// - **Built-in tools**: Tools that are provided by OpenAI that extend the
2939    ///   model's capabilities, like [web search](https://platform.openai.com/docs/guides/tools-web-search)
2940    ///   or [file search](https://platform.openai.com/docs/guides/tools-file-search). Learn more about
2941    ///   [built-in tools](https://platform.openai.com/docs/guides/tools).
2942    /// - **MCP Tools**: Integrations with third-party systems via custom MCP servers
2943    ///   or predefined connectors such as Google Drive and SharePoint. Learn more about
2944    ///   [MCP Tools](https://platform.openai.com/docs/guides/tools-connectors-mcp).
2945    /// - **Function calls (custom tools)**: Functions that are defined by you,
2946    ///   enabling the model to call your own code with strongly typed arguments
2947    ///   and outputs. Learn more about
2948    ///   [function calling](https://platform.openai.com/docs/guides/function-calling). You can also use
2949    ///   custom tools to call your own code.
2950    #[serde(skip_serializing_if = "Option::is_none")]
2951    pub tools: Option<Vec<Tool>>,
2952
2953    /// An integer between 0 and 20 specifying the number of most likely tokens to return at each
2954    /// token position, each with an associated log probability.
2955    #[serde(skip_serializing_if = "Option::is_none")]
2956    pub top_logprobs: Option<u8>,
2957
2958    /// An alternative to sampling with temperature, called nucleus sampling,
2959    /// where the model considers the results of the tokens with top_p probability
2960    /// mass. So 0.1 means only the tokens comprising the top 10% probability mass
2961    /// are considered.
2962    ///
2963    /// We generally recommend altering this or `temperature` but not both.
2964    #[serde(skip_serializing_if = "Option::is_none")]
2965    pub top_p: Option<f32>,
2966
2967    ///The truncation strategy to use for the model response.
2968    /// - `auto`: If the input to this Response exceeds
2969    ///   the model's context window size, the model will truncate the
2970    ///   response to fit the context window by dropping items from the beginning of the conversation.
2971    /// - `disabled` (default): If the input size will exceed the context window
2972    ///   size for a model, the request will fail with a 400 error.
2973    #[serde(skip_serializing_if = "Option::is_none")]
2974    pub truncation: Option<Truncation>,
2975
2976    /// Represents token usage details including input tokens, output tokens,
2977    /// a breakdown of output tokens, and the total tokens used.
2978    #[serde(skip_serializing_if = "Option::is_none")]
2979    pub usage: Option<ResponseUsage>,
2980}
2981
2982#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2983#[serde(rename_all = "snake_case")]
2984pub enum Status {
2985    Completed,
2986    Failed,
2987    InProgress,
2988    Cancelled,
2989    Queued,
2990    Incomplete,
2991}
2992
2993/// Output item
2994#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
2995#[serde(tag = "type")]
2996#[serde(rename_all = "snake_case")]
2997pub enum OutputItem {
2998    /// An output message from the model.
2999    Message(OutputMessage),
3000    /// The results of a file search tool call. See the
3001    /// [file search guide](https://platform.openai.com/docs/guides/tools-file-search)
3002    /// for more information.
3003    FileSearchCall(FileSearchToolCall),
3004    /// A tool call to run a function. See the
3005    /// [function calling guide](https://platform.openai.com/docs/guides/function-calling)
3006    /// for more information.
3007    FunctionCall(FunctionToolCall),
3008    /// The output of a function tool call.
3009    FunctionCallOutput(FunctionToolCallOutputResource),
3010    /// The results of a web search tool call. See the
3011    /// [web search guide](https://platform.openai.com/docs/guides/tools-web-search)
3012    /// for more information.
3013    WebSearchCall(WebSearchToolCall),
3014    /// A tool call to a computer use tool. See the
3015    /// [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use)
3016    /// for more information.
3017    ComputerCall(ComputerToolCall),
3018    /// The output of a computer tool call.
3019    ComputerCallOutput(ComputerToolCallOutputResource),
3020    /// A description of the chain of thought used by a reasoning model while generating
3021    /// a response. Be sure to include these items in your `input` to the Responses API for
3022    /// subsequent turns of a conversation if you are manually
3023    /// [managing context](https://platform.openai.com/docs/guides/conversation-state).
3024    Reasoning(ReasoningItem),
3025    /// A compaction item generated by the [`v1/responses/compact` API](https://platform.openai.com/docs/api-reference/responses/compact).
3026    Compaction(CompactionBody),
3027    /// An image generation request made by the model.
3028    ImageGenerationCall(ImageGenToolCall),
3029    /// A tool call to run code.
3030    CodeInterpreterCall(CodeInterpreterToolCall),
3031    /// A tool call to run a command on the local shell.
3032    LocalShellCall(LocalShellToolCall),
3033    /// A tool call that executes one or more shell commands in a managed environment.
3034    ShellCall(FunctionShellCall),
3035    /// The output of a shell tool call.
3036    ShellCallOutput(FunctionShellCallOutput),
3037    /// A tool call that applies file diffs by creating, deleting, or updating files.
3038    ApplyPatchCall(ApplyPatchToolCall),
3039    /// The output emitted by an apply patch tool call.
3040    ApplyPatchCallOutput(ApplyPatchToolCallOutput),
3041    /// An invocation of a tool on an MCP server.
3042    McpCall(MCPToolCall),
3043    /// A list of tools available on an MCP server.
3044    McpListTools(MCPListTools),
3045    /// A request for human approval of a tool invocation.
3046    McpApprovalRequest(MCPApprovalRequest),
3047    /// A call to a custom tool created by the model.
3048    CustomToolCall(CustomToolCall),
3049    /// The output of a custom tool call.
3050    CustomToolCallOutput(CustomToolCallOutputResource),
3051    /// A tool search call.
3052    ToolSearchCall(ToolSearchCall),
3053    /// A tool search output.
3054    ToolSearchOutput(ToolSearchOutput),
3055}
3056
3057#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3058#[non_exhaustive]
3059pub struct CustomToolCall {
3060    /// An identifier used to map this custom tool call to a tool call output.
3061    pub call_id: String,
3062    /// The namespace of the custom tool being called.
3063    #[serde(skip_serializing_if = "Option::is_none")]
3064    pub namespace: Option<String>,
3065    /// The input for the custom tool call generated by the model.
3066    pub input: String,
3067    /// The name of the custom tool being called.
3068    pub name: String,
3069    /// The unique ID of the custom tool call in the OpenAI platform.
3070    pub id: String,
3071}
3072
3073/// A custom tool call item returned by the API.
3074#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3075#[non_exhaustive]
3076pub struct CustomToolCallResource {
3077    /// An identifier used to map this custom tool call to a tool call output.
3078    pub call_id: String,
3079    /// The namespace of the custom tool being called.
3080    #[serde(skip_serializing_if = "Option::is_none")]
3081    pub namespace: Option<String>,
3082    /// The input for the custom tool call generated by the model.
3083    pub input: String,
3084    /// The name of the custom tool being called.
3085    pub name: String,
3086    /// The unique ID of the custom tool call in the OpenAI platform.
3087    pub id: String,
3088    /// The status of the item. One of `in_progress`, `completed`, or `incomplete`.
3089    pub status: FunctionCallStatus,
3090    /// The identifier of the actor that created the item.
3091    #[serde(skip_serializing_if = "Option::is_none")]
3092    pub created_by: Option<String>,
3093}
3094
3095#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3096pub struct DeleteResponse {
3097    pub object: String,
3098    pub deleted: bool,
3099    pub id: String,
3100}
3101
3102#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3103pub struct AnyItemReference {
3104    pub r#type: Option<String>,
3105    pub id: String,
3106}
3107
3108#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3109#[serde(tag = "type", rename_all = "snake_case")]
3110pub enum ItemResourceItem {
3111    Message(MessageItem),
3112    FileSearchCall(FileSearchToolCall),
3113    ComputerCall(ComputerToolCall),
3114    ComputerCallOutput(ComputerToolCallOutputResource),
3115    WebSearchCall(WebSearchToolCall),
3116    FunctionCall(FunctionToolCallResource),
3117    FunctionCallOutput(FunctionToolCallOutputResource),
3118    ToolSearchCall(ToolSearchCall),
3119    ToolSearchOutput(ToolSearchOutput),
3120    Reasoning(ReasoningItem),
3121    Compaction(CompactionBody),
3122    ImageGenerationCall(ImageGenToolCall),
3123    CodeInterpreterCall(CodeInterpreterToolCall),
3124    LocalShellCall(LocalShellToolCall),
3125    LocalShellCallOutput(LocalShellToolCallOutput),
3126    ShellCall(FunctionShellCallItemParam),
3127    ShellCallOutput(FunctionShellCallOutputItemParam),
3128    ApplyPatchCall(ApplyPatchToolCallItemParam),
3129    ApplyPatchCallOutput(ApplyPatchToolCallOutputItemParam),
3130    McpListTools(MCPListTools),
3131    McpApprovalRequest(MCPApprovalRequest),
3132    McpApprovalResponse(MCPApprovalResponse),
3133    McpCall(MCPToolCall),
3134    CustomToolCall(CustomToolCallResource),
3135    CustomToolCallOutput(CustomToolCallOutputResource),
3136}
3137
3138#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3139#[serde(untagged)]
3140pub enum ItemResource {
3141    ItemReference(AnyItemReference),
3142    Item(ItemResourceItem),
3143}
3144
3145/// A list of Response items.
3146#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3147pub struct ResponseItemList {
3148    /// The type of object returned, must be `list`.
3149    pub object: String,
3150    /// The ID of the first item in the list.
3151    pub first_id: Option<String>,
3152    /// The ID of the last item in the list.
3153    pub last_id: Option<String>,
3154    /// Whether there are more items in the list.
3155    pub has_more: bool,
3156    /// The list of items.
3157    pub data: Vec<ItemResource>,
3158}
3159
3160#[derive(Clone, Serialize, Deserialize, Debug, Default, Builder, PartialEq)]
3161#[builder(
3162    name = "TokenCountsBodyArgs",
3163    pattern = "mutable",
3164    setter(into, strip_option),
3165    default
3166)]
3167#[builder(build_fn(error = "OpenAIError"))]
3168pub struct TokenCountsBody {
3169    /// The conversation that this response belongs to. Items from this
3170    /// conversation are prepended to `input_items` for this response request.
3171    /// Input items and output items from this response are automatically added to this
3172    /// conversation after this response completes.
3173    #[serde(skip_serializing_if = "Option::is_none")]
3174    pub conversation: Option<ConversationParam>,
3175
3176    /// Text, image, or file inputs to the model, used to generate a response
3177    #[serde(skip_serializing_if = "Option::is_none")]
3178    pub input: Option<InputParam>,
3179
3180    /// A system (or developer) message inserted into the model's context.
3181    ///
3182    /// When used along with `previous_response_id`, the instructions from a previous response will
3183    /// not be carried over to the next response. This makes it simple to swap out system (or
3184    /// developer) messages in new responses.
3185    #[serde(skip_serializing_if = "Option::is_none")]
3186    pub instructions: Option<String>,
3187
3188    /// Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
3189    /// wide range of models with different capabilities, performance characteristics,
3190    /// and price points. Refer to the [model guide](https://platform.openai.com/docs/models)
3191    /// to browse and compare available models.
3192    #[serde(skip_serializing_if = "Option::is_none")]
3193    pub model: Option<String>,
3194
3195    /// Whether to allow the model to run tool calls in parallel.
3196    #[serde(skip_serializing_if = "Option::is_none")]
3197    pub parallel_tool_calls: Option<bool>,
3198
3199    /// The unique ID of the previous response to the model. Use this to create multi-turn
3200    /// conversations. Learn more about [conversation state](https://platform.openai.com/docs/guides/conversation-state).
3201    /// Cannot be used in conjunction with `conversation`.
3202    #[serde(skip_serializing_if = "Option::is_none")]
3203    pub previous_response_id: Option<String>,
3204
3205    /// **gpt-5 and o-series models only**
3206    /// Configuration options for [reasoning models](https://platform.openai.com/docs/guides/reasoning).
3207    #[serde(skip_serializing_if = "Option::is_none")]
3208    pub reasoning: Option<Reasoning>,
3209
3210    /// Configuration options for a text response from the model. Can be plain
3211    /// text or structured JSON data. Learn more:
3212    /// - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
3213    /// - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
3214    #[serde(skip_serializing_if = "Option::is_none")]
3215    pub text: Option<ResponseTextParam>,
3216
3217    /// How the model should select which tool (or tools) to use when generating
3218    /// a response. See the `tools` parameter to see how to specify which tools
3219    /// the model can call.
3220    #[serde(skip_serializing_if = "Option::is_none")]
3221    pub tool_choice: Option<ToolChoiceParam>,
3222
3223    /// An array of tools the model may call while generating a response. You can specify which tool
3224    /// to use by setting the `tool_choice` parameter.
3225    #[serde(skip_serializing_if = "Option::is_none")]
3226    pub tools: Option<Vec<Tool>>,
3227
3228    ///The truncation strategy to use for the model response.
3229    /// - `auto`: If the input to this Response exceeds
3230    ///   the model's context window size, the model will truncate the
3231    ///   response to fit the context window by dropping items from the beginning of the conversation.
3232    /// - `disabled` (default): If the input size will exceed the context window
3233    ///   size for a model, the request will fail with a 400 error.
3234    #[serde(skip_serializing_if = "Option::is_none")]
3235    pub truncation: Option<Truncation>,
3236}
3237
3238#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3239pub struct TokenCountsResource {
3240    pub object: String,
3241    pub input_tokens: u32,
3242}
3243
3244/// A compaction item generated by the `/v1/responses/compact` API.
3245#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3246pub struct CompactionSummaryItemParam {
3247    /// The ID of the compaction item.
3248    #[serde(skip_serializing_if = "Option::is_none")]
3249    pub id: Option<String>,
3250    /// The encrypted content of the compaction summary.
3251    pub encrypted_content: String,
3252}
3253
3254/// A compaction item generated by the `/v1/responses/compact` API.
3255#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3256pub struct CompactionBody {
3257    /// The unique ID of the compaction item.
3258    pub id: String,
3259    /// The encrypted content that was produced by compaction.
3260    pub encrypted_content: String,
3261    /// The identifier of the actor that created the item.
3262    #[serde(skip_serializing_if = "Option::is_none")]
3263    pub created_by: Option<String>,
3264}
3265
3266/// Request to compact a conversation.
3267#[derive(Clone, Serialize, Default, Debug, Deserialize, Builder, PartialEq)]
3268#[builder(name = "CompactResponseRequestArgs")]
3269#[builder(pattern = "mutable")]
3270#[builder(setter(into, strip_option), default)]
3271#[builder(derive(Debug))]
3272#[builder(build_fn(error = "OpenAIError"))]
3273pub struct CompactResponseRequest {
3274    /// Model ID used to generate the response, like `gpt-5` or `o3`. OpenAI offers a wide range of models
3275    /// with different capabilities, performance characteristics, and price points. Refer to the
3276    /// [model guide](https://platform.openai.com/docs/models) to browse and compare available models.
3277    pub model: String,
3278
3279    /// Text, image, or file inputs to the model, used to generate a response
3280    #[serde(skip_serializing_if = "Option::is_none")]
3281    pub input: Option<InputParam>,
3282
3283    /// The unique ID of the previous response to the model. Use this to create multi-turn
3284    /// conversations. Learn more about [conversation state](https://platform.openai.com/docs/guides/conversation-state).
3285    /// Cannot be used in conjunction with `conversation`.
3286    #[serde(skip_serializing_if = "Option::is_none")]
3287    pub previous_response_id: Option<String>,
3288
3289    /// A system (or developer) message inserted into the model's context.
3290    ///
3291    /// When used along with `previous_response_id`, the instructions from a previous response will
3292    /// not be carried over to the next response. This makes it simple to swap out system (or
3293    /// developer) messages in new responses.
3294    #[serde(skip_serializing_if = "Option::is_none")]
3295    pub instructions: Option<String>,
3296
3297    /// A key to use when reading from or writing to the prompt cache.
3298    #[serde(skip_serializing_if = "Option::is_none")]
3299    pub prompt_cache_key: Option<String>,
3300
3301    /// How long to retain a prompt cache entry created by this request.
3302    #[serde(skip_serializing_if = "Option::is_none")]
3303    pub prompt_cache_retention: Option<PromptCacheRetention>,
3304}
3305
3306/// The compacted response object.
3307#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3308pub struct CompactResource {
3309    /// The unique identifier for the compacted response.
3310    pub id: String,
3311    /// The object type. Always `response.compaction`.
3312    pub object: String,
3313    /// The compacted list of output items. This is a list of all user messages,
3314    /// followed by a single compaction item.
3315    pub output: Vec<OutputItem>,
3316    /// Unix timestamp (in seconds) when the compacted conversation was created.
3317    pub created_at: u64,
3318    /// Token accounting for the compaction pass, including cached, reasoning, and total tokens.
3319    pub usage: ResponseUsage,
3320}
3321
3322// ============================================================
3323// Container / Environment Types
3324// ============================================================
3325
3326/// A domain-scoped secret injected for allowlisted domains.
3327#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3328pub struct ContainerNetworkPolicyDomainSecretParam {
3329    /// The domain associated with the secret.
3330    pub domain: String,
3331    /// The name of the secret to inject for the domain.
3332    pub name: String,
3333    /// The secret value to inject for the domain.
3334    pub value: String,
3335}
3336
3337/// Details for an allowlist network policy.
3338#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3339pub struct ContainerNetworkPolicyAllowlistDetails {
3340    /// A list of allowed domains.
3341    pub allowed_domains: Vec<String>,
3342    /// Optional domain-scoped secrets for allowlisted domains.
3343    #[serde(skip_serializing_if = "Option::is_none")]
3344    pub domain_secrets: Option<Vec<ContainerNetworkPolicyDomainSecretParam>>,
3345}
3346
3347/// Network access policy for a container.
3348#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3349#[serde(tag = "type", rename_all = "snake_case")]
3350pub enum ContainerNetworkPolicy {
3351    /// Disable all outbound network access.
3352    Disabled,
3353    /// Allow access only to specified domains.
3354    Allowlist(ContainerNetworkPolicyAllowlistDetails),
3355}
3356
3357/// A skill referenced by ID.
3358#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3359pub struct SkillReferenceParam {
3360    /// The ID of the skill to reference.
3361    pub skill_id: String,
3362    /// An optional specific version to use.
3363    #[serde(skip_serializing_if = "Option::is_none")]
3364    pub version: Option<String>,
3365}
3366
3367/// An inline skill source (base64-encoded zip).
3368#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3369pub struct InlineSkillSourceParam {
3370    /// The media type. Always `"application/zip"`.
3371    pub media_type: String,
3372    /// The base64-encoded skill data.
3373    pub data: String,
3374}
3375
3376/// An inline skill definition.
3377#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3378pub struct InlineSkillParam {
3379    /// The name of the skill.
3380    pub name: String,
3381    /// The description of the skill.
3382    pub description: String,
3383    /// The inline source for the skill.
3384    pub source: InlineSkillSourceParam,
3385}
3386
3387/// A skill parameter — either a reference or inline definition.
3388#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3389#[serde(tag = "type", rename_all = "snake_case")]
3390pub enum SkillParam {
3391    /// Reference a skill by ID.
3392    SkillReference(SkillReferenceParam),
3393    /// Provide an inline skill definition.
3394    Inline(InlineSkillParam),
3395}
3396
3397/// Automatically creates a container for the request.
3398#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3399pub struct ContainerAutoParam {
3400    /// An optional list of uploaded file IDs to make available in the container.
3401    #[serde(skip_serializing_if = "Option::is_none")]
3402    pub file_ids: Option<Vec<String>>,
3403    /// Network access policy for the container.
3404    #[serde(skip_serializing_if = "Option::is_none")]
3405    pub network_policy: Option<ContainerNetworkPolicy>,
3406    /// An optional list of skills to make available in the container.
3407    #[serde(skip_serializing_if = "Option::is_none")]
3408    pub skills: Option<Vec<SkillParam>>,
3409}
3410
3411/// A local skill available in a local environment.
3412#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3413pub struct LocalSkillParam {
3414    /// The name of the skill.
3415    pub name: String,
3416    /// The description of the skill.
3417    pub description: String,
3418    /// The path to the directory containing the skill.
3419    pub path: String,
3420}
3421
3422/// Uses a local computer environment.
3423#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3424pub struct LocalEnvironmentParam {
3425    /// An optional list of local skills.
3426    #[serde(skip_serializing_if = "Option::is_none")]
3427    pub skills: Option<Vec<LocalSkillParam>>,
3428}
3429
3430/// References a container created with the /v1/containers endpoint.
3431#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3432pub struct ContainerReferenceParam {
3433    /// The ID of the referenced container.
3434    pub container_id: String,
3435}
3436
3437/// A resource reference to a container by ID.
3438#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3439pub struct ContainerReferenceResource {
3440    /// The ID of the referenced container.
3441    pub container_id: String,
3442}
3443
3444/// The execution environment for a shell tool — container or local.
3445#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3446#[serde(tag = "type", rename_all = "snake_case")]
3447pub enum FunctionShellEnvironment {
3448    /// Automatically creates a container for this request.
3449    ContainerAuto(ContainerAutoParam),
3450    /// Use a local computer environment.
3451    Local(LocalEnvironmentParam),
3452    /// Reference an existing container by ID.
3453    ContainerReference(ContainerReferenceParam),
3454}
3455
3456/// Parameters for the shell function tool.
3457#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
3458pub struct FunctionShellToolParam {
3459    /// The execution environment for the shell tool.
3460    #[serde(skip_serializing_if = "Option::is_none")]
3461    pub environment: Option<FunctionShellEnvironment>,
3462}
3463
3464/// Context management configuration.
3465#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
3466pub struct ContextManagementParam {
3467    /// The context management strategy type.
3468    #[serde(rename = "type")]
3469    pub type_: String,
3470    /// Minimum number of tokens to retain before compacting.
3471    #[serde(skip_serializing_if = "Option::is_none")]
3472    pub compact_threshold: Option<u32>,
3473}