rig/client/image_generation.rs
1#[cfg(feature = "image")]
2mod image {
3 use crate::image_generation::ImageGenerationModel;
4
5 /// A provider client with image generation capabilities.
6 /// Clone is required for conversions between client types.
7 pub trait ImageGenerationClient {
8 /// The ImageGenerationModel used by the Client
9 type ImageGenerationModel: ImageGenerationModel<Client = Self>;
10
11 /// Create an image generation model with the given name.
12 ///
13 /// # Example with OpenAI
14 /// ```
15 /// use rig::prelude::*;
16 /// use rig::providers::openai::{Client, self};
17 ///
18 /// // Initialize the OpenAI client
19 /// let openai = Client::new("your-open-ai-api-key");
20 ///
21 /// let gpt4 = openai.image_generation_model(openai::DALL_E_3);
22 /// ```
23 fn image_generation_model(&self, model: impl Into<String>) -> Self::ImageGenerationModel;
24
25 /// Create an image generation model with the given name.
26 ///
27 /// # Example with OpenAI
28 /// ```
29 /// use rig::prelude::*;
30 /// use rig::providers::openai::{Client, self};
31 ///
32 /// // Initialize the OpenAI client
33 /// let openai = Client::new("your-open-ai-api-key");
34 ///
35 /// let gpt4 = openai.image_generation_model(openai::DALL_E_3);
36 /// ```
37 fn custom_image_generation_model(
38 &self,
39 model: impl Into<String>,
40 ) -> Self::ImageGenerationModel {
41 Self::ImageGenerationModel::make(self, model)
42 }
43 }
44}
45
46#[cfg(feature = "image")]
47pub use image::*;