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
add azure o1 pricing (#7715)
Krish Dholakiaec5a354eac89
diff --git a/docs/my-website/docs/providers/ollama.md b/docs/my-website/docs/providers/ollama.mdindex 63b79fe3aa3..3de21474fa2 100644--- a/docs/my-website/docs/providers/ollama.md+++ b/docs/my-website/docs/providers/ollama.md@@ -147,6 +147,7 @@ model_list:- model_name: "llama3.1"litellm_params:model: "ollama_chat/llama3.1"+ keep_alive: "8m" # Optional: Overrides default keep_alive, use -1 for Forevermodel_info:supports_function_calling: true```diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.pyindex e517744b03e..55d59ef0155 100644--- a/litellm/llms/anthropic/chat/transformation.py+++ b/litellm/llms/anthropic/chat/transformation.py@@ -1,5 +1,4 @@import json-import reimport timefrom typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast@@ -258,13 +257,13 @@ class AnthropicConfig(BaseConfig):) -> Optional[List[str]]:new_stop: Optional[List[str]] = Noneif isinstance(stop, str):- if re.match(r'^\s+$', stop) and litellm.drop_params is True: # anthropic doesn't allow whitespace characters as stop-sequences+ if stop.isspace() and litellm.drop_params is True: # anthropic doesn't allow whitespace characters as stop-sequencesreturn new_stopnew_stop = [stop]elif isinstance(stop, list):new_v = []for v in stop:- if re.match(r'^\s+$', v) and litellm.drop_params is True: # anthropic doesn't allow whitespace characters as stop-sequences+ if v.isspace() and litellm.drop_params is True: # anthropic doesn't allow whitespace characters as stop-sequencescontinuenew_v.append(v)if len(new_v) > 0:diff --git a/litellm/llms/ollama_chat.py b/litellm/llms/ollama_chat.pyindex 5aa26ced46d..76a0604c21b 100644--- a/litellm/llms/ollama_chat.py+++ b/litellm/llms/ollama_chat.py@@ -219,6 +219,7 @@ def get_ollama_response( # noqa: PLR0915stream = optional_params.pop("stream", False)format = optional_params.pop("format", None)+ keep_alive = optional_params.pop("keep_alive", None)function_name = optional_params.pop("function_name", None)tools = optional_params.pop("tools", None)@@ -256,6 +257,8 @@ def get_ollama_response( # noqa: PLR0915data["format"] = formatif tools is not None:data["tools"] = tools+ if keep_alive is not None:+ data["keep_alive"] = keep_alive## LOGGINGlogging_obj.pre_call(input=None,diff --git a/litellm/llms/together_ai/chat.py b/litellm/llms/together_ai/chat.pyindex 51933196ed5..06d33f69750 100644--- a/litellm/llms/together_ai/chat.py+++ b/litellm/llms/together_ai/chat.py@@ -32,7 +32,7 @@ class TogetherAIConfig(OpenAIGPTConfig):optional_params = super().get_supported_openai_params(model)if supports_function_calling is not True:- verbose_logger.warning(+ verbose_logger.debug("Only some together models support function calling/response_format. Docs - https://docs.together.ai/docs/function-calling")optional_params.remove("tools")diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex b4f3952dca7..c924fa4cea8 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -945,6 +945,20 @@"supports_vision": false,"supports_prompt_caching": true},+ "azure/o1": {+ "max_tokens": 100000,+ "max_input_tokens": 200000,+ "max_output_tokens": 100000,+ "input_cost_per_token": 0.000015,+ "output_cost_per_token": 0.000060,+ "cache_read_input_token_cost": 0.0000075,+ "litellm_provider": "azure",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_parallel_function_calling": true,+ "supports_vision": true,+ "supports_prompt_caching": true+ },"azure/o1-preview": {"max_tokens": 32768,"max_input_tokens": 128000,diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.pyindex 17b17687aef..8002863217d 100644--- a/litellm/proxy/proxy_server.py+++ b/litellm/proxy/proxy_server.py@@ -1653,7 +1653,15 @@ class ProxyConfig:Do this, to avoid mutating the config state outside of allowed methods"""- return copy.deepcopy(self.config)+ try:+ return copy.deepcopy(self.config)+ except Exception as e:+ verbose_proxy_logger.debug(+ "ProxyConfig:get_config_state(): Error returning copy of config state. self.config={}\nError: {}".format(+ self.config, e+ )+ )+ return {}async def load_config( # noqa: PLR0915self, router: Optional[litellm.Router], config_file_path: strdiff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex b4f3952dca7..c924fa4cea8 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -945,6 +945,20 @@"supports_vision": false,"supports_prompt_caching": true},+ "azure/o1": {+ "max_tokens": 100000,+ "max_input_tokens": 200000,+ "max_output_tokens": 100000,+ "input_cost_per_token": 0.000015,+ "output_cost_per_token": 0.000060,+ "cache_read_input_token_cost": 0.0000075,+ "litellm_provider": "azure",+ "mode": "chat",+ "supports_function_calling": true,+ "supports_parallel_function_calling": true,+ "supports_vision": true,+ "supports_prompt_caching": true+ },"azure/o1-preview": {"max_tokens": 32768,"max_input_tokens": 128000,diff --git a/tests/proxy_unit_tests/test_proxy_utils.py b/tests/proxy_unit_tests/test_proxy_utils.pyindex dd018f674ff..2b63ba5a8b8 100644--- a/tests/proxy_unit_tests/test_proxy_utils.py+++ b/tests/proxy_unit_tests/test_proxy_utils.py@@ -1107,6 +1107,29 @@ def test_proxy_config_state_post_init_callback_call():assert config["litellm_settings"]["default_team_settings"][0]["team_id"] == "test"+def test_proxy_config_state_get_config_state_error():+ """+ Ensures that get_config_state does not raise an error when the config is not a valid dictionary+ """+ from litellm.proxy.proxy_server import ProxyConfig+ import threading++ test_config = {+ "callback_list": [+ {+ "lock": threading.RLock(), # This will cause the deep copy to fail+ "name": "test_callback",+ }+ ],+ "model_list": ["gpt-4", "claude-3"],+ }++ pc = ProxyConfig()+ pc.config = test_config+ config = pc.get_config_state()+ assert config == {}++@pytest.mark.parametrize("associated_budget_table, expected_user_api_key_auth_key, expected_user_api_key_auth_value",[