Skip to content

Commit 08cae25

Browse files
authored
Add support for multiple image files in CreateImageEditRequest (#366)
Fixes #363
1 parent 917fee1 commit 08cae25

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

async-openai/src/types/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub struct ImageInput {
163163
#[builder(build_fn(error = "OpenAIError"))]
164164
pub struct CreateImageEditRequest {
165165
/// 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.
166-
pub image: ImageInput,
166+
pub image: Vec<ImageInput>,
167167

168168
/// A text description of the desired image(s). The maximum length is 1000 characters.
169169
pub prompt: String,

async-openai/src/types/impls.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -993,12 +993,14 @@ impl AsyncTryFrom<CreateImageEditRequest> for reqwest::multipart::Form {
993993
type Error = OpenAIError;
994994

995995
async fn try_from(request: CreateImageEditRequest) -> Result<Self, Self::Error> {
996-
let image_part = create_file_part(request.image.source).await?;
997-
998996
let mut form = reqwest::multipart::Form::new()
999-
.part("image", image_part)
1000997
.text("prompt", request.prompt);
1001998

999+
for image in request.image {
1000+
let image_part = create_file_part(image.source).await?;
1001+
form = form.part("image[]", image_part);
1002+
}
1003+
10021004
if let Some(mask) = request.mask {
10031005
let mask_part = create_file_part(mask.source).await?;
10041006
form = form.part("mask", mask_part);

0 commit comments

Comments
 (0)