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]

Fix vercel_ai_gateway entry for glm-4.6 (#16084)

pale-aura0d84c11bbead
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index e685ef6a7b6..624dea84e19 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -21145,16 +21145,6 @@
"mode": "chat",
"output_cost_per_token": 2.4e-07
},
- "vercel_ai_gateway/glm-4.6": {
- "litellm_provider": "vercel_ai_gateway",
- "cache_read_input_token_cost": 1.1e-07,
- "input_cost_per_token": 6e-07,
- "max_input_tokens": 200000,
- "max_output_tokens": 200000,
- "max_tokens": 200000,
- "mode": "chat",
- "output_cost_per_token": 2.2e-06
- },
"vercel_ai_gateway/alibaba/qwen-3-235b": {
"input_cost_per_token": 2e-07,
"litellm_provider": "vercel_ai_gateway",
@@ -21988,6 +21978,20 @@
"mode": "chat",
"output_cost_per_token": 1.1e-06
},
+ "vercel_ai_gateway/zai/glm-4.6": {
+ "litellm_provider": "vercel_ai_gateway",
+ "cache_read_input_token_cost": 1.1e-07,
+ "input_cost_per_token": 4.5e-07,
+ "max_input_tokens": 200000,
+ "max_output_tokens": 200000,
+ "max_tokens": 200000,
+ "mode": "chat",
+ "output_cost_per_token": 1.8e-06,
+ "source": "https://vercel.com/ai-gateway/models/glm-4.6",
+ "supports_function_calling": true,
+ "supports_parallel_function_calling": true,
+ "supports_tool_choice": true
+ },
"vertex_ai/claude-3-5-haiku": {
"input_cost_per_token": 1e-06,
"litellm_provider": "vertex_ai-anthropic_models",
diff --git a/tests/test_litellm/llms/vercel_ai_gateway/test_vercel_ai_gateway.py b/tests/test_litellm/llms/vercel_ai_gateway/test_vercel_ai_gateway.py
index 7a2d992ec89..f4d4730e845 100755
--- a/tests/test_litellm/llms/vercel_ai_gateway/test_vercel_ai_gateway.py
+++ b/tests/test_litellm/llms/vercel_ai_gateway/test_vercel_ai_gateway.py
@@ -10,7 +10,8 @@ import respx
import litellm
from litellm import completion
from litellm.llms.vercel_ai_gateway.chat.transformation import VercelAIGatewayConfig
-
+from litellm.cost_calculator import cost_per_token
+import math
@pytest.fixture
def vercel_ai_gateway_response():
@@ -226,3 +227,21 @@ def test_vercel_ai_gateway_models_endpoint_failure():
with pytest.raises(Exception, match="Failed to get models: Not found"):
config.get_models()
+
+def test_vercel_ai_gateway_glm46_cost_math():
+ """Test the cost math for glm-4.6"""
+
+ with open("model_prices_and_context_window.json", "r") as f:
+ litellm.model_cost = json.load(f)
+
+ key = "vercel_ai_gateway/zai/glm-4.6"
+ info = litellm.model_cost[key]
+
+ prompt_cost, completion_cost = cost_per_token(
+ model="vercel_ai_gateway/zai/glm-4.6",
+ prompt_tokens=1000,
+ completion_tokens=500,
+ )
+
+ assert math.isclose(prompt_cost, 1000 * info["input_cost_per_token"], rel_tol=1e-12)
+ assert math.isclose(completion_cost, 500 * info["output_cost_per_token"], rel_tol=1e-12)