Skip to content

feat(azure_ai): add Mistral Document AI OCR 4 and Mistral Medium 3.5 in Foundry - #32645

Closed
devin-ai-integration[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_azure_mistral_ocr4_medium35
Closed

devin-ai-integration[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_azure_mistral_ocr4_medium35

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes #32637

Linear ticket

Pre-Submission checklist

  • 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

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 point api_base/api_key at it and run a real /v1/ocr and /chat/completions call

Config (proof_config.yaml) with the two new models pointed at a placeholder Foundry endpoint, then:

LITELLM_LOCAL_MODEL_COST_MAP=True litellm --config proof_config.yaml --port 4000

curl -s http://localhost:4000/v1/model/info -H "Authorization: Bearer sk-1234"

Output at commit ce10c7627d:

{
  "model_name": "mistral-ocr-4-0-azure",
  "litellm_model": "azure_ai/mistral-ocr-4-0",
  "mode": "ocr",
  "ocr_cost_per_page": 0.004,
  "annotation_cost_per_page": 0.005
}
{
  "model_name": "mistral-medium-3-5-azure",
  "litellm_model": "azure_ai/mistral-medium-3-5",
  "mode": "chat",
  "input_cost_per_token": 1.5e-06,
  "output_cost_per_token": 7.5e-06,
  "max_input_tokens": 262144,
  "supports_vision": true,
  "supports_reasoning": true
}

No register_model: ... not in built-in cost map warning is emitted for either model on proxy startup, confirming both resolve against the cost map

Type

🆕 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.json and the bundled backup)

azure_ai/mistral-ocr-4-0 is 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, so ocr_cost_per_page 0.004 and annotation_cost_per_page 0.005. It reuses the existing AzureAIOCRConfig transformation (which is model-name agnostic and already posts to /providers/mistral/azure/ocr), so no code change is needed beyond the catalog entry

azure_ai/mistral-medium-3-5 is 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 native mistral/mistral-medium-3-5 entry (vision, reasoning, function calling, response schema, tool choice, assistant prefill)

Adds tests/test_litellm/llms/azure_ai/test_azure_ai_mistral_foundry_metadata.py covering the metadata/pricing of both entries plus azure_ai cost-per-token and per-page OCR cost calculation

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

@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

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds two new Mistral models available in Microsoft Azure AI Foundry to litellm's cost map: azure_ai/mistral-ocr-4-0 (Mistral Document AI with OCR 4, priced at $0.004/page OCR-only and $0.005/page with annotations) and azure_ai/mistral-medium-3-5 (128B chat model with 256K context at $1.5/M input and $7.5/M output tokens). No production code changes are required since both models reuse existing provider transformations.

  • Both JSON entries are structurally consistent with neighbouring azure_ai entries; mistral-medium-3-5 correctly mirrors the capabilities already recorded for mistral/mistral-medium-3-5 (vision, reasoning, function calling, response schema, tool choice, assistant prefill).
  • The identical changes are applied to both model_prices_and_context_window.json and the bundled backup, and are accompanied by a new all-mock test file that validates model_info fields and per-page/per-token cost arithmetic.

Confidence Score: 4/5

Safe 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.

Important Files Changed

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

Comment on lines +56 to +69
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_azure_mistral_ocr4_medium35 (ce10c76) with litellm_internal_staging (60729f7)

Open in CodSpeed

@4refael

4refael commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Hi, any plans to merge this? I use Mistral OCR 4 via Azure and cost calculation is missing for it in LiteLLM

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Superseded by rolling registry audit #37902, which reverified and absorbed the provider-documented metadata changes at field level

@devin-ai-integration
devin-ai-integration Bot deleted the litellm_azure_mistral_ocr4_medium35 branch September 10, 2026 03:41
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.

[Feature]: Add Support for Mistral Document AI OCR and Mistral 3.5 Medium in Azure

2 participants