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