[Feature] UI - Models: add api_base field for Anthropic provider form

This commit is contained in:
Yuneng Jiang
2026-04-17 13:32:17 -07:00
parent ad48af69aa
commit 9a8aa4fae4
2 changed files with 27 additions and 0 deletions
@@ -214,6 +214,16 @@
"provider_display_name": "Anthropic",
"litellm_provider": "anthropic",
"credential_fields": [
{
"key": "api_base",
"label": "API Base",
"placeholder": null,
"tooltip": "Optional. Override the upstream Anthropic API URL. Defaults to https://api.anthropic.com.",
"required": false,
"field_type": "text",
"options": null,
"default_value": null
},
{
"key": "api_key",
"label": "API Key",
@@ -164,6 +164,23 @@ def test_anthropic_provider_fields_support_byok():
assert fields_by_key["api_key"].get("tooltip"), (
"Anthropic api_key must have a tooltip explaining the BYOK use case."
)
assert "api_base" in fields_by_key, (
"Anthropic provider form must expose api_base so cloud customers "
"can override the upstream URL without env var access."
)
api_base_field = fields_by_key["api_base"]
assert api_base_field["required"] is False
assert api_base_field["field_type"] == "text"
assert api_base_field.get("tooltip"), (
"api_base should have a tooltip explaining it is optional."
)
# UI forms render fields in credential_fields order; api_base should come first
# so an admin sees the URL override before the key field.
field_order = [f["key"] for f in anthropic["credential_fields"]]
assert field_order.index("api_base") < field_order.index("api_key"), (
"api_base must appear before api_key in credential_fields (matches AI21 and ANTHROPIC_TEXT convention)."
)
def test_public_model_hub_with_healthy_model():