Repository navigation
feat(azure_ai): add Mistral Document AI OCR 4 and Mistral Medium 3.5 in Foundry - #32645
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
🤖 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:
|
|
|
Greptile SummaryThis PR adds two new Mistral models available in Microsoft Azure AI Foundry to litellm's cost map:
Confidence Score: 4/5Safe to merge; changes are limited to catalog metadata and a new test file with no production code modifications. The catalog additions look correct and consistent with existing patterns. The only noteworthy item is in the test: cost_per_token is called with model='mistral-medium-3-5' (no provider prefix), while the fixture patches litellm.model_cost keyed on 'azure_ai/mistral-medium-3-5'. If the underlying lookup doesn't prepend the provider prefix, the test could silently use the remote cost map instead of the local fixture — making it a less reliable guard. Everything else (JSON structure, backup parity, OCR cost scaling test) is clean. tests/test_litellm/llms/azure_ai/test_azure_ai_mistral_foundry_metadata.py — specifically the test_azure_ai_mistral_medium_3_5_cost_per_token test and whether its model-key lookup resolves against the patched local cost map.
|
| Filename | Overview |
|---|---|
| model_prices_and_context_window.json | Adds azure_ai/mistral-ocr-4-0 and azure_ai/mistral-medium-3-5 catalog entries; structure and values are consistent with existing azure_ai model entries |
| litellm/model_prices_and_context_window_backup.json | Mirror of the root JSON changes — same two new entries added in the same locations; identical to the root file's additions |
| tests/test_litellm/llms/azure_ai/test_azure_ai_mistral_foundry_metadata.py | New test file covering model_info fields and cost math for both new models; fixture correctly uses module-scoped MonkeyPatch and clears caches; cost_per_token test is not tied to the local cost-map fixture, which could be brittle depending on test environment |
Reviews (1): Last reviewed commit: "feat(azure_ai): add Mistral Document AI ..." | Re-trigger Greptile
| def test_azure_ai_mistral_medium_3_5_cost_per_token(use_local_model_cost_map): | ||
| from litellm.llms.azure_ai.cost_calculator import cost_per_token | ||
| from litellm.types.utils import Usage | ||
|
|
||
| usage = Usage( | ||
| prompt_tokens=1_000_000, | ||
| completion_tokens=1_000_000, | ||
| total_tokens=2_000_000, | ||
| ) | ||
|
|
||
| prompt_cost, completion_cost = cost_per_token(model="mistral-medium-3-5", usage=usage) | ||
|
|
||
| assert prompt_cost == pytest.approx(1.5) | ||
| assert completion_cost == pytest.approx(7.5) |
There was a problem hiding this comment.
cost_per_token lookup bypasses the local cost-map fixture
cost_per_token internally calls generic_cost_per_token with custom_llm_provider="azure_ai", which uses litellm.model_cost for the lookup. That global is patched by the fixture, so the lookup should resolve correctly — but the test passes model="mistral-medium-3-5" (without the provider prefix). If generic_cost_per_token doesn't prepend azure_ai/ before looking up in model_cost, the test may silently fall through to the remote cost map fetch, bypassing the local fixture. The sibling test_azure_ai_mistral_medium_3_5_model_info calls get_model_info(model="azure_ai/mistral-medium-3-5") (with prefix) and is unambiguous; aligning the cost_per_token test to the same model-key style would remove the ambiguity.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Hi, any plans to merge this? I use Mistral OCR 4 via Azure and cost calculation is missing for it in LiteLLM |
|
Superseded by rolling registry audit #37902, which reverified and absorbed the provider-documented metadata changes at field level |
Relevant issues
Fixes #32637
Linear ticket
Pre-Submission checklist
Screenshots / Proof of Fix
I don't have an Azure Foundry deployment for these two serverless models, so I can't make a real billed Azure call. The closest end-user-visible proof is a running proxy resolving the new catalog entries (pricing, context window, capabilities) via
/v1/model/info. A maintainer with a Foundry deployment can pointapi_base/api_keyat it and run a real/v1/ocrand/chat/completionscallConfig (
proof_config.yaml) with the two new models pointed at a placeholder Foundry endpoint, then:Output at commit
ce10c7627d:No
register_model: ... not in built-in cost mapwarning is emitted for either model on proxy startup, confirming both resolve against the cost mapType
🆕 New Feature
Changes
Adds the two Mistral models that arrived in Microsoft Foundry (per the Foundry announcement) to the cost map (
model_prices_and_context_window.jsonand the bundled backup)azure_ai/mistral-ocr-4-0is Mistral Document AI with OCR 4, priced at the Foundry Global Standard rate of $4 / 1K pages OCR only and $5 / 1K pages with annotations, soocr_cost_per_page0.004 andannotation_cost_per_page0.005. It reuses the existingAzureAIOCRConfigtransformation (which is model-name agnostic and already posts to/providers/mistral/azure/ocr), so no code change is needed beyond the catalog entryazure_ai/mistral-medium-3-5is the 128B, 256K-context Medium 3.5 chat model at the Foundry Global Standard rate of $1.5 / 1M input and $7.5 / 1M output, mirroring the capabilities already recorded for the nativemistral/mistral-medium-3-5entry (vision, reasoning, function calling, response schema, tool choice, assistant prefill)Adds
tests/test_litellm/llms/azure_ai/test_azure_ai_mistral_foundry_metadata.pycovering the metadata/pricing of both entries plusazure_aicost-per-token and per-page OCR cost calculationLink to Devin session: https://app.devin.ai/sessions/ec981255e71c4fe8b4d6a27f7afa6f8d