Skip to main content
  • The image generation tool requires the gpt-image-1 model. See the Azure OpenAI transparency note for limitations and responsible AI considerations.
  • You also need a compatible orchestrator model (gpt-4o, gpt-4o-mini, gpt-4.1, gpt-4.1-mini, gpt-4.1-nano, o3, or gpt-5 series) deployed in the same Foundry project.
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.

Usage support

The following table shows SDK and setup support.

Prerequisites

  • An Azure account with an active subscription.
  • A Foundry project.
  • A basic or standard agent environment. See agent environment setup.
  • Permissions to create and manage agent versions in the project.
  • Two model deployments in the same Foundry project:
    • A compatible Azure OpenAI model deployment for the agent (for example, gpt-4o).
    • An image generation model deployment (gpt-image-1).

Configure the image generation tool

  1. Deploy your orchestrator model (for example, gpt-4o) 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

Before you start, install the latest SDK package. The .NET SDK is currently in preview. For package installation instructions, see the quickstart.

When to use the image generation tool

The image generation tool in Agent Service offers advantages over the Azure OpenAI Image API:

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" or enabling partial_images for streaming.
Use the Responses API if you want to:
  • Build conversational image experiences with GPT Image.
  • Stream partial image results during generation for a smoother user experience.

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