diff --git a/litellm/__init__.py b/litellm/__init__.py index 99d7455c53..aeaa97fc3a 100644 --- a/litellm/__init__.py +++ b/litellm/__init__.py @@ -62,11 +62,11 @@ allowed_fails: int = 0 def get_model_cost_map(url: str): try: - response = requests.get(url) - response.raise_for_status() # Raise an exception if request is unsuccessful - content = response.json() - return content - except: + with requests.get(url, timeout=5) as response: # set a 5 second timeout for the get request + response.raise_for_status() # Raise an exception if the request is unsuccessful + content = response.json() + return content + except Exception as e: import importlib.resources import json with importlib.resources.open_text("litellm", "model_prices_and_context_window_backup.json") as f: