mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-02 08:21:53 +00:00
Fix vercel_ai_gateway entry for glm-4.6 (#16084)
* Fix vercel_ai_gateway entry for glm-4.6 * Fix: add unit test for vercel_ai_gateway/zai/glm-4.6 * Fix: Add fix for unit test on vercel_ai_gateway/zai/glm-4.6 * Remove print statements in test_vercel_ai_gateway_glm46_cost_math
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user