Skip to main content
The image generation tool in Microsoft Foundry Agent Service generates images from text prompts in conversations and multistep workflows. The agent’s Foundry model orchestrates the image generation request and returns base64-encoded output that you can save to a file. If you use a coding agent like GitHub Copilot, the Microsoft Foundry Skill can help verify model and project requirements and add image-generation tool calls to your agent workflow.

Prerequisites

  • An Azure account with an active subscription.
  • A Foundry project.
  • A basic or standard agent environment. See agent environment setup.
  • Foundry User role on the Foundry project to create and manage agent versions.
The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
  • Approval to use gpt-image-1. Apply for access to GPT Image models before you deploy the model.
  • Two model deployments in the same Foundry project:
    • A compatible Azure OpenAI model deployment for the agent (for example, gpt-5).
    • An image generation model deployment (gpt-image-1) in a supported region.

Usage support

The following table shows SDK and setup support.

Configure the image generation tool

  1. Deploy your orchestrator model (for example, gpt-5) to your Foundry project.
  2. Deploy gpt-image-1 to the same Foundry project.
  3. Confirm your region and model support for image generation. See Best practices for using tools in Microsoft Foundry Agent Service.

Code examples

Use the runtime and install command in your selected language section. The .NET SDK is currently in preview. For general SDK setup, see the quickstart.

When to use the image generation tool

Use the image generation tool when an agent needs to generate an image from a text prompt as part of a conversation or multistep workflow. Use the Azure OpenAI Image API directly for image editing, masks, or partial-image streaming.

Optional parameters

Customize image generation by specifying these optional parameters when you create the tool:
Image generation time varies based on the quality setting and prompt complexity. For time-sensitive applications, consider using quality: "low".
Use the Responses API if you want to:
  • Build conversational image experiences with GPT Image.
  • Include image generation in a multistep agent workflow.

Write effective text-to-image prompts

Effective prompts produce better images. Describe the subject, visual style, and composition you want. Use action words like “draw,” “create,” or “edit” to guide the model’s output. Content filtering can block image generation if the service detects unsafe content in your prompt. For more information, see Guardrails and controls overview.
For a thorough look at how you can tweak your text prompts to generate different kinds of images, see Image prompt engineering techniques.

Verify tool execution

Use either of these approaches to confirm that image generation ran successfully:
  • In the response payload, look for an output item with type set to image_generation_call.
  • In the Foundry portal, open tracing/debug for your run to confirm the tool call and inspect inputs and outputs.
When image generation succeeds, the response includes an image_generation_call output item with a result field containing base64-encoded image data. If you see only text output and no image_generation_call item, the request might not be routed to image generation. Review the troubleshooting section.

Troubleshooting