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: code quality issues from ruff linter (#17536)
Alexsander Hamir0c017f376c7d
diff --git a/docs/my-website/docs/proxy/config_settings.md b/docs/my-website/docs/proxy/config_settings.mdindex d4a522f055c..65b1c4afdbc 100644--- a/docs/my-website/docs/proxy/config_settings.md+++ b/docs/my-website/docs/proxy/config_settings.md@@ -360,6 +360,7 @@ router_settings:| AISPEND_ACCOUNT_ID | Account ID for AI Spend| AISPEND_API_KEY | API Key for AI Spend| AIOHTTP_CONNECTOR_LIMIT | Connection limit for aiohttp connector. When set to 0, no limit is applied. **Default is 0**+| AIOHTTP_CONNECTOR_LIMIT_PER_HOST | Connection limit per host for aiohttp connector. When set to 0, no limit is applied. **Default is 0**| AIOHTTP_KEEPALIVE_TIMEOUT | Keep-alive timeout for aiohttp connections in seconds. **Default is 120**| AIOHTTP_TRUST_ENV | Flag to enable aiohttp trust environment. When this is set to True, aiohttp will respect HTTP(S)_PROXY env vars. **Default is False**| AIOHTTP_TTL_DNS_CACHE | DNS cache time-to-live for aiohttp in seconds. **Default is 300**@@ -379,6 +380,7 @@ router_settings:| ATHINA_BASE_URL | Base URL for Athina service (defaults to `https://log.athina.ai`)| AUTH_STRATEGY | Strategy used for authentication (e.g., OAuth, API key)| AUTO_REDIRECT_UI_LOGIN_TO_SSO | Flag to enable automatic redirect of UI login page to SSO when SSO is configured. Default is **true**+| AUDIO_SPEECH_CHUNK_SIZE | Chunk size for audio speech processing. Default is 1024| ANTHROPIC_API_KEY | API key for Anthropic service| ANTHROPIC_API_BASE | Base URL for Anthropic API. Default is https://api.anthropic.com| AWS_ACCESS_KEY_ID | Access Key ID for AWS services@@ -441,6 +443,7 @@ router_settings:| CYBERARK_CLIENT_CERT | Path to client certificate for CyberArk authentication| CYBERARK_CLIENT_KEY | Path to client key for CyberArk authentication| CYBERARK_USERNAME | Username for CyberArk authentication+| CYBERARK_SSL_VERIFY | Flag to enable or disable SSL certificate verification for CyberArk. Default is True| CONFIDENT_API_KEY | API key for DeepEval integration| CUSTOM_TIKTOKEN_CACHE_DIR | Custom directory for Tiktoken cache| CONFIDENT_API_KEY | API key for Confident AI (Deepeval) Logging service@@ -655,6 +658,8 @@ router_settings:| LITERAL_API_URL | API URL for Literal service| LITERAL_BATCH_SIZE | Batch size for Literal operations| LITELLM_ANTHROPIC_DISABLE_URL_SUFFIX | Disable automatic URL suffix appending for Anthropic API base URLs. When set to `true`, prevents LiteLLM from automatically adding `/v1/messages` or `/v1/complete` to custom Anthropic API endpoints+| LITELLM_DD_AGENT_HOST | Hostname or IP of DataDog agent for LiteLLM-specific logging. When set, logs are sent to agent instead of direct API+| LITELLM_DD_AGENT_PORT | Port of DataDog agent for LiteLLM-specific log intake. Default is 10518| LITELLM_DONT_SHOW_FEEDBACK_BOX | Flag to hide feedback box in LiteLLM UI| LITELLM_DROP_PARAMS | Parameters to drop in LiteLLM requests| LITELLM_MODIFY_PARAMS | Parameters to modify in LiteLLM requests@@ -841,6 +846,9 @@ router_settings:| UPSTREAM_LANGFUSE_SECRET_KEY | Secret key for upstream Langfuse authentication| USE_AWS_KMS | Flag to enable AWS Key Management Service for encryption| USE_PRISMA_MIGRATE | Flag to use prisma migrate instead of prisma db push. Recommended for production environments.+| WANDB_API_KEY | API key for Weights & Biases (W&B) logging integration+| WANDB_HOST | Host URL for Weights & Biases (W&B) service+| WANDB_PROJECT_ID | Project ID for Weights & Biases (W&B) logging integration| WEBHOOK_URL | URL for receiving webhooks from external services| SPEND_LOG_RUN_LOOPS | Constant for setting how many runs of 1000 batch deletes should spend_log_cleanup task run| SPEND_LOG_CLEANUP_BATCH_SIZE | Number of logs deleted per batch during cleanup. Default is 1000diff --git a/litellm/llms/anthropic/chat/guardrail_translation/handler.py b/litellm/llms/anthropic/chat/guardrail_translation/handler.pyindex e1af433f23f..b1c4b1484da 100644--- a/litellm/llms/anthropic/chat/guardrail_translation/handler.py+++ b/litellm/llms/anthropic/chat/guardrail_translation/handler.py@@ -26,8 +26,6 @@ from litellm.types.llms.anthropic import (AllAnthropicToolsValues,AnthropicMessagesRequest,)-from litellm.types.llms.openai import ChatCompletionToolParam-from litellm.types.llms.anthropic import AllAnthropicToolsValuesfrom litellm.types.llms.openai import (ChatCompletionToolCallChunk,ChatCompletionToolParam,@@ -66,7 +64,6 @@ class AnthropicMessagesHandler(BaseTranslation):Process input messages by applying guardrails to text content."""messages = data.get("messages")- tools = data.get("tools", None)if messages is None:return datadiff --git a/litellm/llms/openai_like/json_loader.py b/litellm/llms/openai_like/json_loader.pyindex 35c0f1a30c3..f516d39662e 100644--- a/litellm/llms/openai_like/json_loader.py+++ b/litellm/llms/openai_like/json_loader.py@@ -6,6 +6,8 @@ import jsonfrom pathlib import Pathfrom typing import Dict, Optional+from litellm._logging import verbose_logger+class SimpleProviderConfig:"""Simple data class for JSON provider config"""@@ -49,7 +51,7 @@ class JSONProviderRegistry:cls._loaded = Trueexcept Exception as e:- print(f"Warning: Failed to load JSON provider configs: {e}")+ verbose_logger.warning(f"Warning: Failed to load JSON provider configs: {e}")cls._loaded = True@classmethoddiff --git a/litellm/proxy/management_endpoints/team_endpoints.py b/litellm/proxy/management_endpoints/team_endpoints.pyindex ba10d250417..4b62e490a82 100644--- a/litellm/proxy/management_endpoints/team_endpoints.py+++ b/litellm/proxy/management_endpoints/team_endpoints.py@@ -68,7 +68,6 @@ from litellm.proxy.auth.user_api_key_auth import user_api_key_authfrom litellm.proxy.management_endpoints.common_utils import (_is_user_team_admin,_set_object_metadata_field,- _update_metadata_field,_update_metadata_fields,_upsert_budget_and_membership,_user_has_admin_view,@@ -1320,13 +1319,7 @@ async def update_team(updated_kv = data.json(exclude_unset=True)# Check budget_duration and budget_reset_at- if data.budget_duration is not None:- from litellm.proxy.common_utils.timezone_utils import get_budget_reset_time-- reset_at = get_budget_reset_time(budget_duration=data.budget_duration)-- # set the budget_reset_at in DB- updated_kv["budget_reset_at"] = reset_at+ _set_budget_reset_at(data, updated_kv)if TeamMemberBudgetHandler.should_create_budget(team_member_budget=data.team_member_budget,@@ -1405,6 +1398,15 @@ async def update_team(raise handle_exception_on_proxy(e)+def _set_budget_reset_at(data: UpdateTeamRequest, updated_kv: dict) -> None:+ """Set budget_reset_at in updated_kv if budget_duration is provided."""+ if data.budget_duration is not None:+ from litellm.proxy.common_utils.timezone_utils import get_budget_reset_time++ reset_at = get_budget_reset_time(budget_duration=data.budget_duration)+ updated_kv["budget_reset_at"] = reset_at++async def handle_update_object_permission(data_json: dict, existing_team_row: LiteLLM_TeamTable) -> dict:diff --git a/litellm/responses/litellm_completion_transformation/transformation.py b/litellm/responses/litellm_completion_transformation/transformation.pyindex 0446031d7d6..aa3dcbecfef 100644--- a/litellm/responses/litellm_completion_transformation/transformation.py+++ b/litellm/responses/litellm_completion_transformation/transformation.py@@ -713,11 +713,6 @@ class LiteLLMCompletionResponsesConfig:Returns:Dictionary in ChatCompletionToolCallChunk format"""- from litellm.types.llms.openai import (- ChatCompletionToolCallChunk,- ChatCompletionToolCallFunctionChunk,- )-# Extract provider_specific_fields if presentprovider_specific_fields = getattr(tool_call_item, "provider_specific_fields", None