Skip to content

Conversation

@ericstj
Copy link
Member

@ericstj ericstj commented Aug 12, 2025

Backport Add support for text-to-image (#6648)

Experimental only API to include in 9.8 release.

* Add ITextToImageClient

* Remove URI based edit since it's not available

* Add filename for edit

* Add OpenAI implmentation of ITextToImageClient

* Fix tests

* Add tests for TextToImage

* Add DeletgatingTextToImageClient and tests

* Add integration test and fix some bugs

* Add remaining support to MEAI for TextToImage

* Make all TextToImageOptions optional

These are all nullable now so that the client can use defaults where
appropriate.

Remove quality default since it's not consistent across models.

Also remove setting ResponseFormat since this is not supported by
gpt-image-1.

* Address feedback

* Document some exceptions

* Address feedback

* Make EditImageAsync plural

OpenAI's image API supports multiple images and this does seem to be
common functionality and a better generalization.  The client library
doesn't expose this yet, but we should account for it.

Image models may be capable of things like
"Combine the subjects of these images into a single image" or
"Create a single image that uses the subject from the first image and
background for the second" etc.

* Address feedback and add/fix tests.

* Fix bad merge

* Address feedback

* Fix test

* Use DataContent.Name for filename.

* Add extensions for EditImageAsync

Extension that accepts a single DataContent and one that accepts a byte[].

I've left out streams and file paths, since these require more opinions
about how to load them.  I filed dotnet#6683 to address streams.

* Fix test

* Remove use of `_model` field.

* Rename ImageToText to Image

* Rename TextToImage directories to Image

* Rename files TextToImage -> Image

* Add new request and response type

* Make GenerateImagesAsync accept ImageRequest

* Remove EditImageAsync

* Adding GenerateStreamingImagesAsync

* Update docs

* Rename ImageClient ImageGenerator

* Fix up some text-to-image references

* Rename Image(Options|Request|Response)

* Remove `Images` from `GenerateImagesAsync`

* Remove streaming method

We don't yet have any good public support for streaming to vet this API

We can guess at how it might behave for OpenAI, but that doesn't
really give enough confidence to build the API around it.

* Address feedback

* Provide OpenAI an appropriate filename

* Remove Style from ImageGenerationOptions
@ericstj ericstj requested a review from a team as a code owner August 12, 2025 16:36
@jeffhandley jeffhandley merged commit b0080d1 into dotnet:release/9.8 Aug 12, 2025
6 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants