api_openai 0.3.0

OpenAI's API for accessing large language models (LLMs).
Documentation
//! 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,
  };
}