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