Merge pull request #34556 from BerriAI/litellm_azure_claude_1m_context

fix(azure_ai): advertise 1M context window for Claude Opus 4.6+ on Foundry
This commit is contained in:
Mateo Wang 2026-07-25 18:32:28 -07:00 committed by GitHub
commit b439a9a788
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 47 additions and 9 deletions

View file

@ -2887,7 +2887,7 @@
"input_cost_per_token": 5e-06,
"output_cost_per_token": 2.5e-05,
"litellm_provider": "azure_ai",
"max_input_tokens": 200000,
"max_input_tokens": 1000000,
"max_output_tokens": 128000,
"max_tokens": 128000,
"mode": "chat",
@ -2916,7 +2916,7 @@
"input_cost_per_token": 5e-06,
"output_cost_per_token": 2.5e-05,
"litellm_provider": "azure_ai",
"max_input_tokens": 200000,
"max_input_tokens": 1000000,
"max_output_tokens": 128000,
"max_tokens": 128000,
"mode": "chat",
@ -3010,7 +3010,7 @@
"input_cost_per_token": 5e-06,
"output_cost_per_token": 2.5e-05,
"litellm_provider": "azure_ai",
"max_input_tokens": 200000,
"max_input_tokens": 1000000,
"max_output_tokens": 128000,
"max_tokens": 128000,
"mode": "chat",

View file

@ -2887,7 +2887,7 @@
"input_cost_per_token": 5e-06,
"output_cost_per_token": 2.5e-05,
"litellm_provider": "azure_ai",
"max_input_tokens": 200000,
"max_input_tokens": 1000000,
"max_output_tokens": 128000,
"max_tokens": 128000,
"mode": "chat",
@ -2916,7 +2916,7 @@
"input_cost_per_token": 5e-06,
"output_cost_per_token": 2.5e-05,
"litellm_provider": "azure_ai",
"max_input_tokens": 200000,
"max_input_tokens": 1000000,
"max_output_tokens": 128000,
"max_tokens": 128000,
"mode": "chat",
@ -3010,7 +3010,7 @@
"input_cost_per_token": 5e-06,
"output_cost_per_token": 2.5e-05,
"litellm_provider": "azure_ai",
"max_input_tokens": 200000,
"max_input_tokens": 1000000,
"max_output_tokens": 128000,
"max_tokens": 128000,
"mode": "chat",

View file

@ -4,6 +4,7 @@ count actual model entries, not reserved meta keys) and the extraction of the
``fallback_generalizations`` block out of the raw map.
"""
import json
import os
import sys
@ -25,6 +26,14 @@ from litellm.litellm_core_utils.get_model_cost_map import (
)
def _load_root_cost_map() -> dict:
path = os.path.join(
os.path.dirname(__file__), "../../../model_prices_and_context_window.json"
)
with open(path) as f:
return json.load(f)
def _make_models(n: int) -> dict:
return {
f"model-{i}": {"litellm_provider": "openai", "mode": "chat"} for i in range(n)
@ -209,3 +218,33 @@ def test_shipped_backup_marks_claude_4_6_plus_adaptive_not_4_0():
"claude-opus-4-5",
]:
assert "supports_adaptive_thinking" not in backup[non_adaptive], non_adaptive
@pytest.mark.parametrize(
"cost_map",
[_load_root_cost_map(), GetModelCostMap.load_local_model_cost_map()],
ids=["root", "bundled_backup"],
)
def test_azure_ai_claude_1m_context_entries(cost_map: dict):
"""Microsoft Foundry serves a 1M-token context window for Opus 4.6+ and Sonnet
4.6+, so the ``azure_ai`` entries must not advertise the 200k cap that made
context-aware clients compact prompts early (LIT-4406). Both the root map (used
by default network loading) and the bundled fallback are checked so the two can
never drift apart."""
for model in [
"azure_ai/claude-opus-4-6",
"azure_ai/claude-opus-4-7",
"azure_ai/claude-opus-4-8",
"azure_ai/claude-opus-5",
"azure_ai/claude-sonnet-5",
"azure_ai/claude-sonnet-4-6",
]:
assert cost_map[model]["max_input_tokens"] == 1000000, model
for model in [
"azure_ai/claude-opus-4-1",
"azure_ai/claude-opus-4-5",
"azure_ai/claude-sonnet-4-5",
"azure_ai/claude-haiku-4-5",
]:
assert cost_map[model]["max_input_tokens"] == 200000, model

View file

@ -102,7 +102,7 @@ def test_opus_4_6_model_pricing_and_capabilities():
"azure_ai/claude-opus-4-6": {
"provider": "azure_ai",
"has_long_context_pricing": False,
"max_input_tokens": 200000,
"max_input_tokens": 1000000,
},
}

View file

@ -60,10 +60,9 @@ def test_opus_4_8_model_pricing_and_capabilities():
"provider": "vertex_ai-anthropic_models",
"max_input_tokens": 1000000,
},
# Microsoft Foundry / Azure caps Opus 4.8 at a 200k context window.
"azure_ai/claude-opus-4-8": {
"provider": "azure_ai",
"max_input_tokens": 200000,
"max_input_tokens": 1000000,
},
}