From d4f2c64caf8af4a7eb44d5b2f71de2cb71a0a3fc Mon Sep 17 00:00:00 2001 From: ExDevilLee Date: Wed, 19 Aug 2026 13:02:21 +0800 Subject: [PATCH] fix(zai): add current model catalog --- ...odel_prices_and_context_window_backup.json | 92 +++++++++++++++++++ model_prices_and_context_window.json | 92 +++++++++++++++++++ tests/test_litellm/test_zai_model_metadata.py | 91 ++++++++++++++++++ 3 files changed, 275 insertions(+) create mode 100644 tests/test_litellm/test_zai_model_metadata.py diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index d0eca17272d..f570f068649 100644 --- a/litellm/model_prices_and_context_window_backup.json +++ b/litellm/model_prices_and_context_window_backup.json @@ -42359,6 +42359,36 @@ "supports_tool_choice": true, "source": "https://docs.z.ai/guides/overview/pricing" }, + "zai/glm-5.3": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 2.6e-07, + "input_cost_per_token": 1.4e-06, + "output_cost_per_token": 4.4e-06, + "litellm_provider": "zai", + "max_input_tokens": 1048576, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, + "zai/glm-5.2": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 2.6e-07, + "input_cost_per_token": 1.4e-06, + "output_cost_per_token": 4.4e-06, + "litellm_provider": "zai", + "max_input_tokens": 1048576, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, "zai/glm-5.1": { "cache_creation_input_token_cost": 0, "cache_read_input_token_cost": 2.6e-07, @@ -42374,6 +42404,37 @@ "supports_tool_choice": true, "source": "https://docs.z.ai/guides/overview/pricing" }, + "zai/glm-5-turbo": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 2.4e-07, + "input_cost_per_token": 1.2e-06, + "output_cost_per_token": 4e-06, + "litellm_provider": "zai", + "max_input_tokens": 200000, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, + "zai/glm-5v-turbo": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 2.4e-07, + "input_cost_per_token": 1.2e-06, + "output_cost_per_token": 4e-06, + "litellm_provider": "zai", + "max_input_tokens": 200000, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "supports_vision": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, "zai/glm-5-code": { "cache_creation_input_token_cost": 0, "cache_read_input_token_cost": 3e-07, @@ -42419,6 +42480,21 @@ "supports_tool_choice": true, "source": "https://docs.z.ai/guides/overview/pricing" }, + "zai/glm-4.7-flashx": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 1e-08, + "input_cost_per_token": 7e-08, + "output_cost_per_token": 4e-07, + "litellm_provider": "zai", + "max_input_tokens": 200000, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, "zai/glm-4.6": { "cache_creation_input_token_cost": 0, "cache_read_input_token_cost": 1.1e-07, @@ -42434,6 +42510,22 @@ "supports_tool_choice": true, "source": "https://docs.z.ai/guides/overview/pricing" }, + "zai/glm-4.6v": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 5e-08, + "input_cost_per_token": 3e-07, + "output_cost_per_token": 9e-07, + "litellm_provider": "zai", + "max_input_tokens": 128000, + "max_output_tokens": 32768, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "supports_vision": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, "zai/glm-4.5": { "input_cost_per_token": 6e-07, "output_cost_per_token": 2.2e-06, diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json index d0eca17272d..f570f068649 100644 --- a/model_prices_and_context_window.json +++ b/model_prices_and_context_window.json @@ -42359,6 +42359,36 @@ "supports_tool_choice": true, "source": "https://docs.z.ai/guides/overview/pricing" }, + "zai/glm-5.3": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 2.6e-07, + "input_cost_per_token": 1.4e-06, + "output_cost_per_token": 4.4e-06, + "litellm_provider": "zai", + "max_input_tokens": 1048576, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, + "zai/glm-5.2": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 2.6e-07, + "input_cost_per_token": 1.4e-06, + "output_cost_per_token": 4.4e-06, + "litellm_provider": "zai", + "max_input_tokens": 1048576, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, "zai/glm-5.1": { "cache_creation_input_token_cost": 0, "cache_read_input_token_cost": 2.6e-07, @@ -42374,6 +42404,37 @@ "supports_tool_choice": true, "source": "https://docs.z.ai/guides/overview/pricing" }, + "zai/glm-5-turbo": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 2.4e-07, + "input_cost_per_token": 1.2e-06, + "output_cost_per_token": 4e-06, + "litellm_provider": "zai", + "max_input_tokens": 200000, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, + "zai/glm-5v-turbo": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 2.4e-07, + "input_cost_per_token": 1.2e-06, + "output_cost_per_token": 4e-06, + "litellm_provider": "zai", + "max_input_tokens": 200000, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "supports_vision": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, "zai/glm-5-code": { "cache_creation_input_token_cost": 0, "cache_read_input_token_cost": 3e-07, @@ -42419,6 +42480,21 @@ "supports_tool_choice": true, "source": "https://docs.z.ai/guides/overview/pricing" }, + "zai/glm-4.7-flashx": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 1e-08, + "input_cost_per_token": 7e-08, + "output_cost_per_token": 4e-07, + "litellm_provider": "zai", + "max_input_tokens": 200000, + "max_output_tokens": 131072, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, "zai/glm-4.6": { "cache_creation_input_token_cost": 0, "cache_read_input_token_cost": 1.1e-07, @@ -42434,6 +42510,22 @@ "supports_tool_choice": true, "source": "https://docs.z.ai/guides/overview/pricing" }, + "zai/glm-4.6v": { + "cache_creation_input_token_cost": 0, + "cache_read_input_token_cost": 5e-08, + "input_cost_per_token": 3e-07, + "output_cost_per_token": 9e-07, + "litellm_provider": "zai", + "max_input_tokens": 128000, + "max_output_tokens": 32768, + "mode": "chat", + "supports_function_calling": true, + "supports_prompt_caching": true, + "supports_reasoning": true, + "supports_tool_choice": true, + "supports_vision": true, + "source": "https://docs.z.ai/guides/overview/pricing" + }, "zai/glm-4.5": { "input_cost_per_token": 6e-07, "output_cost_per_token": 2.2e-06, diff --git a/tests/test_litellm/test_zai_model_metadata.py b/tests/test_litellm/test_zai_model_metadata.py new file mode 100644 index 00000000000..06864baa604 --- /dev/null +++ b/tests/test_litellm/test_zai_model_metadata.py @@ -0,0 +1,91 @@ +import json +from pathlib import Path + + +CURRENT_ZAI_MODELS = { + "zai/glm-5.3", + "zai/glm-5.2", + "zai/glm-5.1", + "zai/glm-5", + "zai/glm-5-turbo", + "zai/glm-5v-turbo", + "zai/glm-4.7", + "zai/glm-4.7-flash", + "zai/glm-4.7-flashx", + "zai/glm-4.6", + "zai/glm-4.6v", + "zai/glm-4.5", + "zai/glm-4.5v", + "zai/glm-4.5-air", + "zai/glm-4.5-flash", +} + +ZAI_NEW_MODEL_METADATA = { + "zai/glm-5.3": { + "input_cost_per_token": 1.4e-06, + "output_cost_per_token": 4.4e-06, + "max_input_tokens": 1048576, + "max_output_tokens": 131072, + }, + "zai/glm-5.2": { + "input_cost_per_token": 1.4e-06, + "output_cost_per_token": 4.4e-06, + "max_input_tokens": 1048576, + "max_output_tokens": 131072, + }, + "zai/glm-5-turbo": { + "input_cost_per_token": 1.2e-06, + "output_cost_per_token": 4e-06, + "max_input_tokens": 200000, + "max_output_tokens": 131072, + }, + "zai/glm-5v-turbo": { + "input_cost_per_token": 1.2e-06, + "output_cost_per_token": 4e-06, + "max_input_tokens": 200000, + "max_output_tokens": 131072, + "supports_vision": True, + }, + "zai/glm-4.7-flashx": { + "input_cost_per_token": 7e-08, + "output_cost_per_token": 4e-07, + "max_input_tokens": 200000, + "max_output_tokens": 131072, + }, + "zai/glm-4.6v": { + "input_cost_per_token": 3e-07, + "output_cost_per_token": 9e-07, + "max_input_tokens": 128000, + "max_output_tokens": 32768, + "supports_vision": True, + }, +} + + +def test_zai_model_metadata(): + json_path = Path(__file__).parents[2] / "model_prices_and_context_window.json" + model_cost = json.loads(json_path.read_text()) + + assert CURRENT_ZAI_MODELS.issubset(model_cost) + + for model, expected_metadata in ZAI_NEW_MODEL_METADATA.items(): + assert model in model_cost, f"{model} missing from model_prices_and_context_window.json" + metadata = model_cost[model] + assert metadata["litellm_provider"] == "zai" + assert metadata["mode"] == "chat" + assert metadata["supports_function_calling"] is True + assert metadata["supports_reasoning"] is True + assert metadata["supports_tool_choice"] is True + assert metadata["supports_prompt_caching"] is True + + for key, value in expected_metadata.items(): + assert metadata[key] == value + + +def test_zai_model_metadata_backup_matches_main(): + repo_root = Path(__file__).parents[2] + model_cost = json.loads((repo_root / "model_prices_and_context_window.json").read_text()) + backup_model_cost = json.loads((repo_root / "litellm" / "model_prices_and_context_window_backup.json").read_text()) + + for model in ZAI_NEW_MODEL_METADATA: + assert backup_model_cost[model] == model_cost[model]