pub struct ImagesApi<'a>(/* private fields */);
Expand description
ImagesApi
struct to interact with the image generation, editing, and variation endpoints of the API.
Implementations§
Source§impl<'a> ImagesApi<'a>
impl<'a> ImagesApi<'a>
Sourcepub async fn generate(
&self,
prompt: &str,
model: &str,
size: Option<&str>,
response_format: Option<&str>,
n: Option<u64>,
user: Option<&str>,
) -> OpenAIResult<Value>
pub async fn generate( &self, prompt: &str, model: &str, size: Option<&str>, response_format: Option<&str>, n: Option<u64>, user: Option<&str>, ) -> OpenAIResult<Value>
Generate an image based on the provided prompt and parameters.
§Arguments
prompt
- The text prompt to generate the image from.model
- The name of the model to use for generating the image.size
- Optional size of the image.response_format
- Optional response format (e.g.,json
,url
).n
- Optional number of images to generate.user
- Optional user ID.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn edit(
&self,
model: &str,
image_path: &str,
mask_path: &str,
prompt: &str,
size: Option<&str>,
response_format: Option<&str>,
n: Option<u64>,
user: Option<&str>,
) -> OpenAIResult<Value>
pub async fn edit( &self, model: &str, image_path: &str, mask_path: &str, prompt: &str, size: Option<&str>, response_format: Option<&str>, n: Option<u64>, user: Option<&str>, ) -> OpenAIResult<Value>
Edit an existing image using the provided parameters and mask.
§Arguments
model
- The name of the model to use for editing the image.image_path
- The local file path to the image.mask_path
- The local file path to the mask.prompt
- The text prompt to guide the editing.size
- Optional size of the edited image.response_format
- Optional response format (e.g.,json
,url
).n
- Optional number of edited images to generate.user
- Optional user ID.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Sourcepub async fn variation(
&self,
model: &str,
image_path: &str,
size: Option<&str>,
response_format: Option<&str>,
n: Option<u64>,
user: Option<&str>,
) -> OpenAIResult<Value>
pub async fn variation( &self, model: &str, image_path: &str, size: Option<&str>, response_format: Option<&str>, n: Option<u64>, user: Option<&str>, ) -> OpenAIResult<Value>
Create variations of an existing image using the provided parameters.
§Arguments
model
- The name of the model to use for generating variations.image_path
- The local file path to the image.size
- Optional size of the variation images.response_format
- Optional response format (e.g.,json
,url
).n
- Optional number of variation images to generate.user
- Optional user ID.
§Returns
A Result containing the JSON response as serde_json::Value
on success, or an OpenAIError
on failure.
Auto Trait Implementations§
impl<'a> Freeze for ImagesApi<'a>
impl<'a> !RefUnwindSafe for ImagesApi<'a>
impl<'a> Send for ImagesApi<'a>
impl<'a> Sync for ImagesApi<'a>
impl<'a> Unpin for ImagesApi<'a>
impl<'a> !UnwindSafe for ImagesApi<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more