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