openai_compat/types/
images.rs1use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize)]
9pub struct ImageGenerationRequest {
10 pub prompt: String,
11 #[serde(skip_serializing_if = "Option::is_none")]
12 pub model: Option<String>,
13 #[serde(skip_serializing_if = "Option::is_none")]
14 pub n: Option<u32>,
15 #[serde(skip_serializing_if = "Option::is_none")]
17 pub size: Option<String>,
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub quality: Option<String>,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub response_format: Option<String>,
24 #[serde(skip_serializing_if = "Option::is_none")]
26 pub style: Option<String>,
27 #[serde(skip_serializing_if = "Option::is_none")]
28 pub user: Option<String>,
29}
30
31impl ImageGenerationRequest {
32 pub fn new(prompt: impl Into<String>) -> Self {
33 Self {
34 prompt: prompt.into(),
35 model: None,
36 n: None,
37 size: None,
38 quality: None,
39 response_format: None,
40 style: None,
41 user: None,
42 }
43 }
44
45 pub fn model(mut self, model: impl Into<String>) -> Self {
46 self.model = Some(model.into());
47 self
48 }
49
50 pub fn n(mut self, n: u32) -> Self {
51 self.n = Some(n);
52 self
53 }
54
55 pub fn size(mut self, size: impl Into<String>) -> Self {
56 self.size = Some(size.into());
57 self
58 }
59
60 pub fn quality(mut self, quality: impl Into<String>) -> Self {
61 self.quality = Some(quality.into());
62 self
63 }
64
65 pub fn response_format(mut self, response_format: impl Into<String>) -> Self {
66 self.response_format = Some(response_format.into());
67 self
68 }
69
70 pub fn style(mut self, style: impl Into<String>) -> Self {
72 self.style = Some(style.into());
73 self
74 }
75
76 pub fn user(mut self, user: impl Into<String>) -> Self {
77 self.user = Some(user.into());
78 self
79 }
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[non_exhaustive]
85pub struct ImageData {
86 #[serde(default)]
87 pub url: Option<String>,
88 #[serde(default)]
89 pub b64_json: Option<String>,
90 #[serde(default)]
91 pub revised_prompt: Option<String>,
92}
93
94#[derive(Debug, Clone, Serialize, Deserialize)]
96#[non_exhaustive]
97pub struct ImagesResponse {
98 #[serde(default)]
99 pub created: Option<i64>,
100 pub data: Vec<ImageData>,
101}