openai_api_rs/v1/
image.rs

1use serde::{Deserialize, Serialize};
2use std::option::Option;
3
4use crate::impl_builder_methods;
5
6#[derive(Debug, Deserialize, Serialize)]
7pub struct ImageData {
8    pub url: String,
9}
10
11#[derive(Debug, Serialize, Clone, Deserialize)]
12pub struct ImageGenerationRequest {
13    pub prompt: String,
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub model: Option<String>,
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub n: Option<i32>,
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub size: Option<String>,
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub response_format: Option<String>,
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub user: Option<String>,
24}
25
26impl ImageGenerationRequest {
27    pub fn new(prompt: String) -> Self {
28        Self {
29            prompt,
30            model: None,
31            n: None,
32            size: None,
33            response_format: None,
34            user: None,
35        }
36    }
37}
38
39impl_builder_methods!(
40    ImageGenerationRequest,
41    model: String,
42    n: i32,
43    size: String,
44    response_format: String,
45    user: String
46);
47
48#[derive(Debug, Deserialize, Serialize)]
49pub struct ImageGenerationResponse {
50    pub created: i64,
51    pub data: Vec<ImageData>,
52}
53
54#[derive(Debug, Serialize, Clone)]
55pub struct ImageEditRequest {
56    pub image: String,
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub mask: Option<String>,
59    pub prompt: String,
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub model: Option<String>,
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub n: Option<i32>,
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub size: Option<String>,
66    #[serde(skip_serializing_if = "Option::is_none")]
67    pub response_format: Option<String>,
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub user: Option<String>,
70}
71
72impl ImageEditRequest {
73    pub fn new(image: String, prompt: String) -> Self {
74        Self {
75            image,
76            prompt,
77            mask: None,
78            model: None,
79            n: None,
80            size: None,
81            response_format: None,
82            user: None,
83        }
84    }
85}
86
87impl_builder_methods!(
88    ImageEditRequest,
89    mask: String,
90    model: String,
91    n: i32,
92    size: String,
93    response_format: String,
94    user: String
95);
96
97#[derive(Debug, Deserialize, Serialize)]
98pub struct ImageEditResponse {
99    pub created: i64,
100    pub data: Vec<ImageData>,
101}
102
103#[derive(Debug, Serialize, Clone)]
104pub struct ImageVariationRequest {
105    pub image: String,
106    #[serde(skip_serializing_if = "Option::is_none")]
107    pub n: Option<i32>,
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub model: Option<String>,
110    #[serde(skip_serializing_if = "Option::is_none")]
111    pub size: Option<String>,
112    #[serde(skip_serializing_if = "Option::is_none")]
113    pub response_format: Option<String>,
114    #[serde(skip_serializing_if = "Option::is_none")]
115    pub user: Option<String>,
116}
117
118impl ImageVariationRequest {
119    pub fn new(image: String) -> Self {
120        Self {
121            image,
122            model: None,
123            n: None,
124            size: None,
125            response_format: None,
126            user: None,
127        }
128    }
129}
130
131impl_builder_methods!(
132    ImageVariationRequest,
133    model: String,
134    n: i32,
135    size: String,
136    response_format: String,
137    user: String
138);
139
140#[derive(Debug, Deserialize, Serialize)]
141pub struct ImageVariationResponse {
142    pub created: i64,
143    pub data: Vec<ImageData>,
144}