-
Notifications
You must be signed in to change notification settings - Fork 6k
Add tutorial for text-to-image generation using Microsoft.Extensions.AI #49391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
docs/ai/quickstarts/snippets/text-to-image/azure-openai/Program.cs
Outdated
Show resolved
Hide resolved
docs/ai/quickstarts/snippets/text-to-image/azure-openai/Program.cs
Outdated
Show resolved
Hide resolved
docs/ai/quickstarts/snippets/text-to-image/azure-openai/Program.cs
Outdated
Show resolved
Hide resolved
|
@gewarren - gave first pass of feedback. Let me know what you think based on desired scope of this initial PR. |
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