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]

Revert "test_update_model_cost_map_url"

Ishaan Jaffer09dcb38b4bff
diff --git a/litellm/utils.py b/litellm/utils.py
index 4e4a9747e7d..ce6b2aa9c6a 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -2365,11 +2365,13 @@ def register_model(model_cost: Union[str, dict]): # noqa: PLR0915
loaded_model_cost = litellm.get_model_cost_map(url=model_cost)
for key, value in loaded_model_cost.items():
- ## get existing model info from model_cost directly ##
- ## avoid calling get_model_info() as it triggers provider resolution
- ## which can cause side effects like GitHub Copilot OAuth flow
- existing_model: dict = litellm.model_cost.get(key, {})
- model_cost_key = key
+ ## get model info ##
+ try:
+ existing_model: dict = cast(dict, get_model_info(model=key))
+ model_cost_key = existing_model["key"]
+ except Exception:
+ existing_model = {}
+ model_cost_key = key
## override / add new keys to the existing model cost dictionary
updated_dictionary = _update_dictionary(existing_model, value)
litellm.model_cost.setdefault(model_cost_key, {}).update(updated_dictionary)
diff --git a/tests/local_testing/test_register_model.py b/tests/local_testing/test_register_model.py
index 028bdc0abca..6b170798874 100644
--- a/tests/local_testing/test_register_model.py
+++ b/tests/local_testing/test_register_model.py
@@ -62,4 +62,4 @@ def test_update_model_cost_via_completion():
pytest.fail(f"An error occurred: {e}")
-# test_update_model_cost_via_completion()
+test_update_model_cost_via_completion()