Skip to content

feat(azure_ai): add MAI-Image-2.5-Pro image generation pricing - #34941

Open
devin-ai-integration[bot] wants to merge 4 commits into
litellm_internal_stagingfrom
litellm_azure_ai_mai_image_2_5_pro
Open

feat(azure_ai): add MAI-Image-2.5-Pro image generation pricing#34941
devin-ai-integration[bot] wants to merge 4 commits into
litellm_internal_stagingfrom
litellm_azure_ai_mai_image_2_5_pro

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • azure_ai/MAI-Image-2.5-Pro was missing from the cost map
  • First version of this PR mirrored the cheaper MAI-Image-2.5 rates
  • Image edits billed image input tokens at the text input rate

How it solves it:

  • Adds the entry at Microsoft's published Pro rates
  • Fixes completion_cost flattening ImageUsage and losing the input split

Relevant issues

Linear ticket

Resolves LIT-4881

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

All runs hit a real MAI-Image-2.5-Pro GlobalStandard deployment (model version 2026-06-19) created for this PR on an Azure AI Foundry resource in eastus, through a live proxy started from the branch under test with mai-image-2.5-pro routed to azure_ai/MAI-Image-2.5-Pro, costing real $

Generation:

curl -sS -D headers.txt http://localhost:36461/v1/images/generations \
  -H "Authorization: Bearer sk-..." -H "Content-Type: application/json" \
  -d '{"model": "mai-image-2.5-pro", "prompt": "a lighthouse on a rocky coast at golden hour, photorealistic", "size": "1024x1024", "n": 1}'

Edit (exercises image input tokens):

curl -sS -D headers.txt http://localhost:36461/v1/images/edits \
  -H "Authorization: Bearer sk-..." \
  -F "model=mai-image-2.5-pro" -F "prompt=make it a stormy night with lightning" -F "image=@lighthouse.png"

Both return a real image (b64_json, ~2.2 MB PNG) plus usage; generation reported {"input_tokens": 14, "input_tokens_details": {"image_tokens": 0, "text_tokens": 14}, "output_tokens": 1024} and the edit reported {"input_tokens": 1061, "input_tokens_details": {"image_tokens": 1024, "text_tokens": 37}, "output_tokens": 1024} on every run

Run Commit x-litellm-response-cost generation x-litellm-response-cost edit
Before fixes 4e68cbd1ea $0.048198 (wrong, $47/M output) $0.113849 (wrong, image input at $5/M)
After fixes 1d9090c3ee $0.108614 $0.116921

Expected math at published rates: generation 14 x $5/M + 1024 x $106/M = $0.108614, and edit 37 x $5/M + 1024 x $8/M + 1024 x $106/M = $0.116921, both matching the returned header and the spend log (x-litellm-key-spend matches)

Type

🆕 New Feature
🐛 Bug Fix

Changes

Adds azure_ai/MAI-Image-2.5-Pro to model_prices_and_context_window.json and the bundled backup. Microsoft's Pro announcement prices Pro at $5 per 1M text input tokens and $106 per 1M image output tokens, so the entry uses input_cost_per_token: 5e-06 and output_cost_per_image_token: 0.000106 rather than mirroring the $47/M output rate of the base 2.5 tier as the first version of this PR did. Image input is 8e-06, matching the base tier and corroborated by third party trackers since the announcement only lists text input and image output. The per-image fallback output_cost_per_image: 0.1085 is 1024 output tokens (what the API reports for a 1024x1024 image) at the Pro output rate

Live testing the /v1/images/edits path surfaced a second bug: completion_cost replaced any usage object it did not recognize with a chat Usage built from model_dump(), and ImageUsage was not recognized. That dropped input_tokens_details, so image input tokens fell through to input_cost_per_token and every MAI edit under-billed image input at $5/M instead of $8/M. _is_known_usage_objects now recognizes ImageUsage, which preserves the split for the image cost calculators. Covered by a regression test that fails at exactly the observed wrong live cost if the flattening comes back, plus updated cost map assertions on the corrected Pro rates

No transformation changes were needed: AzureFoundryMAIImageGenerationConfig.is_mai_model already matches any name containing maiimage, so MAI-Image-2.5-Pro routes through the MAI config unchanged

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/45df637e36e1422bb3f39c1ec146bd0a

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds MAI-Image-2.5-Pro pricing metadata and preserves detailed image usage during cost calculation

  • Registers matching Pro pricing in the canonical and backup cost maps
  • Recognizes ImageUsage so image-edit input token categories reach the image cost calculator
  • Adds pricing, model-detection, and image-edit cost regression coverage

Confidence Score: 5/5

The PR appears safe to merge

No blocking failure remains

Important Files Changed

Filename Overview
litellm/cost_calculator.py Extends recognized usage types to preserve image-specific input token details during cost calculation
model_prices_and_context_window.json Adds the canonical Azure AI MAI-Image-2.5-Pro pricing and endpoint metadata
litellm/model_prices_and_context_window_backup.json Mirrors the new MAI-Image-2.5-Pro pricing entry in the bundled backup map
tests/test_litellm/test_cost_calculator.py Adds a regression test confirming image-edit text and image input tokens receive their distinct rates
tests/test_litellm/llms/azure_ai/image_generation/test_mai_image_generation.py Extends MAI model recognition and pricing assertions for the Pro variant

Reviews (2): Last reviewed commit: "fix(cost): treat ImageUsage as a known u..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_azure_ai_mai_image_2_5_pro (1d9090c) with litellm_internal_staging (b930e2f)

Open in CodSpeed

MAI-Image-2.5-Pro image output is $106 per 1M tokens per Microsoft's Pro
announcement, not the $47 per 1M inherited from the base MAI-Image-2.5 tier.
Update output_cost_per_image_token to 0.000106, derive the per-image fallback
(1024 output tokens per 1024x1024 image) as 0.1085, and point source at the
Pro announcement blog.
completion_cost flattened ImageUsage into chat Usage before routing to the
image cost calculator, dropping input_tokens_details. Image edit calls then
billed image input tokens at input_cost_per_token instead of
input_cost_per_image_token (MAI edits under-billed at $5/M instead of $8/M).
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants