1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// BetaImageGenTool : A tool that generates images using the GPT image models.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaImageGenTool {
/// The type of the image generation tool. Always `image_generation`.
#[serde(rename = "type")]
pub r#type: Type,
/// ID of the model to use
#[serde(rename = "model", skip_serializing_if = "Option::is_none")]
pub model: Option<String>,
/// The quality of the generated image. The GPT image models support `low`, `medium`, and `high`. `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including their `2026-09-08` snapshots, also support `xhigh` and `max`. Default: `auto`.
#[serde(rename = "quality", skip_serializing_if = "Option::is_none")]
pub quality: Option<Quality>,
#[serde(rename = "size", skip_serializing_if = "Option::is_none")]
pub size: Option<Box<models::ImageGenToolSize>>,
/// The output format of the generated image. One of `png`, `webp`, or `jpeg`. Default: `png`.
#[serde(rename = "output_format", skip_serializing_if = "Option::is_none")]
pub output_format: Option<OutputFormat>,
/// Compression level for the output image. Default: 100.
#[serde(rename = "output_compression", skip_serializing_if = "Option::is_none")]
pub output_compression: Option<i32>,
/// Moderation level for the generated image. Default: `auto`.
#[serde(rename = "moderation", skip_serializing_if = "Option::is_none")]
pub moderation: Option<Moderation>,
/// Set the background of the generated image. One of `transparent`, `opaque`, or `auto`. `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including their `2026-09-08` snapshots, support `opaque` and `transparent` backgrounds. Transparent backgrounds are available for supported GPT Image models. For `gpt-image-2` and `gpt-image-2-2026-04-21`, this support is in preview. When using `transparent`, set the output format to `png` or `webp`. Default: `auto`.
#[serde(rename = "background", skip_serializing_if = "Option::is_none")]
pub background: Option<Background>,
#[serde(
rename = "input_fidelity",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub input_fidelity: Option<Option<models::BetaInputFidelity>>,
#[serde(rename = "input_image_mask", skip_serializing_if = "Option::is_none")]
pub input_image_mask: Option<models::ImageGenToolInputImageMask>,
/// Number of partial images to generate in streaming mode, from 0 (default value) to 3.
#[serde(rename = "partial_images", skip_serializing_if = "Option::is_none")]
pub partial_images: Option<i32>,
#[serde(rename = "action", skip_serializing_if = "Option::is_none")]
pub action: Option<models::BetaImageGenActionEnum>,
}
impl BetaImageGenTool {
/// A tool that generates images using the GPT image models.
pub fn new(r#type: Type) -> BetaImageGenTool {
BetaImageGenTool {
r#type,
model: None,
quality: None,
size: None,
output_format: None,
output_compression: None,
moderation: None,
background: None,
input_fidelity: None,
input_image_mask: None,
partial_images: None,
action: None,
}
}
}
/// The type of the image generation tool. Always `image_generation`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "image_generation")]
ImageGeneration,
}
impl Default for Type {
fn default() -> Type {
Self::ImageGeneration
}
}
/// The quality of the generated image. The GPT image models support `low`, `medium`, and `high`. `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including their `2026-09-08` snapshots, also support `xhigh` and `max`. Default: `auto`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Quality {
#[serde(rename = "low")]
Low,
#[serde(rename = "medium")]
Medium,
#[serde(rename = "high")]
High,
#[serde(rename = "xhigh")]
Xhigh,
#[serde(rename = "max")]
Max,
#[serde(rename = "auto")]
Auto,
}
impl Default for Quality {
fn default() -> Quality {
Self::Low
}
}
/// The output format of the generated image. One of `png`, `webp`, or `jpeg`. Default: `png`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum OutputFormat {
#[serde(rename = "png")]
Png,
#[serde(rename = "webp")]
Webp,
#[serde(rename = "jpeg")]
Jpeg,
}
impl Default for OutputFormat {
fn default() -> OutputFormat {
Self::Png
}
}
/// Moderation level for the generated image. Default: `auto`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Moderation {
#[serde(rename = "auto")]
Auto,
#[serde(rename = "low")]
Low,
}
impl Default for Moderation {
fn default() -> Moderation {
Self::Auto
}
}
/// Set the background of the generated image. One of `transparent`, `opaque`, or `auto`. `gpt-image-2.5-sunburst` and `gpt-image-2.5-flare`, including their `2026-09-08` snapshots, support `opaque` and `transparent` backgrounds. Transparent backgrounds are available for supported GPT Image models. For `gpt-image-2` and `gpt-image-2-2026-04-21`, this support is in preview. When using `transparent`, set the output format to `png` or `webp`. Default: `auto`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Background {
#[serde(rename = "transparent")]
Transparent,
#[serde(rename = "opaque")]
Opaque,
#[serde(rename = "auto")]
Auto,
}
impl Default for Background {
fn default() -> Background {
Self::Transparent
}
}
impl std::fmt::Display for BetaImageGenTool {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}