Lesson 7 brings multimodal capabilities into the stack.
Instead of only generating text, the copilot can now generate images via an MCP tool.
Lessons in this series
Before you start (self-setup)
If you’re following along on your own, complete lesson 0 and lesson 6 first.
This lesson adds a dedicated Azure OpenAI image deployment.
Self-setup: deploy a GPT image model
- In Azure OpenAI, create a deployment for a GPT image model (for example
gpt-image-1orgpt-image-1.5). - Copy the endpoint, API key, and deployment name.
- Save them in the MCP server project:
dotnet user-secrets set "ImageGeneration:Endpoint" "https://<your-resource>.openai.azure.com/"
dotnet user-secrets set "ImageGeneration:APIKey" "<your-api-key>"
dotnet user-secrets set "ImageGeneration:ModelName" "<your-image-deployment-name>"
Tip: image generation can be expensive. Set a budget and test with a small number of prompts first.
Also worth noting: dall-e-3 has been retired in Azure OpenAI. Use gpt-image-1 or gpt-image-1.5 for new deployments.
The new tool
The workshop adds GenerateStarWarsImageTool to the MCP server.
It:
- accepts a text description
- calls Azure OpenAI image generation with a GPT image deployment (
gpt-image-1series) - returns an image URL as JSON
Simple contract, high utility.
Prompt engineering for image safety
A really useful part of this lesson is how it handles content policy issues.
The first pass prompt nudges toward:
- cartoon/parody style
- no direct copyrighted character reproduction
Then, if policy violations happen, the tool returns actionable retry guidance rather than a dead-end error.
That guidance tells the model to:
- replace named characters with descriptive traits
- tone down disallowed content
This is a great pattern for resilient AI systems: tools can teach the orchestrating model how to recover.
Tightening the copilot behavior
The system prompt is updated so if a tool asks for a retry, the assistant follows that instruction and retries.
This creates a self-healing loop:
- user asks for image
- tool call fails with policy violation
- tool returns remediation guidance
- assistant rewrites prompt and retries
That is much better UX than “sorry, failed”.
Suggested banner prompt
A vibrant cinematic artwork of an AI assistant projecting generated concept art panels in a starship studio, with one panel being refined into a safer descriptive prompt workflow. Retro space-opera vibe, rich colors, high detail, no text, no logos.
Follow along
Workshop source for this lesson: Lesson 7 README.
Next up: building agents and a multi-agent story + image workflow.
Note: Original workshop repository: jimbobbennett/StarWarsCopilot.
