async_openai_compat/types/
responses.rs

1use crate::error::OpenAIError;
2pub use crate::types::{
3    CompletionTokensDetails, ImageDetail, PromptTokensDetails, ReasoningEffort,
4    ResponseFormatJsonSchema,
5};
6use derive_builder::Builder;
7use serde::{Deserialize, Serialize};
8use serde_json::Value;
9use std::collections::HashMap;
10
11/// Role of messages in the API.
12#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
13#[serde(rename_all = "lowercase")]
14pub enum Role {
15    User,
16    Assistant,
17    System,
18    Developer,
19}
20
21/// Status of input/output items.
22#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
23#[serde(rename_all = "snake_case")]
24pub enum OutputStatus {
25    InProgress,
26    Completed,
27    Incomplete,
28}
29
30/// Input payload: raw text or structured context items.
31#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
32#[serde(untagged)]
33pub enum Input {
34    /// A text input to the model, equivalent to a text input with the user role.
35    Text(String),
36    /// A list of one or many input items to the model, containing different content types.
37    Items(Vec<InputItem>),
38}
39
40/// A context item: currently only messages.
41#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
42#[serde(untagged, rename_all = "snake_case")]
43pub enum InputItem {
44    Message(InputMessage),
45    Custom(serde_json::Value),
46}
47
48/// A message to prime the model.
49#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
50#[builder(
51    name = "InputMessageArgs",
52    pattern = "mutable",
53    setter(into, strip_option),
54    default
55)]
56#[builder(build_fn(error = "OpenAIError"))]
57pub struct InputMessage {
58    #[serde(default, rename = "type")]
59    pub kind: InputMessageType,
60    /// The role of the message input.
61    pub role: Role,
62    /// Text, image, or audio input to the model, used to generate a response. Can also contain
63    /// previous assistant responses.
64    pub content: InputContent,
65}
66
67#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
68#[serde(rename_all = "snake_case")]
69pub enum InputMessageType {
70    #[default]
71    Message,
72}
73
74#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
75#[serde(untagged)]
76pub enum InputContent {
77    /// A text input to the model.
78    TextInput(String),
79    /// A list of one or many input items to the model, containing different content types.
80    InputItemContentList(Vec<ContentType>),
81}
82
83/// Parts of a message: text, image, file, or audio.
84#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
85#[serde(tag = "type", rename_all = "snake_case")]
86pub enum ContentType {
87    /// A text input to the model.
88    InputText(InputText),
89    /// An image input to the model.
90    InputImage(InputImage),
91    /// A file input to the model.
92    InputFile(InputFile),
93}
94
95#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
96pub struct InputText {
97    pub text: String,
98}
99
100#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
101#[builder(
102    name = "InputImageArgs",
103    pattern = "mutable",
104    setter(into, strip_option),
105    default
106)]
107#[builder(build_fn(error = "OpenAIError"))]
108pub struct InputImage {
109    /// The detail level of the image to be sent to the model.
110    pub detail: ImageDetail,
111    /// The ID of the file to be sent to the model.
112    #[serde(skip_serializing_if = "Option::is_none")]
113    pub file_id: Option<String>,
114    /// The URL of the image to be sent to the model. A fully qualified URL or base64 encoded image
115    /// in a data URL.
116    #[serde(skip_serializing_if = "Option::is_none")]
117    pub image_url: Option<String>,
118}
119
120#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
121#[builder(
122    name = "InputFileArgs",
123    pattern = "mutable",
124    setter(into, strip_option),
125    default
126)]
127#[builder(build_fn(error = "OpenAIError"))]
128pub struct InputFile {
129    /// The content of the file to be sent to the model.
130    #[serde(skip_serializing_if = "Option::is_none")]
131    pub file_data: Option<String>,
132    /// The ID of the file to be sent to the model.
133    #[serde(skip_serializing_if = "Option::is_none")]
134    pub file_id: Option<String>,
135    /// The name of the file to be sent to the model.
136    #[serde(skip_serializing_if = "Option::is_none")]
137    pub filename: Option<String>,
138}
139
140/// Builder for a Responses API request.
141#[derive(Clone, Serialize, Deserialize, Debug, Default, Builder, PartialEq)]
142#[builder(
143    name = "CreateResponseArgs",
144    pattern = "mutable",
145    setter(into, strip_option),
146    default
147)]
148#[builder(build_fn(error = "OpenAIError"))]
149pub struct CreateResponse {
150    /// Text, image, or file inputs to the model, used to generate a response.
151    pub input: Input,
152
153    /// Model ID used to generate the response, like `gpt-4o`.
154    /// OpenAI offers a wide range of models with different capabilities,
155    /// performance characteristics, and price points.
156    pub model: String,
157
158    /// Whether to run the model response in the background.
159    /// boolean or null.
160    #[serde(skip_serializing_if = "Option::is_none")]
161    pub background: Option<bool>,
162
163    /// Specify additional output data to include in the model response.
164    ///
165    /// Supported values:
166    /// - `file_search_call.results`
167    ///   Include the search results of the file search tool call.
168    /// - `message.input_image.image_url`
169    ///   Include image URLs from the input message.
170    /// - `computer_call_output.output.image_url`
171    ///   Include image URLs from the computer call output.
172    /// - `reasoning.encrypted_content`
173    ///   Include an encrypted version of reasoning tokens in reasoning item outputs.
174    ///   This enables reasoning items to be used in multi-turn conversations when
175    ///   using the Responses API statelessly (for example, when the `store` parameter
176    ///   is set to `false`, or when an organization is enrolled in the zero-data-
177    ///   retention program).
178    ///
179    /// If `None`, no additional data is returned.
180    #[serde(skip_serializing_if = "Option::is_none")]
181    pub include: Option<Vec<String>>,
182
183    /// Inserts a system (or developer) message as the first item in the model's context.
184    ///
185    /// When using along with previous_response_id, the instructions from a previous response will
186    /// not be carried over to the next response. This makes it simple to swap out system
187    /// (or developer) messages in new responses.
188    #[serde(skip_serializing_if = "Option::is_none")]
189    pub instructions: Option<String>,
190
191    /// An upper bound for the number of tokens that can be generated for a
192    /// response, including visible output tokens and reasoning tokens.
193    #[serde(skip_serializing_if = "Option::is_none")]
194    pub max_output_tokens: Option<u32>,
195
196    /// The maximum number of total calls to built-in tools that can be processed in a response.
197    /// This maximum number applies across all built-in tool calls, not per individual tool.
198    /// Any further attempts to call a tool by the model will be ignored.
199    pub max_tool_calls: Option<u32>,
200
201    /// Set of 16 key-value pairs that can be attached to an object. This can be
202    /// useful for storing additional information about the object in a structured
203    /// format, and querying for objects via API or the dashboard.
204    ///
205    /// Keys are strings with a maximum length of 64 characters. Values are
206    /// strings with a maximum length of 512 characters.
207    #[serde(skip_serializing_if = "Option::is_none")]
208    pub metadata: Option<HashMap<String, String>>,
209
210    /// Whether to allow the model to run tool calls in parallel.
211    #[serde(skip_serializing_if = "Option::is_none")]
212    pub parallel_tool_calls: Option<bool>,
213
214    /// The unique ID of the previous response to the model. Use this to create
215    /// multi-turn conversations.
216    #[serde(skip_serializing_if = "Option::is_none")]
217    pub previous_response_id: Option<String>,
218
219    /// Reference to a prompt template and its variables.
220    #[serde(skip_serializing_if = "Option::is_none")]
221    pub prompt: Option<PromptConfig>,
222
223    /// **o-series models only**: Configuration options for reasoning models.
224    #[serde(skip_serializing_if = "Option::is_none")]
225    pub reasoning: Option<ReasoningConfig>,
226
227    /// Specifies the latency tier to use for processing the request.
228    ///
229    /// This parameter is relevant for customers subscribed to the Scale tier service.
230    ///
231    /// Supported values:
232    /// - `auto`
233    ///   - If the Project is Scale tier enabled, the system will utilize Scale tier credits until
234    ///     they are exhausted.
235    ///   - If the Project is not Scale tier enabled, the request will be processed using the
236    ///     default service tier with a lower uptime SLA and no latency guarantee.
237    /// - `default`
238    ///   The request will be processed using the default service tier with a lower uptime SLA and
239    ///   no latency guarantee.
240    /// - `flex`
241    ///   The request will be processed with the Flex Processing service tier. Learn more.
242    ///
243    /// When not set, the default behavior is `auto`.
244    ///
245    /// When this parameter is set, the response body will include the `service_tier` utilized.
246    #[serde(skip_serializing_if = "Option::is_none")]
247    pub service_tier: Option<ServiceTier>,
248
249    /// Whether to store the generated model response for later retrieval via API.
250    #[serde(skip_serializing_if = "Option::is_none")]
251    pub store: Option<bool>,
252
253    /// If set to true, the model response data will be streamed to the client as it is
254    /// generated using server-sent events.
255    #[serde(skip_serializing_if = "Option::is_none")]
256    pub stream: Option<bool>,
257
258    /// What sampling temperature to use, between 0 and 2. Higher values like 0.8
259    /// will make the output more random, while lower values like 0.2 will make it
260    /// more focused and deterministic. We generally recommend altering this or
261    /// `top_p` but not both.
262    #[serde(skip_serializing_if = "Option::is_none")]
263    pub temperature: Option<f32>,
264
265    /// Configuration options for a text response from the model. Can be plain text
266    /// or structured JSON data.
267    #[serde(skip_serializing_if = "Option::is_none")]
268    pub text: Option<TextConfig>,
269
270    /// How the model should select which tool (or tools) to use when generating
271    /// a response.
272    #[serde(skip_serializing_if = "Option::is_none")]
273    pub tool_choice: Option<ToolChoice>,
274
275    /// An array of tools the model may call while generating a response.
276    /// Can include built-in tools (file_search, web_search_preview,
277    /// computer_use_preview) or custom function definitions.
278    #[serde(skip_serializing_if = "Option::is_none")]
279    pub tools: Option<Vec<ToolDefinition>>,
280
281    /// An integer between 0 and 20 specifying the number of most likely tokens to return
282    /// at each token position, each with an associated log probability.
283    #[serde(skip_serializing_if = "Option::is_none")]
284    pub top_logprobs: Option<u32>, // TODO add validation of range
285
286    /// An alternative to sampling with temperature, called nucleus sampling,
287    /// where the model considers the results of the tokens with top_p probability
288    /// mass. So 0.1 means only the tokens comprising the top 10% probability mass
289    /// are considered. We generally recommend altering this or `temperature` but
290    /// not both.
291    #[serde(skip_serializing_if = "Option::is_none")]
292    pub top_p: Option<f32>,
293
294    /// The truncation strategy to use for the model response:
295    /// - `auto`: drop items in the middle to fit context window.
296    /// - `disabled`: error if exceeding context window.
297    #[serde(skip_serializing_if = "Option::is_none")]
298    pub truncation: Option<Truncation>,
299
300    /// A unique identifier representing your end-user, which can help OpenAI to
301    /// monitor and detect abuse.
302    #[serde(skip_serializing_if = "Option::is_none")]
303    pub user: Option<String>,
304
305    /// The key to use for caching the prompt.
306    #[serde(skip_serializing_if = "Option::is_none")]
307    pub prompt_cache_key: Option<String>,
308}
309
310/// Service tier request options.
311#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
312pub struct PromptConfig {
313    /// The unique identifier of the prompt template to use.
314    pub id: String,
315
316    /// Optional version of the prompt template.
317    #[serde(skip_serializing_if = "Option::is_none")]
318    pub version: Option<String>,
319
320    /// Optional map of values to substitute in for variables in your prompt. The substitution
321    /// values can either be strings, or other Response input types like images or files.
322    /// For now only supporting Strings.
323    #[serde(skip_serializing_if = "Option::is_none")]
324    pub variables: Option<HashMap<String, String>>,
325}
326
327/// Service tier request options.
328#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
329#[serde(rename_all = "lowercase")]
330pub enum ServiceTier {
331    Auto,
332    Default,
333    Flex,
334}
335
336/// Truncation strategies.
337#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
338#[serde(rename_all = "lowercase")]
339pub enum Truncation {
340    Auto,
341    Disabled,
342}
343
344/// o-series reasoning settings.
345#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
346#[builder(
347    name = "ReasoningConfigArgs",
348    pattern = "mutable",
349    setter(into, strip_option),
350    default
351)]
352#[builder(build_fn(error = "OpenAIError"))]
353pub struct ReasoningConfig {
354    /// Constrain effort on reasoning.
355    #[serde(skip_serializing_if = "Option::is_none")]
356    pub effort: Option<ReasoningEffort>,
357    /// Summary mode for reasoning.
358    #[serde(skip_serializing_if = "Option::is_none")]
359    pub summary: Option<ReasoningSummary>,
360}
361
362#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
363#[serde(rename_all = "lowercase")]
364pub enum ReasoningSummary {
365    Auto,
366    Concise,
367    Detailed,
368}
369
370/// Configuration for text response format.
371#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
372pub struct TextConfig {
373    /// Defines the format: plain text, JSON object, or JSON schema.
374    pub format: TextResponseFormat,
375}
376
377#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
378#[serde(tag = "type", rename_all = "snake_case")]
379pub enum TextResponseFormat {
380    /// The type of response format being defined: `text`
381    Text,
382    /// The type of response format being defined: `json_object`
383    JsonObject,
384    /// The type of response format being defined: `json_schema`
385    JsonSchema(ResponseFormatJsonSchema),
386}
387
388/// Definitions for model-callable tools.
389#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
390#[serde(tag = "type", rename_all = "snake_case")]
391pub enum ToolDefinition {
392    /// File search tool.
393    FileSearch(FileSearch),
394    /// Custom function call.
395    Function(Function),
396    /// Web search preview tool.
397    WebSearchPreview(WebSearchPreview),
398    /// Virtual computer control tool.
399    ComputerUsePreview(ComputerUsePreview),
400    /// Remote Model Context Protocol server.
401    Mcp(Mcp),
402    /// Python code interpreter tool.
403    CodeInterpreter(CodeInterpreter),
404    /// Image generation tool.
405    ImageGeneration(ImageGeneration),
406    /// Local shell command execution tool.
407    LocalShell,
408}
409
410#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
411#[builder(
412    name = "FileSearchArgs",
413    pattern = "mutable",
414    setter(into, strip_option),
415    default
416)]
417#[builder(build_fn(error = "OpenAIError"))]
418pub struct FileSearch {
419    /// The IDs of the vector stores to search.
420    pub vector_store_ids: Vec<String>,
421    /// The maximum number of results to return. This number should be between 1 and 50 inclusive.
422    #[serde(skip_serializing_if = "Option::is_none")]
423    pub max_num_results: Option<u32>,
424    /// A filter to apply.
425    #[serde(skip_serializing_if = "Option::is_none")]
426    pub filters: Option<Filter>,
427    /// Ranking options for search.
428    #[serde(skip_serializing_if = "Option::is_none")]
429    pub ranking_options: Option<RankingOptions>,
430}
431
432#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
433#[builder(
434    name = "FunctionArgs",
435    pattern = "mutable",
436    setter(into, strip_option),
437    default
438)]
439pub struct Function {
440    /// The name of the function to call.
441    pub name: String,
442    /// A JSON schema object describing the parameters of the function.
443    pub parameters: serde_json::Value,
444    /// Whether to enforce strict parameter validation.
445    pub strict: bool,
446    /// A description of the function. Used by the model to determine whether or not to call the
447    /// function.
448    #[serde(skip_serializing_if = "Option::is_none")]
449    pub description: Option<String>,
450}
451
452#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
453#[builder(
454    name = "WebSearchPreviewArgs",
455    pattern = "mutable",
456    setter(into, strip_option),
457    default
458)]
459pub struct WebSearchPreview {
460    /// The user's location.
461    #[serde(skip_serializing_if = "Option::is_none")]
462    pub user_location: Option<Location>,
463    /// High level guidance for the amount of context window space to use for the search.
464    #[serde(skip_serializing_if = "Option::is_none")]
465    pub search_context_size: Option<WebSearchContextSize>,
466}
467
468#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq)]
469#[serde(rename_all = "lowercase")]
470pub enum WebSearchContextSize {
471    Low,
472    Medium,
473    High,
474}
475
476#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
477#[builder(
478    name = "ComputerUsePreviewArgs",
479    pattern = "mutable",
480    setter(into, strip_option),
481    default
482)]
483pub struct ComputerUsePreview {
484    /// The type of computer environment to control.
485    environment: String,
486    /// The width of the computer display.
487    display_width: u32,
488    /// The height of the computer display.
489    display_height: u32,
490}
491
492/// Options for search result ranking.
493#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
494pub struct RankingOptions {
495    /// The ranker to use for the file search.
496    pub ranker: String,
497    /// The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will
498    /// attempt to return only the most relevant results, but may return fewer results.
499    #[serde(skip_serializing_if = "Option::is_none")]
500    pub score_threshold: Option<f32>,
501}
502
503/// Filters for file search.
504#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
505#[serde(untagged)]
506pub enum Filter {
507    /// A filter used to compare a specified attribute key to a given value using a defined
508    /// comparison operation.
509    Comparison(ComparisonFilter),
510    /// Combine multiple filters using and or or.
511    Compound(CompoundFilter),
512}
513
514/// Single comparison filter.
515#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
516pub struct ComparisonFilter {
517    /// Specifies the comparison operator
518    #[serde(rename = "type")]
519    pub op: ComparisonType,
520    /// The key to compare against the value.
521    pub key: String,
522    /// The value to compare against the attribute key; supports string, number, or boolean types.
523    pub value: serde_json::Value,
524}
525
526#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
527pub enum ComparisonType {
528    #[serde(rename = "eq")]
529    Equals,
530    #[serde(rename = "ne")]
531    NotEquals,
532    #[serde(rename = "gt")]
533    GreaterThan,
534    #[serde(rename = "gte")]
535    GreaterThanOrEqualTo,
536    #[serde(rename = "lt")]
537    LessThan,
538    #[serde(rename = "lte")]
539    LessThanOrEqualTo,
540}
541
542/// Combine multiple filters.
543#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
544pub struct CompoundFilter {
545    /// Type of operation
546    #[serde(rename = "type")]
547    pub op: ComparisonType,
548    /// Array of filters to combine. Items can be ComparisonFilter or CompoundFilter.
549    pub filters: Vec<Filter>,
550}
551
552#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
553#[serde(rename_all = "lowercase")]
554pub enum CompoundType {
555    And,
556    Or,
557}
558
559/// Approximate user location for web search.
560#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
561#[builder(
562    name = "LocationArgs",
563    pattern = "mutable",
564    setter(into, strip_option),
565    default
566)]
567#[builder(build_fn(error = "OpenAIError"))]
568pub struct Location {
569    /// The type of location approximation. Always approximate.
570    #[serde(rename = "type")]
571    pub kind: String,
572    /// Free text input for the city of the user, e.g. San Francisco.
573    #[serde(skip_serializing_if = "Option::is_none")]
574    pub city: Option<String>,
575    /// The two-letter ISO country code of the user, e.g. US.
576    #[serde(skip_serializing_if = "Option::is_none")]
577    pub country: Option<String>,
578    /// Free text input for the region of the user, e.g. California.
579    #[serde(skip_serializing_if = "Option::is_none")]
580    pub region: Option<String>,
581    /// The IANA timezone of the user, e.g. America/Los_Angeles.
582    #[serde(skip_serializing_if = "Option::is_none")]
583    pub timezone: Option<String>,
584}
585
586/// MCP (Model Context Protocol) tool configuration.
587#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
588#[builder(
589    name = "McpArgs",
590    pattern = "mutable",
591    setter(into, strip_option),
592    default
593)]
594#[builder(build_fn(error = "OpenAIError"))]
595pub struct Mcp {
596    /// A label for this MCP server.
597    pub server_label: String,
598    /// The URL for the MCP server.
599    pub server_url: String,
600    /// List of allowed tool names or filter object.
601    #[serde(skip_serializing_if = "Option::is_none")]
602    pub allowed_tools: Option<AllowedTools>,
603    /// Optional HTTP headers for the MCP server.
604    #[serde(skip_serializing_if = "Option::is_none")]
605    pub headers: Option<Value>,
606    /// Approval policy or filter for tools.
607    #[serde(skip_serializing_if = "Option::is_none")]
608    pub require_approval: Option<RequireApproval>,
609}
610
611/// Allowed tools configuration for MCP.
612#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
613#[serde(untagged)]
614pub enum AllowedTools {
615    /// A flat list of allowed tool names.
616    List(Vec<String>),
617    /// A filter object specifying allowed tools.
618    Filter(McpAllowedToolsFilter),
619}
620
621/// Filter object for MCP allowed tools.
622#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
623pub struct McpAllowedToolsFilter {
624    /// Names of tools in the filter
625    #[serde(skip_serializing_if = "Option::is_none")]
626    pub tool_names: Option<Vec<String>>,
627}
628
629/// Approval policy or filter for MCP tools.
630#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
631#[serde(untagged)]
632pub enum RequireApproval {
633    /// A blanket policy: "always" or "never".
634    Policy(RequireApprovalPolicy),
635    /// A filter object specifying which tools require approval.
636    Filter(McpApprovalFilter),
637}
638
639#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
640#[serde(rename_all = "lowercase")]
641pub enum RequireApprovalPolicy {
642    Always,
643    Never,
644}
645
646/// Filter object for MCP tool approval.
647#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
648pub struct McpApprovalFilter {
649    /// A list of tools that always require approval.
650    #[serde(skip_serializing_if = "Option::is_none")]
651    pub always: Option<McpAllowedToolsFilter>,
652    /// A list of tools that never require approval.
653    #[serde(skip_serializing_if = "Option::is_none")]
654    pub never: Option<McpAllowedToolsFilter>,
655}
656
657/// Container configuration for a code interpreter.
658#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
659#[serde(untagged)]
660pub enum CodeInterpreterContainer {
661    /// A simple container ID.
662    Id(String),
663    /// Auto-configured container with optional files.
664    Container(CodeInterpreterContainerKind),
665}
666
667/// Auto configuration for code interpreter container.
668#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
669#[serde(tag = "type", rename_all = "snake_case")]
670pub enum CodeInterpreterContainerKind {
671    Auto {
672        /// Optional list of uploaded file IDs.
673        #[serde(skip_serializing_if = "Option::is_none")]
674        file_ids: Option<Vec<String>>,
675    },
676}
677
678/// Code interpreter tool definition.
679#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
680#[builder(
681    name = "CodeInterpreterArgs",
682    pattern = "mutable",
683    setter(into, strip_option),
684    default
685)]
686#[builder(build_fn(error = "OpenAIError"))]
687pub struct CodeInterpreter {
688    /// Container configuration for running code.
689    pub container: CodeInterpreterContainer,
690}
691
692/// Mask image input for image generation.
693#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
694pub struct InputImageMask {
695    /// Base64-encoded mask image.
696    #[serde(skip_serializing_if = "Option::is_none")]
697    pub image_url: Option<String>,
698    /// File ID for the mask image.
699    #[serde(skip_serializing_if = "Option::is_none")]
700    pub file_id: Option<String>,
701}
702
703/// Image generation tool definition.
704#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default, Builder)]
705#[builder(
706    name = "ImageGenerationArgs",
707    pattern = "mutable",
708    setter(into, strip_option),
709    default
710)]
711#[builder(build_fn(error = "OpenAIError"))]
712pub struct ImageGeneration {
713    /// Background type: transparent, opaque, or auto.
714    #[serde(skip_serializing_if = "Option::is_none")]
715    pub background: Option<ImageGenerationBackground>,
716    /// Optional mask for inpainting.
717    #[serde(skip_serializing_if = "Option::is_none")]
718    pub input_image_mask: Option<InputImageMask>,
719    /// Model to use (default: gpt-image-1).
720    #[serde(skip_serializing_if = "Option::is_none")]
721    pub model: Option<String>,
722    /// Moderation level (default: auto).
723    #[serde(skip_serializing_if = "Option::is_none")]
724    pub moderation: Option<String>,
725    /// Compression level (0-100).
726    #[serde(skip_serializing_if = "Option::is_none")]
727    pub output_compression: Option<u8>,
728    /// Output format: png, webp, or jpeg.
729    #[serde(skip_serializing_if = "Option::is_none")]
730    pub output_format: Option<ImageGenerationOutputFormat>,
731    /// Number of partial images (0-3).
732    #[serde(skip_serializing_if = "Option::is_none")]
733    pub partial_images: Option<u8>,
734    /// Quality: low, medium, high, or auto.
735    #[serde(skip_serializing_if = "Option::is_none")]
736    pub quality: Option<ImageGenerationQuality>,
737    /// Size: e.g. "1024x1024" or auto.
738    #[serde(skip_serializing_if = "Option::is_none")]
739    pub size: Option<ImageGenerationSize>,
740}
741
742#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
743#[serde(rename_all = "lowercase")]
744pub enum ImageGenerationBackground {
745    Transparent,
746    Opaque,
747    Auto,
748}
749
750#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
751#[serde(rename_all = "lowercase")]
752pub enum ImageGenerationOutputFormat {
753    Png,
754    Webp,
755    Jpeg,
756}
757
758#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
759#[serde(rename_all = "lowercase")]
760pub enum ImageGenerationQuality {
761    Low,
762    Medium,
763    High,
764    Auto,
765}
766
767#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
768#[serde(rename_all = "lowercase")]
769pub enum ImageGenerationSize {
770    Auto,
771    #[serde(rename = "1024x1024")]
772    Size1024x1024,
773    #[serde(rename = "1024x1536")]
774    Size1024x1536,
775    #[serde(rename = "1536x1024")]
776    Size1536x1024,
777}
778
779/// Control how the model picks or is forced to pick a tool.
780#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
781#[serde(untagged)]
782pub enum ToolChoice {
783    /// Controls which (if any) tool is called by the model.
784    Mode(ToolChoiceMode),
785    /// Indicates that the model should use a built-in tool to generate a response.
786    Hosted {
787        /// The type of hosted tool the model should to use.
788        #[serde(rename = "type")]
789        kind: HostedToolType,
790    },
791    /// Use this option to force the model to call a specific function.
792    Function {
793        /// The name of the function to call.
794        name: String,
795    },
796}
797
798/// Simple tool-choice modes.
799#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
800#[serde(rename_all = "lowercase")]
801pub enum ToolChoiceMode {
802    /// The model will not call any tool and instead generates a message.
803    None,
804    /// The model can pick between generating a message or calling one or more tools.
805    Auto,
806    /// The model must call one or more tools.
807    Required,
808}
809
810/// Hosted tool type identifiers.
811#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq)]
812#[serde(rename_all = "snake_case")]
813pub enum HostedToolType {
814    FileSearch,
815    WebSearchPreview,
816    ComputerUsePreview,
817}
818
819/// Error returned by the API when a request fails.
820#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
821pub struct ErrorObject {
822    /// The error code for the response.
823    pub code: String,
824    /// A human-readable description of the error.
825    pub message: String,
826}
827
828/// Details about an incomplete response.
829#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
830pub struct IncompleteDetails {
831    /// The reason why the response is incomplete.
832    pub reason: String,
833}
834
835/// A simple text output from the model.
836#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
837pub struct OutputText {
838    /// The annotations of the text output.
839    pub annotations: Vec<Annotation>,
840    /// The text output from the model.
841    pub text: String,
842}
843
844#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
845#[serde(tag = "type", rename_all = "snake_case")]
846pub enum Annotation {
847    /// A citation to a file.
848    FileCitation(FileCitation),
849    /// A citation for a web resource used to generate a model response.
850    UrlCitation(UrlCitation),
851    /// A path to a file.
852    FilePath(FilePath),
853}
854
855#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
856pub struct FileCitation {
857    /// The ID of the file.
858    file_id: String,
859    /// The index of the file in the list of files.
860    index: u32,
861}
862
863#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
864pub struct UrlCitation {
865    /// The index of the last character of the URL citation in the message.
866    end_index: u32,
867    /// The index of the first character of the URL citation in the message.
868    start_index: u32,
869    /// The title of the web resource.
870    title: String,
871    /// The URL of the web resource.
872    url: String,
873}
874
875#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
876pub struct FilePath {
877    /// The ID of the file.
878    file_id: String,
879    /// The index of the file in the list of files.
880    index: u32,
881}
882
883/// A refusal explanation from the model.
884#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
885pub struct Refusal {
886    /// The refusal explanationfrom the model.
887    pub refusal: String,
888}
889
890/// A message generated by the model.
891#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
892pub struct OutputMessage {
893    /// The content of the output message.
894    pub content: Vec<Content>,
895    /// The unique ID of the output message.
896    pub id: String,
897    /// The role of the output message. Always assistant.
898    pub role: Role,
899    /// The status of the message input.
900    pub status: OutputStatus,
901}
902
903#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
904#[serde(tag = "type", rename_all = "snake_case")]
905pub enum Content {
906    /// A text output from the model.
907    OutputText(OutputText),
908    /// A refusal from the model.
909    Refusal(Refusal),
910}
911
912/// Nested content within an output message.
913#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
914#[serde(tag = "type", rename_all = "snake_case")]
915pub enum OutputContent {
916    /// An output message from the model.
917    Message(OutputMessage),
918    /// The results of a file search tool call.
919    FileSearchCall(FileSearchCallOutput),
920    /// A tool call to run a function.
921    FunctionCall(FunctionCall),
922    /// The results of a web search tool call.
923    WebSearchCall(WebSearchCallOutput),
924    /// A tool call to a computer use tool.
925    ComputerCall(ComputerCallOutput),
926    /// A description of the chain of thought used by a reasoning model while generating a response.
927    /// Be sure to include these items in your input to the Responses API for subsequent turns of a
928    /// conversation if you are manually managing context.
929    Reasoning(ReasoningItem),
930    /// Image generation tool call output.
931    ImageGenerationCall(ImageGenerationCallOutput),
932    /// Code interpreter tool call output.
933    CodeInterpreterCall(CodeInterpreterCallOutput),
934    /// Local shell tool call output.
935    LocalShellCall(LocalShellCallOutput),
936    /// MCP tool invocation output.
937    McpCall(McpCallOutput),
938    /// MCP list-tools output.
939    McpListTools(McpListToolsOutput),
940    /// MCP approval request output.
941    McpApprovalRequest(McpApprovalRequestOutput),
942}
943
944/// A reasoning item representing the model's chain of thought, including summary paragraphs.
945#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
946pub struct ReasoningItem {
947    /// Unique identifier of the reasoning content.
948    pub id: String,
949    /// The summarized chain-of-thought paragraphs.
950    pub summary: Vec<SummaryText>,
951    /// The encrypted content of the reasoning item - populated when a response is generated with
952    /// `reasoning.encrypted_content` in the `include` parameter.
953    #[serde(skip_serializing_if = "Option::is_none")]
954    pub encrypted_content: Option<String>,
955    /// The status of the reasoning item.
956    #[serde(skip_serializing_if = "Option::is_none")]
957    pub status: Option<OutputStatus>,
958}
959
960/// A single summary text fragment from reasoning.
961#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
962pub struct SummaryText {
963    /// A short summary of the reasoning used by the model.
964    pub text: String,
965}
966
967/// File search tool call output.
968#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
969pub struct FileSearchCallOutput {
970    /// The unique ID of the file search tool call.
971    pub id: String,
972    /// The queries used to search for files.
973    pub queries: Vec<String>,
974    /// The status of the file search tool call.
975    pub status: FileSearchCallOutputStatus,
976    /// The results of the file search tool call.
977    #[serde(skip_serializing_if = "Option::is_none")]
978    pub results: Option<Vec<FileSearchResult>>,
979}
980
981#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
982#[serde(rename_all = "snake_case")]
983pub enum FileSearchCallOutputStatus {
984    InProgress,
985    Searching,
986    Incomplete,
987    Failed,
988    Completed,
989}
990
991/// A single result from a file search.
992#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
993pub struct FileSearchResult {
994    /// The unique ID of the file.
995    pub file_id: String,
996    /// The name of the file.
997    pub filename: String,
998    /// The relevance score of the file - a value between 0 and 1.
999    pub score: f32,
1000    /// The text that was retrieved from the file.
1001    pub text: String,
1002    /// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
1003    /// additional information about the object in a structured format, and querying for objects
1004    /// API or the dashboard. Keys are strings with a maximum length of 64 characters
1005    /// . Values are strings with a maximum length of 512 characters, booleans, or numbers.
1006    pub attributes: HashMap<String, serde_json::Value>,
1007}
1008
1009#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1010pub struct SafetyCheck {
1011    /// The ID of the safety check.
1012    pub id: String,
1013    /// The type/code of the pending safety check.
1014    pub code: String,
1015    /// Details about the pending safety check.
1016    pub message: String,
1017}
1018
1019/// Web search tool call output.
1020#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1021pub struct WebSearchCallOutput {
1022    /// The unique ID of the web search tool call.
1023    pub id: String,
1024    /// The status of the web search tool call.
1025    pub status: String,
1026}
1027
1028/// Output from a computer tool call.
1029#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1030pub struct ComputerCallOutput {
1031    pub action: ComputerCallAction,
1032    /// An identifier used when responding to the tool call with output.
1033    pub call_id: String,
1034    /// The unique ID of the computer call.
1035    pub id: String,
1036    /// The pending safety checks for the computer call.
1037    pub pending_safety_checks: Vec<SafetyCheck>,
1038    /// The status of the item.
1039    pub status: OutputStatus,
1040}
1041
1042/// A point in 2D space.
1043#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1044pub struct Point {
1045    pub x: i32,
1046    pub y: i32,
1047}
1048
1049/// Represents all user‐triggered actions.
1050#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1051#[serde(tag = "type", rename_all = "snake_case")]
1052pub enum ComputerCallAction {
1053    /// A click action.
1054    Click(Click),
1055
1056    /// A double-click action.
1057    DoubleClick(DoubleClick),
1058
1059    /// A drag action.
1060    Drag(Drag),
1061
1062    /// A keypress action.
1063    KeyPress(KeyPress),
1064
1065    /// A mouse move action.
1066    Move(MoveAction),
1067
1068    /// A screenshot action.
1069    Screenshot,
1070
1071    /// A scroll action.
1072    Scroll(Scroll),
1073
1074    /// A type (text entry) action.
1075    Type(TypeAction),
1076
1077    /// A wait (no-op) action.
1078    Wait,
1079}
1080
1081#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1082#[serde(rename_all = "snake_case")]
1083pub enum ButtonPress {
1084    Left,
1085    Right,
1086    Wheel,
1087    Back,
1088    Forward,
1089}
1090
1091/// A click action.
1092#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1093pub struct Click {
1094    /// Which mouse button was pressed.
1095    pub button: ButtonPress,
1096    /// X‐coordinate of the click.
1097    pub x: i32,
1098    /// Y‐coordinate of the click.
1099    pub y: i32,
1100}
1101
1102/// A double click action.
1103#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1104pub struct DoubleClick {
1105    /// X‐coordinate of the double click.
1106    pub x: i32,
1107    /// Y‐coordinate of the double click.
1108    pub y: i32,
1109}
1110
1111/// A drag action.
1112#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1113pub struct Drag {
1114    /// The path of points the cursor drags through.
1115    pub path: Vec<Point>,
1116    /// X‐coordinate at the end of the drag.
1117    pub x: i32,
1118    /// Y‐coordinate at the end of the drag.
1119    pub y: i32,
1120}
1121
1122/// A keypress action.
1123#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1124pub struct KeyPress {
1125    /// The list of keys to press (e.g. `["Control", "C"]`).
1126    pub keys: Vec<String>,
1127}
1128
1129/// A mouse move action.
1130#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1131pub struct MoveAction {
1132    /// X‐coordinate to move to.
1133    pub x: i32,
1134    /// Y‐coordinate to move to.
1135    pub y: i32,
1136}
1137
1138/// A scroll action.
1139#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1140pub struct Scroll {
1141    /// Horizontal scroll distance.
1142    pub scroll_x: i32,
1143    /// Vertical scroll distance.
1144    pub scroll_y: i32,
1145    /// X‐coordinate where the scroll began.
1146    pub x: i32,
1147    /// Y‐coordinate where the scroll began.
1148    pub y: i32,
1149}
1150
1151/// A typing (text entry) action.
1152#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1153pub struct TypeAction {
1154    /// The text to type.
1155    pub text: String,
1156}
1157
1158/// Metadata for a function call request.
1159#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1160pub struct FunctionCall {
1161    /// The unique ID of the function tool call.
1162    pub id: String,
1163    /// The unique ID of the function tool call generated by the model.
1164    pub call_id: String,
1165    /// The name of the function to run.
1166    pub name: String,
1167    /// A JSON string of the arguments to pass to the function.
1168    pub arguments: String,
1169    /// The status of the item.
1170    pub status: OutputStatus,
1171}
1172
1173/// Output of an image generation request.
1174#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1175pub struct ImageGenerationCallOutput {
1176    /// Unique ID of the image generation call.
1177    pub id: String,
1178    /// Base64-encoded generated image, or null.
1179    pub result: Option<String>,
1180    /// Status of the image generation call.
1181    pub status: String,
1182}
1183
1184/// Output of a code interpreter request.
1185#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1186pub struct CodeInterpreterCallOutput {
1187    /// The code that was executed.
1188    pub code: String,
1189    /// Unique ID of the call.
1190    pub id: String,
1191    /// Status of the tool call.
1192    pub status: String,
1193    /// ID of the container used to run the code.
1194    pub container_id: String,
1195    /// The results of the execution: logs or files.
1196    pub results: Vec<CodeInterpreterResult>,
1197}
1198
1199/// Individual result from a code interpreter: either logs or files.
1200#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1201#[serde(tag = "type", rename_all = "snake_case")]
1202pub enum CodeInterpreterResult {
1203    /// Text logs from the execution.
1204    Logs(CodeInterpreterTextOutput),
1205    /// File outputs from the execution.
1206    Files(CodeInterpreterFileOutput),
1207}
1208
1209/// The output containing execution logs.
1210#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1211pub struct CodeInterpreterTextOutput {
1212    /// The logs of the code interpreter tool call.
1213    pub logs: String,
1214}
1215
1216/// The output containing file references.
1217#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1218pub struct CodeInterpreterFileOutput {
1219    /// List of file IDs produced.
1220    pub files: Vec<CodeInterpreterFile>,
1221}
1222
1223#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1224pub struct CodeInterpreterFile {
1225    /// The ID of the file.
1226    file_id: String,
1227    /// The MIME type of the file.
1228    mime_type: String,
1229}
1230
1231/// Output of a local shell command request.
1232#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1233pub struct LocalShellCallOutput {
1234    /// Details of the exec action.
1235    pub action: LocalShellAction,
1236    /// Unique call identifier for responding to the tool call.
1237    pub call_id: String,
1238    /// Unique ID of the local shell call.
1239    pub id: String,
1240    /// Status of the local shell call.
1241    pub status: String,
1242}
1243
1244/// Define the shape of a local shell action (exec).
1245#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1246pub struct LocalShellAction {
1247    /// The command to run.
1248    pub command: Vec<String>,
1249    /// Environment variables to set for the command.
1250    pub env: HashMap<String, String>,
1251    /// Optional timeout for the command (ms).
1252    pub timeout_ms: Option<u64>,
1253    /// Optional user to run the command as.
1254    pub user: Option<String>,
1255    /// Optional working directory for the command.
1256    pub working_directory: Option<String>,
1257}
1258
1259/// Output of an MCP server tool invocation.
1260#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1261pub struct McpCallOutput {
1262    /// JSON string of the arguments passed.
1263    pub arguments: String,
1264    /// Unique ID of the MCP call.
1265    pub id: String,
1266    /// Name of the tool invoked.
1267    pub name: String,
1268    /// Label of the MCP server.
1269    pub server_label: String,
1270    /// Error message from the call, if any.
1271    pub error: Option<String>,
1272    /// Output from the call, if any.
1273    pub output: Option<String>,
1274}
1275
1276/// Output listing tools available on an MCP server.
1277#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1278pub struct McpListToolsOutput {
1279    /// Unique ID of the list request.
1280    pub id: String,
1281    /// Label of the MCP server.
1282    pub server_label: String,
1283    /// Tools available on the server with metadata.
1284    pub tools: Vec<McpToolInfo>,
1285    /// Error message if listing failed.
1286    #[serde(skip_serializing_if = "Option::is_none")]
1287    pub error: Option<String>,
1288}
1289
1290/// Information about a single tool on an MCP server.
1291#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1292pub struct McpToolInfo {
1293    /// The name of the tool.
1294    pub name: String,
1295    /// The JSON schema describing the tool's input.
1296    pub input_schema: Value,
1297    /// Additional annotations about the tool.
1298    #[serde(skip_serializing_if = "Option::is_none")]
1299    pub annotations: Option<Value>,
1300    /// The description of the tool.
1301    #[serde(skip_serializing_if = "Option::is_none")]
1302    pub description: Option<String>,
1303}
1304
1305/// Output representing a human approval request for an MCP tool.
1306#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1307pub struct McpApprovalRequestOutput {
1308    /// JSON string of arguments for the tool.
1309    pub arguments: String,
1310    /// Unique ID of the approval request.
1311    pub id: String,
1312    /// Name of the tool requiring approval.
1313    pub name: String,
1314    /// Label of the MCP server making the request.
1315    pub server_label: String,
1316}
1317
1318/// Usage statistics for a response.
1319#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1320pub struct Usage {
1321    /// The number of input tokens.
1322    pub input_tokens: u32,
1323    /// A detailed breakdown of the input tokens.
1324    pub input_tokens_details: PromptTokensDetails,
1325    /// The number of output tokens.
1326    pub output_tokens: u32,
1327    /// A detailed breakdown of the output tokens.
1328    pub output_tokens_details: CompletionTokensDetails,
1329    /// The total number of tokens used.
1330    pub total_tokens: u32,
1331}
1332
1333/// The complete response returned by the Responses API.
1334#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1335pub struct Response {
1336    /// Unix timestamp (in seconds) when this Response was created.
1337    pub created_at: u64,
1338
1339    /// Error object if the API failed to generate a response.
1340    #[serde(skip_serializing_if = "Option::is_none")]
1341    pub error: Option<ErrorObject>,
1342
1343    /// Unique identifier for this response.
1344    pub id: String,
1345
1346    /// Details about why the response is incomplete, if any.
1347    #[serde(skip_serializing_if = "Option::is_none")]
1348    pub incomplete_details: Option<IncompleteDetails>,
1349
1350    /// Instructions that were inserted as the first item in context.
1351    #[serde(skip_serializing_if = "Option::is_none")]
1352    pub instructions: Option<String>,
1353
1354    /// The value of `max_output_tokens` that was honored.
1355    #[serde(skip_serializing_if = "Option::is_none")]
1356    pub max_output_tokens: Option<u32>,
1357
1358    /// Metadata tags/values that were attached to this response.
1359    #[serde(skip_serializing_if = "Option::is_none")]
1360    pub metadata: Option<HashMap<String, String>>,
1361
1362    /// Model ID used to generate the response.
1363    pub model: String,
1364
1365    /// The object type – always `response`.
1366    pub object: String,
1367
1368    /// The array of content items generated by the model.
1369    pub output: Vec<OutputContent>,
1370
1371    /// SDK-only convenience property that contains the aggregated text output from all
1372    /// `output_text` items in the `output` array, if any are present.
1373    /// Supported in the Python and JavaScript SDKs.
1374    #[serde(skip_serializing_if = "Option::is_none")]
1375    pub output_text: Option<String>,
1376
1377    /// Whether parallel tool calls were enabled.
1378    #[serde(skip_serializing_if = "Option::is_none")]
1379    pub parallel_tool_calls: Option<bool>,
1380
1381    /// Previous response ID, if creating part of a multi-turn conversation.
1382    #[serde(skip_serializing_if = "Option::is_none")]
1383    pub previous_response_id: Option<String>,
1384
1385    /// Reasoning configuration echoed back (effort, summary settings).
1386    #[serde(skip_serializing_if = "Option::is_none")]
1387    pub reasoning: Option<ReasoningConfig>,
1388
1389    /// Whether to store the generated model response for later retrieval via API.
1390    #[serde(skip_serializing_if = "Option::is_none")]
1391    pub store: Option<bool>,
1392
1393    /// The service tier that actually processed this response.
1394    #[serde(skip_serializing_if = "Option::is_none")]
1395    pub service_tier: Option<ServiceTier>,
1396
1397    /// The status of the response generation.
1398    pub status: Status,
1399
1400    /// Sampling temperature that was used.
1401    #[serde(skip_serializing_if = "Option::is_none")]
1402    pub temperature: Option<f32>,
1403
1404    /// Text format configuration echoed back (plain, json_object, json_schema).
1405    #[serde(skip_serializing_if = "Option::is_none")]
1406    pub text: Option<TextConfig>,
1407
1408    /// How the model chose or was forced to choose a tool.
1409    #[serde(skip_serializing_if = "Option::is_none")]
1410    pub tool_choice: Option<ToolChoice>,
1411
1412    /// Tool definitions that were provided.
1413    #[serde(skip_serializing_if = "Option::is_none")]
1414    pub tools: Option<Vec<ToolDefinition>>,
1415
1416    /// Nucleus sampling cutoff that was used.
1417    #[serde(skip_serializing_if = "Option::is_none")]
1418    pub top_p: Option<f32>,
1419
1420    /// Truncation strategy that was applied.
1421    #[serde(skip_serializing_if = "Option::is_none")]
1422    pub truncation: Option<Truncation>,
1423
1424    /// Token usage statistics for this request.
1425    #[serde(skip_serializing_if = "Option::is_none")]
1426    pub usage: Option<Usage>,
1427
1428    /// End-user ID for which this response was generated.
1429    #[serde(skip_serializing_if = "Option::is_none")]
1430    pub user: Option<String>,
1431}
1432
1433#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1434#[serde(rename_all = "snake_case")]
1435pub enum Status {
1436    Completed,
1437    Failed,
1438    InProgress,
1439    Incomplete,
1440}