Skip to content

Jboudreau/support gpt image models#457

Open
joe-boudreau wants to merge 12 commits intoaallam:mainfrom
joe-boudreau:jboudreau/support-gpt-image-models
Open

Jboudreau/support gpt image models#457
joe-boudreau wants to merge 12 commits intoaallam:mainfrom
joe-boudreau:jboudreau/support-gpt-image-models

Conversation

@joe-boudreau
Copy link
Copy Markdown

@joe-boudreau joe-boudreau commented Jan 12, 2026

Q A
Bug fix? yes
New feature? yes
BC breaks? no

Describe your change

  • Update the ImagesApi with 4 new methods:
    • imageCreate
    • imageEdit
    • imageCreateFlow
    • imageEditFlow

These are meant to replace the imageURL and imageJson methods in this interface once the Dall-E models are deprecated and removed in May 2026. I elected to leave them in for now to make this a backwards compatible library update. A future library update ( after May 2026) should remove these methods and simplify the API.

The OpenAI Images API only supports base_64 encoded JSON images now, the external URL option will be gone once the Dall-E models are deprecated. So the new interface methods represent that future state.

What problem is this fixing?

Dall-E Deprecation

In May 2026, OpenAI will be removing the Dall-E Image models from their API:
https://platform.openai.com/docs/deprecations#2025-11-14-dall-e-model-snapshots
These models will be unavailable after that.
In addition, the image variation endpoint is only supported by dall-e-2: https://platform.openai.com/docs/api-reference/images/createVariation
So presumably it will also be removed when the models are removed.

GPT Image support

The new class of image models (gpt-image-*) aren't supported by the Image interface in this library currently because it doesn't allow NOT setting the response_format field in the request. Requests with this field are rejected by OpenAI because that field is only supported by the Dall-E models:

Caused by: io.ktor.client.plugins.ClientRequestException: Client request(POST https://api.openai.com/v1/images/generations) invalid: 400 Bad Request. Text: "{
"error": {
"message": "Unknown parameter: 'response_format'.",
"type": "invalid_request_error",
"param": "response_format",
"code": "unknown_parameter"
}
}"

So the updates to the Image interface make this an optional field so you can actually use the GPT Image models now.

https://platform.openai.com/docs/api-reference/images


internal fun FormBuilder.appendFileSource(key: String, fileSource: FileSource) {
append(key = key, filename = fileSource.name, contentType = ContentType.Application.OctetStream) {
append(key = key, filename = fileSource.name, contentType = ContentType.parse(fileSource.contentType)) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these tests were failing now because the OpenAI API doesn't support application/octet-stream as a valid content type anymore. it needs to be image/png

@joe-boudreau
Copy link
Copy Markdown
Author

@aallam can you please review this - it's ready to be merged if you agree with the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant