feat(azure_ai): add MAI-Image-2.5-Pro image generation pricing - #34941
Open
devin-ai-integration[bot] wants to merge 4 commits into
Open
feat(azure_ai): add MAI-Image-2.5-Pro image generation pricing#34941devin-ai-integration[bot] wants to merge 4 commits into
devin-ai-integration[bot] wants to merge 4 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
Greptile SummaryAdds MAI-Image-2.5-Pro pricing metadata and preserves detailed image usage during cost calculation
Confidence Score: 5/5The PR appears safe to merge No blocking failure remains
|
| 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
…itellm_azure_ai_mai_image_2_5_pro
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).
Contributor
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Problem this solves:
azure_ai/MAI-Image-2.5-Prowas missing from the cost mapHow it solves it:
completion_costflatteningImageUsageand losing the input splitRelevant issues
Linear ticket
Resolves LIT-4881
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito 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-ProGlobalStandard 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 withmai-image-2.5-prorouted toazure_ai/MAI-Image-2.5-Pro, costing real $Generation:
Edit (exercises image input tokens):
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 runx-litellm-response-costgenerationx-litellm-response-costedit4e68cbd1ea1d9090c3eeExpected 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-spendmatches)Type
🆕 New Feature
🐛 Bug Fix
Changes
Adds
azure_ai/MAI-Image-2.5-Protomodel_prices_and_context_window.jsonand 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 usesinput_cost_per_token: 5e-06andoutput_cost_per_image_token: 0.000106rather than mirroring the $47/M output rate of the base 2.5 tier as the first version of this PR did. Image input is8e-06, matching the base tier and corroborated by third party trackers since the announcement only lists text input and image output. The per-image fallbackoutput_cost_per_image: 0.1085is 1024 output tokens (what the API reports for a 1024x1024 image) at the Pro output rateLive testing the
/v1/images/editspath surfaced a second bug:completion_costreplaced any usage object it did not recognize with a chatUsagebuilt frommodel_dump(), andImageUsagewas not recognized. That droppedinput_tokens_details, so image input tokens fell through toinput_cost_per_tokenand every MAI edit under-billed image input at $5/M instead of $8/M._is_known_usage_objectsnow recognizesImageUsage, 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 ratesNo transformation changes were needed:
AzureFoundryMAIImageGenerationConfig.is_mai_modelalready matches any name containingmaiimage, soMAI-Image-2.5-Proroutes through the MAI config unchangedFinal Attestation
Link to Devin session: https://app.devin.ai/sessions/45df637e36e1422bb3f39c1ec146bd0a