Add tutorial for text-to-image generation using Microsoft.Extensions.AI#49391
Merged
Add tutorial for text-to-image generation using Microsoft.Extensions.AI#49391
Conversation
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add tutorial for AI text-to-image feature in .NET
Add tutorial for text-to-image generation using Microsoft.Extensions.AI
Oct 21, 2025
gewarren
approved these changes
Oct 22, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds a comprehensive quickstart tutorial demonstrating how to generate images from text prompts using the Microsoft.Extensions.AI library's experimental IImageGenerator interface. The tutorial provides step-by-step instructions with working code examples for Azure OpenAI integration, covering basic image generation, configuration options, error handling, and best practices.
Key changes:
- Adds new quickstart tutorial
text-to-image.mdwith complete Azure OpenAI implementation - Reorganizes TOC structure with new "Text to image" section and expanded quickstarts
- Includes working C# code example with proper error handling and configuration management
- Updates existing generate-images.md title to clarify it uses DALLe directly
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/ai/toc.yml | Restructures navigation with expanded quickstarts section and new "Text to image" category containing both MEAI and DALLe tutorials |
| docs/ai/quickstarts/text-to-image.md | Adds new comprehensive tutorial covering IImageGenerator usage with Azure OpenAI, including setup, code examples, options, error handling, and best practices |
| docs/ai/quickstarts/snippets/text-to-image/azure-openai/TextToImageAzureOpenAI.csproj | Adds project file with required package references for the text-to-image quickstart sample |
| docs/ai/quickstarts/snippets/text-to-image/azure-openai/Program.cs | Implements complete working example demonstrating basic generation, configuration options, and error handling patterns |
| docs/ai/quickstarts/generate-images.md | Updates title to clarify distinction from MEAI tutorial by specifying it uses DALLe |
ericstj
reviewed
Oct 23, 2025
ericstj
reviewed
Oct 23, 2025
docs/ai/quickstarts/snippets/text-to-image/azure-openai/Program.cs
Outdated
Show resolved
Hide resolved
ericstj
reviewed
Oct 23, 2025
docs/ai/quickstarts/snippets/text-to-image/azure-openai/Program.cs
Outdated
Show resolved
Hide resolved
ericstj
reviewed
Oct 23, 2025
docs/ai/quickstarts/snippets/text-to-image/azure-openai/Program.cs
Outdated
Show resolved
Hide resolved
ericstj
reviewed
Oct 23, 2025
ericstj
reviewed
Oct 23, 2025
ericstj
reviewed
Oct 23, 2025
Member
|
@gewarren - gave first pass of feedback. Let me know what you think based on desired scope of this initial PR. |
This was referenced Oct 24, 2025
meaghanlewis
approved these changes
Oct 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a comprehensive tutorial that demonstrates how to use the
Microsoft.Extensions.AIlibrary to generate images from text prompts using theIImageGeneratorinterface.Overview
The tutorial covers the complete workflow for integrating text-to-image capabilities into .NET applications, with support for both OpenAI and Azure OpenAI providers.
What's included
Documentation
docs/ai/tutorials/text-to-image.md) that covers:IImageGeneratorinterface and its capabilitiesCode Examples
DefaultAzureCredentialImageGenerationOptionsImageGeneratorBuilderFeatures
MEAI001)Technical Details
The tutorial demonstrates the experimental
IImageGeneratorinterface from theMicrosoft.Extensions.AIlibrary, showing how to:ImageClienttoIImageGeneratorusing theAsIImageGenerator()extension methodSystem.Drawing.Sizefor dimensionsImageGenerationResponseFormatfor controlling output formatImageGenerationResponse.ContentscollectionUriContentto retrieve image URLsFixes #486214
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/jeremylikness/text2imagesample/contentscurl -s REDACTED(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Fixes #48169
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Internal previews