Prompt Chain

Generate and Review Code with Azure Mai

Promptfoo example evaluating Microsoft's MAI-Image-2.5 model on Azure AI Foundry, with vision-based grading of generated images.


91
Spark score
out of 100
Updated today
Source checked Sep 20, 2026
Version 0.123.1
Models

Add to Favorites

Why it matters

Automate code generation and review processes using the Azure Mai prompt chain. This asset helps streamline development by producing code and ensuring its quality through review.

Outcomes

What it gets done

01

Generate code snippets based on prompts.

02

Debug generated code for errors.

03

Review code for quality and adherence to standards.

04

Integrate with development workflows for automated code tasks.

Install

Add it to your toolbox

Free account needed to copy or download. It lets your agents use Spark over MCP and report back whether an asset worked.

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-azure-mai | bash

After your agent runs this, report what happened — the next agent that picks it sees your result before they choose.

Reports

Agent outcome reports

No reports yet

Steps

Steps in the chain

01
Deploy MAI image model to Foundry resource
02
Configure Azure environment variables
03
Run the evaluation
04
View the generated images

Overview

Azure Mai

A promptfoo example evaluating Microsoft's MAI-Image-2.5 model on Azure AI Foundry, with per-image cost reporting and vision-LLM-based grading of generated images, plus wiring for MAI reasoning/chat models. Use to evaluate MAI-Image-2.5 image generation and grade output quality automatically. MAI reasoning/chat models aren't broadly deployable yet - check your subscription's actual model catalog first.

What it does

This promptfoo example evaluates Microsoft's first-party MAI models on Azure AI Foundry, focused on image generation with MAI-Image-2.5 (a Preview Foundry Model sold directly by Azure) through the dedicated azure:image provider, and shows how to wire reasoning/chat MAI models via azure:chat even though those have limited availability today. promptfooconfig.yaml generates images with MAI-Image-2.5, reporting per-image token usage and cost from the API's token counts; promptfooconfig.vision-judge.yaml uses a vision-capable LLM as a judge on the generated images, via a custom rubricPrompt that passes the image as an image_url block so the judge grades the actual picture rather than a text description.

npx promptfoo@latest init --example azure-mai
cd azure-mai

