Build a Star Wars Copilot in C# - Lesson 7: Multimodal Image Generation

Jim Bennett | Mar 17, 2026

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

Lesson
Lesson 0: Self-Setup
Lesson 1: Chat with an LLM
Lesson 2: Chat History and System Prompts
Lesson 3: Model Choice and Local Models
Lesson 4: Tool Calling
Lesson 5: MCP (Model Context Protocol)
Lesson 6: RAG from a Database
Lesson 7: Multimodal Image Generation
Lesson 8: Agents and Orchestration

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

  1. In Azure OpenAI, create a deployment for a GPT image model (for example gpt-image-1 or gpt-image-1.5).
  2. Copy the endpoint, API key, and deployment name.
  3. 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-1 series)
  • 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:

  1. user asks for image
  2. tool call fails with policy violation
  3. tool returns remediation guidance
  4. 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.