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