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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(model_cost_map): fix json parse error on model cost map + add unit test (#8629)
Krish Dholakiaea985dda0b46
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 5eec1fcf2b8..c2c4140933a 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -5328,6 +5328,28 @@"supports_vision": true,"supports_tool_choice": true},+ "openrouter/google/gemini-2.0-flash-001": {+ "max_tokens": 8192,+ "max_input_tokens": 1048576,+ "max_output_tokens": 8192,+ "max_images_per_prompt": 3000,+ "max_videos_per_prompt": 10,+ "max_video_length": 1,+ "max_audio_length_hours": 8.4,+ "max_audio_per_prompt": 1,+ "max_pdf_size_mb": 30,+ "input_cost_per_audio_token": 0.0000007,+ "input_cost_per_token": 0.0000001,+ "output_cost_per_token": 0.0000004,+ "litellm_provider": "openrouter",+ "mode": "chat",+ "supports_system_messages": true,+ "supports_function_calling": true,+ "supports_vision": true,+ "supports_response_schema": true,+ "supports_audio_output": true,+ "supports_tool_choice": true+ },"openrouter/mistralai/mixtral-8x22b-instruct": {"max_tokens": 65536,"input_cost_per_token": 0.00000065,diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex dd76f9a0e63..c2c4140933a 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -5348,7 +5348,7 @@"supports_vision": true,"supports_response_schema": true,"supports_audio_output": true,- "supports_tool_choice": true,+ "supports_tool_choice": true},"openrouter/mistralai/mixtral-8x22b-instruct": {"max_tokens": 65536,diff --git a/tests/local_testing/test_completion_cost.py b/tests/local_testing/test_completion_cost.pyindex 8576a00d308..124a222fdac 100644--- a/tests/local_testing/test_completion_cost.py+++ b/tests/local_testing/test_completion_cost.py@@ -2961,3 +2961,18 @@ async def test_cost_calculator_with_custom_pricing_router(model_item, custom_pri)# assert resp.model == "random-model"assert resp._hidden_params["response_cost"] > 0+++def test_json_valid_model_cost_map():+ import json++ os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"++ model_cost = litellm.get_model_cost_map(url="")++ try:+ # Attempt to serialize and deserialize the JSON+ json_str = json.dumps(model_cost)+ json.loads(json_str)+ except json.JSONDecodeError as e:+ assert False, f"Invalid JSON format: {str(e)}"