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]

[Feature] UI - Models: allow empty api_key for Anthropic provider (BYOK)

Yuneng Jiangad48af69aafa
diff --git a/litellm/proxy/public_endpoints/provider_create_fields.json b/litellm/proxy/public_endpoints/provider_create_fields.json
index 860593a6eab..b24f3df6272 100644
--- a/litellm/proxy/public_endpoints/provider_create_fields.json
+++ b/litellm/proxy/public_endpoints/provider_create_fields.json
@@ -218,8 +218,8 @@
"key": "api_key",
"label": "API Key",
"placeholder": "sk-",
- "tooltip": null,
- "required": true,
+ "tooltip": "Leave empty for BYOK (bring-your-own-key) flows, where clients forward their own Anthropic key via the x-api-key header. Requires the 'Forward LLM provider auth headers' UI setting to be enabled.",
+ "required": false,
"field_type": "password",
"options": null,
"default_value": null
diff --git a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py
index d62f88bf169..dc6def48fcb 100644
--- a/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py
+++ b/tests/test_litellm/proxy/public_endpoints/test_public_endpoints.py
@@ -138,6 +138,34 @@ def test_azure_provider_fields_include_entra_id():
assert fields_by_key["client_secret"]["required"] is False
+def test_anthropic_provider_fields_support_byok():
+ """
+ The Anthropic provider form must allow BYOK:
+ - api_key is optional (not required) so admins can create models without a key
+ - api_key has a non-null tooltip explaining the BYOK use case
+ """
+ app_instance = FastAPI()
+ app_instance.include_router(router)
+ test_client = TestClient(app_instance)
+
+ response = test_client.get("/public/providers/fields")
+ assert response.status_code == 200
+ providers = response.json()
+
+ anthropic = next((p for p in providers if p["provider"] == "Anthropic"), None)
+ assert anthropic is not None, "Anthropic provider entry not found"
+
+ fields_by_key = {f["key"]: f for f in anthropic["credential_fields"]}
+ assert "api_key" in fields_by_key
+ assert fields_by_key["api_key"]["required"] is False, (
+ "Anthropic api_key must be optional so admins can configure BYOK models "
+ "without entering a key. See BYOK tutorial."
+ )
+ assert fields_by_key["api_key"].get("tooltip"), (
+ "Anthropic api_key must have a tooltip explaining the BYOK use case."
+ )
+
+
def test_public_model_hub_with_healthy_model():
"""Test that health information is populated for a healthy model"""
app = FastAPI()