From ea985dda0b46cefe75205ad285a22fe6310b51cd Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Tue, 18 Feb 2025 11:18:16 -0800 Subject: [PATCH] fix(model_cost_map): fix json parse error on model cost map + add unit test (#8629) Fixes https://github.com/BerriAI/litellm/pull/8619#issuecomment-2666693045 --- ...odel_prices_and_context_window_backup.json | 22 +++++++++++++++++++ model_prices_and_context_window.json | 2 +- tests/local_testing/test_completion_cost.py | 15 +++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json index 5eec1fcf2b..c2c4140933 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.json index dd76f9a0e6..c2c4140933 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.py index 8576a00d30..124a222fda 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)}"