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]

chore: apply black formatting and enable black pre-commit hook

joereynac6b5c070056d
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9396f323e45..2bc361bc48f 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -14,12 +14,12 @@ repos:
types: [python]
files: (litellm/|litellm_proxy_extras/|enterprise/).*\.py
exclude: ^litellm/__init__.py$
- # - id: black
- # name: black
- # entry: poetry run black
- # language: system
- # types: [python]
- # files: (litellm/|litellm_proxy_extras/|enterprise/).*\.py
+ - id: black
+ name: black
+ entry: poetry run black
+ language: system
+ types: [python]
+ files: (litellm/|litellm_proxy_extras/).*\.py
- repo: https://github.com/pycqa/flake8
rev: 7.0.0 # The version of flake8 to use
hooks:
diff --git a/litellm/llms/anthropic/skills/transformation.py b/litellm/llms/anthropic/skills/transformation.py
index f582aefd81d..a992d84d459 100644
--- a/litellm/llms/anthropic/skills/transformation.py
+++ b/litellm/llms/anthropic/skills/transformation.py
@@ -42,7 +42,9 @@ class AnthropicSkillsConfig(BaseSkillsAPIConfig):
auth_header = AnthropicModelInfo.get_auth_header(api_key)
if auth_header is None:
- raise ValueError("ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Skills API")
+ raise ValueError(
+ "ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN is required for Skills API"
+ )
headers.update(auth_header)
headers["anthropic-version"] = "2023-06-01"
diff --git a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
index 96a7b5a27ae..534022cc133 100644
--- a/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
+++ b/litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py
@@ -586,7 +586,11 @@ async def anthropic_proxy_route(
"""
[Docs](https://docs.litellm.ai/docs/pass_through/anthropic_completion)
"""
- base_target_url = os.getenv("ANTHROPIC_API_BASE") or os.getenv("ANTHROPIC_BASE_URL") or "https://api.anthropic.com"
+ base_target_url = (
+ os.getenv("ANTHROPIC_API_BASE")
+ or os.getenv("ANTHROPIC_BASE_URL")
+ or "https://api.anthropic.com"
+ )
encoded_endpoint = httpx.URL(endpoint).path
# Ensure endpoint starts with '/' for proper URL construction
diff --git a/litellm/utils.py b/litellm/utils.py
index 77625809bf0..c8272586dad 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -6160,7 +6160,10 @@ def validate_environment( # noqa: PLR0915
["AZURE_API_BASE", "AZURE_API_VERSION", "AZURE_API_KEY"]
)
elif custom_llm_provider == "anthropic":
- if "ANTHROPIC_API_KEY" in os.environ or "ANTHROPIC_AUTH_TOKEN" in os.environ:
+ if (
+ "ANTHROPIC_API_KEY" in os.environ
+ or "ANTHROPIC_AUTH_TOKEN" in os.environ
+ ):
keys_in_environment = True
else:
missing_keys.append("ANTHROPIC_API_KEY")
@@ -6399,7 +6402,10 @@ def validate_environment( # noqa: PLR0915
missing_keys.append("OPENAI_API_KEY")
## anthropic
elif model in litellm.anthropic_models:
- if "ANTHROPIC_API_KEY" in os.environ or "ANTHROPIC_AUTH_TOKEN" in os.environ:
+ if (
+ "ANTHROPIC_API_KEY" in os.environ
+ or "ANTHROPIC_AUTH_TOKEN" in os.environ
+ ):
keys_in_environment = True
else:
missing_keys.append("ANTHROPIC_API_KEY")