Closed
Description
Hi there!
I’m trying to call openAIClient.images().edit(...)
in the Java SDK, but I keep getting: 400: Invalid type for 'image': expected one of an array of files or file, but got a string instead.
I’ve tried a few different ways to pass the image, but so far no luck. For example, here’s a minimal repro:
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.images.ImageEditParams;
import com.openai.models.images.ImagesResponse;
import java.io.InputStream;
import java.net.URL;
public class ImageEditTest {
public static void main(String[] args) throws Exception {
InputStream is = new URL("https://upload.wikimedia.org/wikipedia/en/thumb/7/7d/Lenna_%28test_image%29.png/320px-Lenna_%28test_image%29.png").openStream();
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
ImagesResponse response = client.images().edit(
ImageEditParams.builder()
.model("gpt-image-1")
.prompt("Make the image black and white")
.image(is)
.build()
);
System.out.println(response);
}
}
- Am I using .image(InputStream) incorrectly?
- Is there a bug in the SDK?
- If I’m doing it wrong, could you share a working Java example?
Thanks in advance for any guidance!
Metadata
Metadata
Assignees
Labels
No labels