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