From ef1cde433ea7c6dd1515de06c6d0d748fae4a197 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 20 Aug 2026 18:22:14 -0700 Subject: [PATCH 1/2] fix: add moonshot/kimi-k3 to the cost map models.litellm.ai and released litellm versions read model_prices_and_context_window.json from main at runtime, so Kimi K3 is missing from the hosted catalog even though the entry is in review for litellm_internal_staging in #37552. This copies that entry onto main so the catalog picks it up on its next fetch. Data only: the cost map and its backup copy, no code changes. Pricing matches Moonshot's published rates ($3/M input, $0.30/M cache read, $15/M output, 1,048,576-token context). The fireworks_ai and Azure Foundry kimi-k3 variants are separate work in #37512 and #37658; neither touches the native moonshot/kimi-k3 key. --- .../model_prices_and_context_window_backup.json | 17 +++++++++++++++++ model_prices_and_context_window.json | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 07f9027313ba..53d069c4a71f 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -30025,6 +30025,23 @@ "supports_video_input": true, "supports_vision": true }, + "moonshot/kimi-k3": { + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "moonshot", + "max_input_tokens": 1048576, + "max_output_tokens": 1048576, + "max_tokens": 1048576, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "source": "https://platform.kimi.ai/docs/pricing/chat-k3", + "supports_function_calling": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_video_input": true, + "supports_vision": true + }, "moonshot/kimi-latest": { "cache_read_input_token_cost": 1.5e-07, "deprecation_date": "2026-01-28", diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 07f9027313ba..53d069c4a71f 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -30025,6 +30025,23 @@ "supports_video_input": true, "supports_vision": true }, + "moonshot/kimi-k3": { + "cache_read_input_token_cost": 3e-07, + "input_cost_per_token": 3e-06, + "litellm_provider": "moonshot", + "max_input_tokens": 1048576, + "max_output_tokens": 1048576, + "max_tokens": 1048576, + "mode": "chat", + "output_cost_per_token": 1.5e-05, + "source": "https://platform.kimi.ai/docs/pricing/chat-k3", + "supports_function_calling": true, + "supports_reasoning": true, + "supports_response_schema": true, + "supports_tool_choice": true, + "supports_video_input": true, + "supports_vision": true + }, "moonshot/kimi-latest": { "cache_read_input_token_cost": 1.5e-07, "deprecation_date": "2026-01-28", From ca78d549dc44043d1858e92c4d9e2541bc4610e3 Mon Sep 17 00:00:00 2001 From: Sisyphus Date: Thu, 27 Aug 2026 23:27:41 +0800 Subject: [PATCH 2/2] fix(model_prices): annotate retired xAI grok-2-era models and mark grok-4.20-multi-agent Responses-only xAI retired the grok-2 generation effective 2026-02-28 and the retired slugs now hard-fail with "Model not found - retired by xAI"; grok-beta and grok-vision-beta were retired earlier without a published date and are annotated with the same batch date. - add deprecation_date to xai/grok-2, grok-2-1212, grok-2-latest, grok-2-vision, grok-2-vision-latest, grok-beta, grok-vision-beta so they surface via GET /v1/model/deprecations - set mode=responses on xai/grok-4.20-multi-agent-0309 and xai/grok-4.20-multi-agent-beta-0309: xAI documents that the multi-agent model does not work with the Chat Completions API - pricing metadata unchanged; main and backup cost maps kept in sync Fixes #38179 --- ...odel_prices_and_context_window_backup.json | 11 ++- model_prices_and_context_window.json | 11 ++- .../test_xai_grok_model_metadata.py | 85 +++++++++++++++++++ 3 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 tests/test_litellm/test_xai_grok_model_metadata.py diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 9ca8d9e1bac3..7bd629bfc580 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -43373,6 +43373,7 @@ ] }, "xai/grok-2": { + "deprecation_date": "2026-02-28", "input_cost_per_token": 2e-06, "litellm_provider": "xai", "max_input_tokens": 131072, @@ -43385,6 +43386,7 @@ "supports_web_search": true }, "xai/grok-2-1212": { + "deprecation_date": "2026-02-28", "input_cost_per_token": 2e-06, "litellm_provider": "xai", "max_input_tokens": 131072, @@ -43397,6 +43399,7 @@ "supports_web_search": true }, "xai/grok-2-latest": { + "deprecation_date": "2026-02-28", "input_cost_per_token": 2e-06, "litellm_provider": "xai", "max_input_tokens": 131072, @@ -43409,6 +43412,7 @@ "supports_web_search": true }, "xai/grok-2-vision": { + "deprecation_date": "2026-02-28", "input_cost_per_image": 2e-06, "input_cost_per_token": 2e-06, "litellm_provider": "xai", @@ -43438,6 +43442,7 @@ "supports_web_search": true }, "xai/grok-2-vision-latest": { + "deprecation_date": "2026-02-28", "input_cost_per_image": 2e-06, "input_cost_per_token": 2e-06, "litellm_provider": "xai", @@ -43836,7 +43841,7 @@ "max_input_tokens": 1000000, "max_output_tokens": 1000000, "max_tokens": 1000000, - "mode": "chat", + "mode": "responses", "output_cost_per_token": 2.5e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, @@ -44018,6 +44023,7 @@ "supports_web_search": true }, "xai/grok-beta": { + "deprecation_date": "2026-02-28", "input_cost_per_token": 5e-06, "litellm_provider": "xai", "max_input_tokens": 131072, @@ -44094,6 +44100,7 @@ "deprecation_date": "2026-05-15" }, "xai/grok-vision-beta": { + "deprecation_date": "2026-02-28", "input_cost_per_image": 5e-06, "input_cost_per_token": 5e-06, "litellm_provider": "xai", @@ -50703,7 +50710,7 @@ "max_input_tokens": 1000000, "max_output_tokens": 1000000, "max_tokens": 1000000, - "mode": "chat", + "mode": "responses", "output_cost_per_token": 2.5e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index 9ca8d9e1bac3..7bd629bfc580 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -43373,6 +43373,7 @@ ] }, "xai/grok-2": { + "deprecation_date": "2026-02-28", "input_cost_per_token": 2e-06, "litellm_provider": "xai", "max_input_tokens": 131072, @@ -43385,6 +43386,7 @@ "supports_web_search": true }, "xai/grok-2-1212": { + "deprecation_date": "2026-02-28", "input_cost_per_token": 2e-06, "litellm_provider": "xai", "max_input_tokens": 131072, @@ -43397,6 +43399,7 @@ "supports_web_search": true }, "xai/grok-2-latest": { + "deprecation_date": "2026-02-28", "input_cost_per_token": 2e-06, "litellm_provider": "xai", "max_input_tokens": 131072, @@ -43409,6 +43412,7 @@ "supports_web_search": true }, "xai/grok-2-vision": { + "deprecation_date": "2026-02-28", "input_cost_per_image": 2e-06, "input_cost_per_token": 2e-06, "litellm_provider": "xai", @@ -43438,6 +43442,7 @@ "supports_web_search": true }, "xai/grok-2-vision-latest": { + "deprecation_date": "2026-02-28", "input_cost_per_image": 2e-06, "input_cost_per_token": 2e-06, "litellm_provider": "xai", @@ -43836,7 +43841,7 @@ "max_input_tokens": 1000000, "max_output_tokens": 1000000, "max_tokens": 1000000, - "mode": "chat", + "mode": "responses", "output_cost_per_token": 2.5e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, @@ -44018,6 +44023,7 @@ "supports_web_search": true }, "xai/grok-beta": { + "deprecation_date": "2026-02-28", "input_cost_per_token": 5e-06, "litellm_provider": "xai", "max_input_tokens": 131072, @@ -44094,6 +44100,7 @@ "deprecation_date": "2026-05-15" }, "xai/grok-vision-beta": { + "deprecation_date": "2026-02-28", "input_cost_per_image": 5e-06, "input_cost_per_token": 5e-06, "litellm_provider": "xai", @@ -50703,7 +50710,7 @@ "max_input_tokens": 1000000, "max_output_tokens": 1000000, "max_tokens": 1000000, - "mode": "chat", + "mode": "responses", "output_cost_per_token": 2.5e-06, "source": "https://docs.x.ai/docs/models", "supports_function_calling": true, diff --git a/tests/test_litellm/test_xai_grok_model_metadata.py b/tests/test_litellm/test_xai_grok_model_metadata.py new file mode 100644 index 000000000000..30f8122d20a4 --- /dev/null +++ b/tests/test_litellm/test_xai_grok_model_metadata.py @@ -0,0 +1,85 @@ +import json +from pathlib import Path + +# https://github.com/BerriAI/litellm/issues/38179 +# grok-2-era slugs: xAI deprecated them effective 2026-02-28 (same batch date as +# the pre-existing xai/grok-2-vision-1212 annotation) and they now hard-fail with +# "Model not found — retired by xAI". +RETIRED_GROK2_MODELS = [ + "xai/grok-2", + "xai/grok-2-1212", + "xai/grok-2-latest", + "xai/grok-2-vision", + "xai/grok-2-vision-latest", + "xai/grok-beta", + "xai/grok-vision-beta", +] +GROK2_DEPRECATION_DATE = "2026-02-28" + +# Per https://docs.x.ai/developers/model-capabilities/text/multi-agent (Limitations): +# "The multi-agent model does not work with the OpenAI Chat Completions API." +RESPONSES_ONLY_MODELS = [ + "xai/grok-4.20-multi-agent-0309", + "xai/grok-4.20-multi-agent-beta-0309", +] + +# Slugs still served by xAI (https://docs.x.ai/developers/models) that must not +# be marked deprecated. +ACTIVE_GROK_MODELS = [ + "xai/grok-4.5", + "xai/grok-4.6", + "xai/grok-4.20-0309-reasoning", +] + + +def _load_model_cost(path: Path) -> dict: + with open(path) as f: + return json.load(f) + + +def test_retired_grok2_models_are_annotated(): + json_path = Path(__file__).parents[2] / "model_prices_and_context_window.json" + model_cost = _load_model_cost(json_path) + + for model in RETIRED_GROK2_MODELS: + info = model_cost.get(model) + assert info is not None, f"{model} not found in model_prices_and_context_window.json" + assert ( + info.get("deprecation_date") == GROK2_DEPRECATION_DATE + ), f"{model} should carry deprecation_date {GROK2_DEPRECATION_DATE}" + + +def test_grok_4_20_multi_agent_is_responses_only(): + json_path = Path(__file__).parents[2] / "model_prices_and_context_window.json" + model_cost = _load_model_cost(json_path) + + for model in RESPONSES_ONLY_MODELS: + info = model_cost.get(model) + assert info is not None, f"{model} not found in model_prices_and_context_window.json" + assert ( + info.get("mode") == "responses" + ), f"{model} only works with the xAI Responses API, not Chat Completions" + + +def test_active_grok_models_are_not_marked_deprecated(): + json_path = Path(__file__).parents[2] / "model_prices_and_context_window.json" + model_cost = _load_model_cost(json_path) + + for model in ACTIVE_GROK_MODELS: + info = model_cost.get(model) + assert info is not None, f"{model} not found in model_prices_and_context_window.json" + assert ( + "deprecation_date" not in info + ), f"{model} is still served by xAI and must not be marked deprecated" + + +def test_xai_grok_metadata_backup_matches_main(): + repo_root = Path(__file__).parents[2] + main_path = repo_root / "model_prices_and_context_window.json" + backup_path = repo_root / "litellm" / "model_prices_and_context_window_backup.json" + + main_cost = _load_model_cost(main_path) + backup_cost = _load_model_cost(backup_path) + + for model in RETIRED_GROK2_MODELS + RESPONSES_ONLY_MODELS: + assert backup_cost.get(model) == main_cost.get(model), f"{model} differs between main and backup"