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    /// 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}
944
945/// A single result from a file search.
946#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
947pub struct FileSearchResult {
948    /// The unique ID of the file.
949    pub file_id: String,
950    /// The name of the file.
951    pub filename: String,
952    /// The relevance score of the file - a value between 0 and 1.
953    pub score: f32,
954    /// The text that was retrieved from the file.
955    pub text: String,
956    /// Set of 16 key-value pairs that can be attached to an object. This can be useful for storing
957    /// additional information about the object in a structured format, and querying for objects
958    /// API or the dashboard. Keys are strings with a maximum length of 64 characters
959    /// . Values are strings with a maximum length of 512 characters, booleans, or numbers.
960    pub attributes: HashMap<String, serde_json::Value>,
961}
962
963#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
964pub struct SafetyCheck {
965    /// The ID of the safety check.
966    pub id: String,
967    /// The type/code of the pending safety check.
968    pub code: String,
969    /// Details about the pending safety check.
970    pub message: String,
971}
972
973/// Web search tool call output.
974#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
975pub struct WebSearchCallOutput {
976    /// The unique ID of the web search tool call.
977    pub id: String,
978    /// The status of the web search tool call.
979    pub status: String,
980}
981
982/// Output from a computer tool call.
983#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
984pub struct ComputerCallOutput {
985    pub action: ComputerCallAction,
986    /// An identifier used when responding to the tool call with output.
987    pub call_id: String,
988    /// The unique ID of the computer call.
989    pub id: String,
990    /// The pending safety checks for the computer call.
991    pub pending_safety_checks: Vec<SafetyCheck>,
992    /// The status of the item.
993    pub status: OutputStatus,
994}
995
996/// A point in 2D space.
997#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
998pub struct Point {
999    pub x: i32,
1000    pub y: i32,
1001}
1002
1003/// Represents all user‐triggered actions.
1004#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1005#[serde(tag = "type", rename_all = "snake_case")]
1006pub enum ComputerCallAction {
1007    /// A click action.
1008    Click(Click),
1009
1010    /// A double-click action.
1011    DoubleClick(DoubleClick),
1012
1013    /// A drag action.
1014    Drag(Drag),
1015
1016    /// A keypress action.
1017    KeyPress(KeyPress),
1018
1019    /// A mouse move action.
1020    Move(MoveAction),
1021
1022    /// A screenshot action.
1023    Screenshot,
1024
1025    /// A scroll action.
1026    Scroll(Scroll),
1027
1028    /// A type (text entry) action.
1029    Type(TypeAction),
1030
1031    /// A wait (no-op) action.
1032    Wait,
1033}
1034
1035#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1036#[serde(rename_all = "snake_case")]
1037pub enum ButtonPress {
1038    Left,
1039    Right,
1040    Wheel,
1041    Back,
1042    Forward,
1043}
1044
1045/// A click action.
1046#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1047pub struct Click {
1048    /// Which mouse button was pressed.
1049    pub button: ButtonPress,
1050    /// X‐coordinate of the click.
1051    pub x: i32,
1052    /// Y‐coordinate of the click.
1053    pub y: i32,
1054}
1055
1056/// A double click action.
1057#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1058pub struct DoubleClick {
1059    /// X‐coordinate of the double click.
1060    pub x: i32,
1061    /// Y‐coordinate of the double click.
1062    pub y: i32,
1063}
1064
1065/// A drag action.
1066#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1067pub struct Drag {
1068    /// The path of points the cursor drags through.
1069    pub path: Vec<Point>,
1070    /// X‐coordinate at the end of the drag.
1071    pub x: i32,
1072    /// Y‐coordinate at the end of the drag.
1073    pub y: i32,
1074}
1075
1076/// A keypress action.
1077#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1078pub struct KeyPress {
1079    /// The list of keys to press (e.g. `["Control", "C"]`).
1080    pub keys: Vec<String>,
1081}
1082
1083/// A mouse move action.
1084#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1085pub struct MoveAction {
1086    /// X‐coordinate to move to.
1087    pub x: i32,
1088    /// Y‐coordinate to move to.
1089    pub y: i32,
1090}
1091
1092/// A scroll action.
1093#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1094pub struct Scroll {
1095    /// Horizontal scroll distance.
1096    pub scroll_x: i32,
1097    /// Vertical scroll distance.
1098    pub scroll_y: i32,
1099    /// X‐coordinate where the scroll began.
1100    pub x: i32,
1101    /// Y‐coordinate where the scroll began.
1102    pub y: i32,
1103}
1104
1105/// A typing (text entry) action.
1106#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
1107pub struct TypeAction {
1108    /// The text to type.
1109    pub text: String,
1110}
1111
1112/// Metadata for a function call request.
1113#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1114pub struct FunctionCall {
1115    /// The unique ID of the function tool call.
1116    pub id: String,
1117    /// The unique ID of the function tool call generated by the model.
1118    pub call_id: String,
1119    /// The name of the function to run.
1120    pub name: String,
1121    /// A JSON string of the arguments to pass to the function.
1122    pub arguments: String,
1123    /// The status of the item.
1124    pub status: OutputStatus,
1125}
1126
1127/// Output of an image generation request.
1128#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1129pub struct ImageGenerationCallOutput {
1130    /// Unique ID of the image generation call.
1131    pub id: String,
1132    /// Base64-encoded generated image, or null.
1133    pub result: Option<String>,
1134    /// Status of the image generation call.
1135    pub status: String,
1136}
1137
1138/// Output of a code interpreter request.
1139#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1140pub struct CodeInterpreterCallOutput {
1141    /// The code that was executed.
1142    pub code: String,
1143    /// Unique ID of the call.
1144    pub id: String,
1145    /// Status of the tool call.
1146    pub status: String,
1147    /// ID of the container used to run the code.
1148    pub container_id: String,
1149    /// The results of the execution: logs or files.
1150    pub results: Vec<CodeInterpreterResult>,
1151}
1152
1153/// Individual result from a code interpreter: either logs or files.
1154#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1155#[serde(tag = "type", rename_all = "snake_case")]
1156pub enum CodeInterpreterResult {
1157    /// Text logs from the execution.
1158    Logs(CodeInterpreterTextOutput),
1159    /// File outputs from the execution.
1160    Files(CodeInterpreterFileOutput),
1161}
1162
1163/// The output containing execution logs.
1164#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1165pub struct CodeInterpreterTextOutput {
1166    /// The logs of the code interpreter tool call.
1167    pub logs: String,
1168}
1169
1170/// The output containing file references.
1171#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1172pub struct CodeInterpreterFileOutput {
1173    /// List of file IDs produced.
1174    pub files: Vec<CodeInterpreterFile>,
1175}
1176
1177#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1178pub struct CodeInterpreterFile {
1179    /// The ID of the file.
1180    file_id: String,
1181    /// The MIME type of the file.
1182    mime_type: String,
1183}
1184
1185/// Output of a local shell command request.
1186#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1187pub struct LocalShellCallOutput {
1188    /// Details of the exec action.
1189    pub action: LocalShellAction,
1190    /// Unique call identifier for responding to the tool call.
1191    pub call_id: String,
1192    /// Unique ID of the local shell call.
1193    pub id: String,
1194    /// Status of the local shell call.
1195    pub status: String,
1196}
1197
1198/// Define the shape of a local shell action (exec).
1199#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1200pub struct LocalShellAction {
1201    /// The command to run.
1202    pub command: Vec<String>,
1203    /// Environment variables to set for the command.
1204    pub env: HashMap<String, String>,
1205    /// Optional timeout for the command (ms).
1206    pub timeout_ms: Option<u64>,
1207    /// Optional user to run the command as.
1208    pub user: Option<String>,
1209    /// Optional working directory for the command.
1210    pub working_directory: Option<String>,
1211}
1212
1213/// Output of an MCP server tool invocation.
1214#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1215pub struct McpCallOutput {
1216    /// JSON string of the arguments passed.
1217    pub arguments: String,
1218    /// Unique ID of the MCP call.
1219    pub id: String,
1220    /// Name of the tool invoked.
1221    pub name: String,
1222    /// Label of the MCP server.
1223    pub server_label: String,
1224    /// Error message from the call, if any.
1225    pub error: Option<String>,
1226    /// Output from the call, if any.
1227    pub output: Option<String>,
1228}
1229
1230/// Output listing tools available on an MCP server.
1231#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1232pub struct McpListToolsOutput {
1233    /// Unique ID of the list request.
1234    pub id: String,
1235    /// Label of the MCP server.
1236    pub server_label: String,
1237    /// Tools available on the server with metadata.
1238    pub tools: Vec<McpToolInfo>,
1239    /// Error message if listing failed.
1240    #[serde(skip_serializing_if = "Option::is_none")]
1241    pub error: Option<String>,
1242}
1243
1244/// Information about a single tool on an MCP server.
1245#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1246pub struct McpToolInfo {
1247    /// The name of the tool.
1248    pub name: String,
1249    /// The JSON schema describing the tool's input.
1250    pub input_schema: Value,
1251    /// Additional annotations about the tool.
1252    #[serde(skip_serializing_if = "Option::is_none")]
1253    pub annotations: Option<Value>,
1254    /// The description of the tool.
1255    #[serde(skip_serializing_if = "Option::is_none")]
1256    pub description: Option<String>,
1257}
1258
1259/// Output representing a human approval request for an MCP tool.
1260#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1261pub struct McpApprovalRequestOutput {
1262    /// JSON string of arguments for the tool.
1263    pub arguments: String,
1264    /// Unique ID of the approval request.
1265    pub id: String,
1266    /// Name of the tool requiring approval.
1267    pub name: String,
1268    /// Label of the MCP server making the request.
1269    pub server_label: String,
1270}
1271
1272/// Usage statistics for a response.
1273#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1274pub struct Usage {
1275    /// The number of input tokens.
1276    pub input_tokens: u32,
1277    /// A detailed breakdown of the input tokens.
1278    pub input_tokens_details: PromptTokensDetails,
1279    /// The number of output tokens.
1280    pub output_tokens: u32,
1281    /// A detailed breakdown of the output tokens.
1282    pub output_tokens_details: CompletionTokensDetails,
1283    /// The total number of tokens used.
1284    pub total_tokens: u32,
1285}
1286
1287/// The complete response returned by the Responses API.
1288#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1289pub struct Response {
1290    /// Unix timestamp (in seconds) when this Response was created.
1291    pub created_at: u64,
1292
1293    /// Error object if the API failed to generate a response.
1294    #[serde(skip_serializing_if = "Option::is_none")]
1295    pub error: Option<ErrorObject>,
1296
1297    /// Unique identifier for this response.
1298    pub id: String,
1299
1300    /// Details about why the response is incomplete, if any.
1301    #[serde(skip_serializing_if = "Option::is_none")]
1302    pub incomplete_details: Option<IncompleteDetails>,
1303
1304    /// Instructions that were inserted as the first item in context.
1305    #[serde(skip_serializing_if = "Option::is_none")]
1306    pub instructions: Option<String>,
1307
1308    /// The value of `max_output_tokens` that was honored.
1309    #[serde(skip_serializing_if = "Option::is_none")]
1310    pub max_output_tokens: Option<u32>,
1311
1312    /// Metadata tags/values that were attached to this response.
1313    #[serde(skip_serializing_if = "Option::is_none")]
1314    pub metadata: Option<HashMap<String, String>>,
1315
1316    /// Model ID used to generate the response.
1317    pub model: String,
1318
1319    /// The object type – always `response`.
1320    pub object: String,
1321
1322    /// The array of content items generated by the model.
1323    pub output: Vec<OutputContent>,
1324
1325    /// Whether parallel tool calls were enabled.
1326    #[serde(skip_serializing_if = "Option::is_none")]
1327    pub parallel_tool_calls: Option<bool>,
1328
1329    /// Previous response ID, if creating part of a multi-turn conversation.
1330    #[serde(skip_serializing_if = "Option::is_none")]
1331    pub previous_response_id: Option<String>,
1332
1333    /// Reasoning configuration echoed back (effort, summary settings).
1334    #[serde(skip_serializing_if = "Option::is_none")]
1335    pub reasoning: Option<ReasoningConfig>,
1336
1337    /// The service tier that actually processed this response.
1338    #[serde(skip_serializing_if = "Option::is_none")]
1339    pub service_tier: Option<ServiceTier>,
1340
1341    /// The status of the response generation.
1342    pub status: Status,
1343
1344    /// Sampling temperature that was used.
1345    #[serde(skip_serializing_if = "Option::is_none")]
1346    pub temperature: Option<f32>,
1347
1348    /// Text format configuration echoed back (plain, json_object, json_schema).
1349    #[serde(skip_serializing_if = "Option::is_none")]
1350    pub text: Option<TextConfig>,
1351
1352    /// How the model chose or was forced to choose a tool.
1353    #[serde(skip_serializing_if = "Option::is_none")]
1354    pub tool_choice: Option<ToolChoice>,
1355
1356    /// Tool definitions that were provided.
1357    #[serde(skip_serializing_if = "Option::is_none")]
1358    pub tools: Option<Vec<ToolDefinition>>,
1359
1360    /// Nucleus sampling cutoff that was used.
1361    #[serde(skip_serializing_if = "Option::is_none")]
1362    pub top_p: Option<f32>,
1363
1364    /// Truncation strategy that was applied.
1365    #[serde(skip_serializing_if = "Option::is_none")]
1366    pub truncation: Option<Truncation>,
1367
1368    /// Token usage statistics for this request.
1369    #[serde(skip_serializing_if = "Option::is_none")]
1370    pub usage: Option<Usage>,
1371
1372    /// End-user ID for which this response was generated.
1373    #[serde(skip_serializing_if = "Option::is_none")]
1374    pub user: Option<String>,
1375}
1376
1377#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
1378#[serde(rename_all = "snake_case")]
1379pub enum Status {
1380    Completed,
1381    Failed,
1382    InProgress,
1383    Incomplete,
1384}