openai/models/
create_image_request.rs

1/*
2 * OpenAI API
3 *
4 * APIs for sampling from and fine-tuning language models
5 *
6 * The version of the OpenAPI document: 1.2.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12
13
14#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
15pub struct CreateImageRequest {
16    /// A text description of the desired image(s). The maximum length is 1000 characters.
17    #[serde(rename = "prompt")]
18    pub prompt: String,
19    /// The number of images to generate. Must be between 1 and 10.
20    #[serde(rename = "n", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
21    pub n: Option<Option<i32>>,
22    /// The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
23    #[serde(rename = "size", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
24    pub size: Option<Option<Size>>,
25    /// The format in which the generated images are returned. Must be one of `url` or `b64_json`.
26    #[serde(rename = "response_format", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")]
27    pub response_format: Option<Option<ResponseFormat>>,
28    /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). 
29    #[serde(rename = "user", skip_serializing_if = "Option::is_none")]
30    pub user: Option<String>,
31}
32
33impl CreateImageRequest {
34    pub fn new(prompt: String) -> CreateImageRequest {
35        CreateImageRequest {
36            prompt,
37            n: None,
38            size: None,
39            response_format: None,
40            user: None,
41        }
42    }
43}
44
45/// The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x1024`.
46#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
47pub enum Size {
48    #[serde(rename = "256x256")]
49    Variant256x256,
50    #[serde(rename = "512x512")]
51    Variant512x512,
52    #[serde(rename = "1024x1024")]
53    Variant1024x1024,
54}
55
56impl Default for Size {
57    fn default() -> Size {
58        Self::Variant256x256
59    }
60}
61/// The format in which the generated images are returned. Must be one of `url` or `b64_json`.
62#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
63pub enum ResponseFormat {
64    #[serde(rename = "url")]
65    Url,
66    #[serde(rename = "b64_json")]
67    B64Json,
68}
69
70impl Default for ResponseFormat {
71    fn default() -> ResponseFormat {
72        Self::Url
73    }
74}
75