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