Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

feat(mistral): add mistral/mistral-ocr-2512 (OCR 3) to cost map (#31463)

Mateo Wang5a1c7839be05
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 5cf5af8a22a..6a65977e909 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -25610,6 +25610,16 @@
],
"source": "https://mistral.ai/pricing#api-pricing"
},
+ "mistral/mistral-ocr-2512": {
+ "litellm_provider": "mistral",
+ "ocr_cost_per_page": 0.002,
+ "annotation_cost_per_page": 0.003,
+ "mode": "ocr",
+ "supported_endpoints": [
+ "/v1/ocr"
+ ],
+ "source": "https://mistral.ai/pricing#api-pricing"
+ },
"mistral/magistral-medium-latest": {
"input_cost_per_token": 2e-06,
"litellm_provider": "mistral",
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index ed1b2fb7db9..d5af7391439 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -25774,6 +25774,16 @@
],
"source": "https://mistral.ai/pricing#api-pricing"
},
+ "mistral/mistral-ocr-2512": {
+ "litellm_provider": "mistral",
+ "ocr_cost_per_page": 0.002,
+ "annotation_cost_per_page": 0.003,
+ "mode": "ocr",
+ "supported_endpoints": [
+ "/v1/ocr"
+ ],
+ "source": "https://mistral.ai/pricing#api-pricing"
+ },
"mistral/magistral-medium-latest": {
"input_cost_per_token": 2e-06,
"litellm_provider": "mistral",
diff --git a/tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_cost.py b/tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_cost.py
index b98b0c22e50..c7f959826fe 100644
--- a/tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_cost.py
+++ b/tests/test_litellm/llms/mistral/ocr/test_mistral_ocr_cost.py
@@ -5,6 +5,9 @@ for mistral-ocr-4-0 and mistral-ocr-latest, which now both resolve to
OCR 4 at $4 / 1000 pages.
"""
+import json
+from pathlib import Path
+
import pytest
import litellm
@@ -13,6 +16,14 @@ from litellm.llms.base_llm.ocr.transformation import OCRPage, OCRResponse, OCRUs
OCR4_COST_PER_PAGE = 0.004
+REPO_ROOT = Path(__file__).parents[5]
+MAIN_COST_MAP = REPO_ROOT / "model_prices_and_context_window.json"
+BACKUP_COST_MAP = REPO_ROOT / "litellm" / "model_prices_and_context_window_backup.json"
+
+OCR3_MODEL = "mistral/mistral-ocr-2512"
+OCR3_COST_PER_PAGE = 0.002
+OCR3_ANNOTATION_COST_PER_PAGE = 0.003
+
def _ocr_response(model: str, pages_processed: int) -> OCRResponse:
return OCRResponse(
@@ -38,3 +49,43 @@ def test_ocr4_cost_scales_with_pages(model: str, pages_processed: int) -> None:
call_type="ocr",
)
assert cost == pytest.approx(OCR4_COST_PER_PAGE * pages_processed)
+
+
+def local_model_cost_map(monkeypatch):
+ """Force get_model_info to resolve against the in-repo cost map instead of the
+ remote one fetched at import time, which does not yet carry OCR 3 pricing."""
+ monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")
+ monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))
+ litellm.get_model_info.cache_clear()
+ yield
+ litellm.get_model_info.cache_clear()
+
+
[email protected]("cost_map_path", [MAIN_COST_MAP, BACKUP_COST_MAP])
+def test_ocr3_pricing_entry(cost_map_path: Path) -> None:
+ with open(cost_map_path) as f:
+ info = json.load(f).get(OCR3_MODEL)
+
+ assert info is not None, f"{OCR3_MODEL} missing from {cost_map_path.name}"
+ assert info["litellm_provider"] == "mistral"
+ assert info["mode"] == "ocr"
+ assert info["supported_endpoints"] == ["/v1/ocr"]
+ assert info["ocr_cost_per_page"] == OCR3_COST_PER_PAGE
+ assert info["annotation_cost_per_page"] == OCR3_ANNOTATION_COST_PER_PAGE
+
+
+def test_ocr3_model_info_price(local_model_cost_map) -> None:
+ info = litellm.get_model_info(model=OCR3_MODEL, custom_llm_provider="mistral")
+ assert info["ocr_cost_per_page"] == OCR3_COST_PER_PAGE
+
+
[email protected]("pages_processed", [1, 3, 10])
+def test_ocr3_cost_scales_with_pages(local_model_cost_map, pages_processed: int) -> None:
+ cost = completion_cost(
+ completion_response=_ocr_response("mistral-ocr-2512", pages_processed),
+ model=OCR3_MODEL,
+ custom_llm_provider="mistral",
+ call_type="ocr",
+ )
+ assert cost == pytest.approx(OCR3_COST_PER_PAGE * pages_processed)