Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion async-openai/src/types/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub struct ImageInput {
#[builder(build_fn(error = "OpenAIError"))]
pub struct CreateImageEditRequest {
/// The image to edit. Must be a valid PNG file, less than 4MB, and square. If mask is not provided, image must have transparency, which will be used as the mask.
pub image: ImageInput,
pub image: Vec<ImageInput>,

/// A text description of the desired image(s). The maximum length is 1000 characters.
pub prompt: String,
Expand Down
8 changes: 5 additions & 3 deletions async-openai/src/types/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,12 +893,14 @@ impl AsyncTryFrom<CreateImageEditRequest> for reqwest::multipart::Form {
type Error = OpenAIError;

async fn try_from(request: CreateImageEditRequest) -> Result<Self, Self::Error> {
let image_part = create_file_part(request.image.source).await?;

let mut form = reqwest::multipart::Form::new()
.part("image", image_part)
.text("prompt", request.prompt);

for image in request.image {
let image_part = create_file_part(image.source).await?;
form = form.part("image[]", image_part);
}

if let Some(mask) = request.mask {
let mask_part = create_file_part(mask.source).await?;
form = form.part("mask", mask_part);
Expand Down