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
//! Structures related to image generation and manipulation responses.
/// Define a private namespace for all its items.
mod private
{
// Serde imports
use serde::{ Serialize, Deserialize }; // Added Serialize
/// Represents the url or the content of an image generated by the `OpenAI` API.
///
/// # Used By
/// - `ImagesResponse`
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ] // Added Serialize
pub struct Image
{
/// The base64-encoded JSON of the generated image, if `response_format` is `b64_json`.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub b64_json : Option< String >,
/// The URL of the generated image, if `response_format` is `url` (default). URLs are only valid for 60 minutes.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub url : Option< String >,
/// The prompt that was used to generate the image, if there was any revision to the prompt.
#[ serde( skip_serializing_if = "Option::is_none" ) ]
pub revised_prompt : Option< String >,
}
/// Represents the response object for image generation, edit, and variation endpoints.
///
/// # Used By
/// - `/images/generations` (POST)
/// - `/images/edits` (POST)
/// - `/images/variations` (POST)
#[ derive( Debug, Serialize, Deserialize, Clone, PartialEq ) ] // Added Serialize
pub struct ImagesResponse
{
/// The Unix timestamp (in seconds) when the response was created.
pub created : i64,
/// A list of generated image objects.
pub data : Vec< Image >,
}
/// Request parameters for editing an image.
///
/// # Used By
/// - `/images/edits` (POST request)
#[ derive( Debug, Clone ) ]
pub struct CreateImageEditRequest
{
/// The image to edit. Must be a valid PNG file, less than 4MB, and square.
pub image : Vec< u8 >,
/// The filename for the image file.
pub image_filename : String,
/// An additional image whose fully transparent areas indicate where image should be edited.
/// Must be a PNG file, less than 4MB, and have the same dimensions as image.
pub mask : Option< Vec< u8 > >,
/// The filename for the mask file (if mask is provided).
pub mask_filename : Option< String >,
/// A text description of the desired image(s). The maximum length is 1000 characters.
pub prompt : String,
/// The model to use for image generation.
pub model : Option< String >,
/// The number of images to generate. Must be between 1 and 10.
pub n : Option< i32 >,
/// The size of the generated images.
pub size : Option< String >,
/// The format in which the generated images are returned.
pub response_format : Option< String >,
/// A unique identifier representing your end-user.
pub user : Option< String >,
}
/// Request parameters for creating a variation of an image.
///
/// # Used By
/// - `/images/variations` (POST request)
#[ derive( Debug, Clone ) ]
pub struct CreateImageVariationRequest
{
/// The image to create a variation of. Must be a valid PNG file, less than 4MB, and square.
pub image : Vec< u8 >,
/// The filename for the image file.
pub image_filename : String,
/// The model to use for image generation.
pub model : Option< String >,
/// The number of images to generate. Must be between 1 and 10.
pub n : Option< i32 >,
/// The format in which the generated images are returned.
pub response_format : Option< String >,
/// The size of the generated images.
pub size : Option< String >,
/// A unique identifier representing your end-user.
pub user : Option< String >,
}
} // end mod private
crate ::mod_interface!
{
exposed use
{
Image,
ImagesResponse,
CreateImageEditRequest,
CreateImageVariationRequest,
};
}