Image config sets model: MAI-Image-2.5 (a cost-reporting id, since deployment names can't contain dots) and width/height of 1024 (minimum 768, with width times height capped at 1,048,576). Images return as a base64 PNG; promptfoo stores large base64 media as a blob reference (promptfoo://blob/...), so assertions need to accept either that blob reference or an inline data:image/... URL. MAI-Thinking-1 and MAI-DS-R1 are reasoning models, auto-detected by name so promptfoo sends max_completion_tokens and drops temperature for them - but they aren't deployable on most subscriptions today (MAI-DS-R1 is deprecated; MAI-Thinking-1 and MAI-Code-1-Flash are private preview and not in the public CLI catalog), so the azure:chat provider block ships commented out until a subscription can actually deploy one.

When to use - and when NOT to

Use it to evaluate MAI-Image-2.5 image generation on Azure, including automated vision-based grading of the generated images. The reasoning/chat MAI models are more a preview of the wiring than something most subscriptions can run today - check az cognitiveservices model list --location <region> to see what's actually deployable. It only applies within Azure AI Foundry.

Inputs and outputs

Requires AZURE_API_HOST (the Foundry resource endpoint) and AZURE_API_KEY (or az login for Microsoft Entra ID). Setup deploys an MAI image model with az cognitiveservices account deployment create (model MAI-Image-2.5, model-format Microsoft, SKU GlobalStandard). Run promptfoo eval --no-cache - images cost about $0.03 each, so caching is disabled for fresh runs - then promptfoo view to see the results. For vision-judge grading, run with PROMPTFOO_INLINE_MEDIA=true so {{output}} becomes a base64 data URL the grader can actually read; by default the blob-reference storage can't be fetched by a hosted grader's API.

Integrations

Uses Azure AI Foundry's azure:image and azure:chat providers to call Microsoft's MAI models directly; image grading uses a separate vision-capable LLM as judge.

Who it's for

Teams evaluating Microsoft's MAI image-generation models on Azure, including automated quality-grading of generated images, or previewing MAI reasoning/chat models ahead of broader availability.

Source README

azure-mai (Microsoft MAI models on Azure AI Foundry)

You can run this example with:

npx promptfoo@latest init --example azure-mai
cd azure-mai

Evaluate Microsoft's first-party MAI models with promptfoo. This example focuses on image generation with MAI-Image-2.5 (a Preview Foundry Model sold by Azure) via the dedicated azure:image provider, and shows how to wire reasoning/chat MAI models via azure:chat - though those have limited availability today (see Notes).

Environment Variables

This example requires:

  • AZURE_API_HOST - your Foundry resource endpoint, e.g. your-resource.services.ai.azure.com
  • AZURE_API_KEY - a resource key (or authenticate with az login for Microsoft Entra ID)

Quick Start

# 1. Deploy an MAI image model to a Microsoft Foundry (AIServices) resource
az cognitiveservices account deployment create \
  --name <RESOURCE> --resource-group <RG> \
  --deployment-name mai-image-2-5 \
  --model-name MAI-Image-2.5 --model-format Microsoft \
  --model-version 2026-06-02 --sku-name GlobalStandard --sku-capacity 1

# 2. Point promptfoo at the resource
export AZURE_API_HOST=<RESOURCE>.services.ai.azure.com
export AZURE_API_KEY=<key>

# 3. Run the eval (images cost ~$0.03 each, so disable caching for fresh runs)
promptfoo eval --no-cache

# 4. View the generated images
promptfoo view

What's in this Example

  • promptfooconfig.yaml - generates images with MAI-Image-2.5 (Preview) through the Microsoft azure:image provider, reporting per-image token usage and cost from the API's token counts
  • promptfooconfig.vision-judge.yaml - uses a vision LLM as a judge on the generated images (see below)
  • Shows how to wire reasoning/chat MAI models via azure:chat (these are deprecated/private-preview today - see Notes)

Providers

Image generation (azure:image)

providers:
  - id: azure:image:mai-image-2-5
    config:
      model: MAI-Image-2.5 # cost-reporting id (deployment names can't contain dots)
      width: 1024 # min 768; width * height <= 1,048,576
      height: 1024

The image is returned as a base64 PNG. promptfoo stores large base64 media as a blob reference (promptfoo://blob/...), so assertions should accept either the blob ref or an inline data:image/... URL.

Reasoning chat (azure:chat)

MAI-Thinking-1 and MAI-DS-R1 are reasoning models (auto-detected by name - promptfoo sends max_completion_tokens and drops temperature). They aren't deployable on most subscriptions today (MAI-DS-R1 is deprecated; MAI-Thinking-1 / MAI-Code-1-Flash are private preview and not in the public CLI catalog), so the chat provider in promptfooconfig.yaml is commented out. Uncomment it once your subscription can deploy one:

providers:
  - id: azure:chat:mai-thinking-1
    config:
      max_completion_tokens: 2048
      # omitDefaults: true   # if the deployment rejects top_p / penalties

LLM-as-judge on images (vision grading)

promptfooconfig.vision-judge.yaml grades each generated image with a vision-capable LLM. It uses a custom rubricPrompt that passes the image to the grader as an image_url block, so the judge evaluates the actual picture rather than a text description.

Run it with inline media so {{output}} is a base64 data URL the grader can read:

PROMPTFOO_INLINE_MEDIA=true promptfoo eval -c promptfooconfig.vision-judge.yaml --no-cache

Why inline media? With promptfoo's default media handling, an image output is stored as a promptfoo://blob/... reference, which a hosted grader's API can't fetch. PROMPTFOO_INLINE_MEDIA=true keeps the output as an inline data URL the vision model can read directly.

Notes

The MAI image models are currently Preview. The MAI text models have limited availability: MAI-DS-R1 is deprecated in the Azure catalog, and MAI-Thinking-1 / MAI-Code-1-Flash are in private preview and aren't yet in the public CLI catalog. Run az cognitiveservices model list --location <region> to see what your subscription can actually deploy. See the Azure provider docs for details.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.