fix(clf_ai_gateway): list the provider in the proxy Add Model form

main now requires every LlmProviders value to have an entry in
provider_create_fields.json (or be frozen as unlisted), so the Add Model
dropdown cannot silently miss a backend provider. Add the clf_ai_gateway
entry in the same shape as the SCX.ai registration: required API key,
optional API base with https://api.clfaigateway.dev/v1 as placeholder, and
a cost-map model as the default model placeholder. A provider test pins
the entry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
bap1106 2026-09-17 03:44:27 +07:00
parent 7acf816586
commit e009e4ffea
2 changed files with 49 additions and 0 deletions

View file

@ -829,6 +829,34 @@
],
"default_model_placeholder": "gpt-3.5-turbo"
},
{
"provider": "CLF_AI_GATEWAY",
"provider_display_name": "CLF AI Gateway",
"litellm_provider": "clf_ai_gateway",
"credential_fields": [
{
"key": "api_base",
"label": "API Base",
"placeholder": "https://api.clfaigateway.dev/v1",
"tooltip": null,
"required": false,
"field_type": "text",
"options": null,
"default_value": null
},
{
"key": "api_key",
"label": "API Key",
"placeholder": null,
"tooltip": null,
"required": true,
"field_type": "password",
"options": null,
"default_value": null
}
],
"default_model_placeholder": "clf_ai_gateway/glm-5.3"
},
{
"provider": "CLOUDFLARE",
"provider_display_name": "Cloudflare",

View file

@ -1,3 +1,6 @@
import json
from pathlib import Path
import pytest
import litellm
@ -145,3 +148,21 @@ def test_advertised_reasoning_efforts_match_the_gateway(model: str) -> None:
key = f"clf_ai_gateway/{model}"
entry = {**litellm.model_cost[key], "key": key}
assert resolve_supported_reasoning_efforts(entry, deployment_is_mapped=True) == GATEWAY_REASONING_EFFORTS[model]
def test_selectable_in_the_proxy_add_model_form() -> None:
fields_path = Path(litellm.__file__).parent / "proxy" / "public_endpoints" / "provider_create_fields.json"
provider_fields = json.loads(fields_path.read_text(encoding="utf-8"))
entries = [entry for entry in provider_fields if entry["litellm_provider"] == "clf_ai_gateway"]
assert len(entries) == 1
entry = entries[0]
assert entry["provider"] == "CLF_AI_GATEWAY"
assert entry["provider_display_name"] == "CLF AI Gateway"
assert entry["default_model_placeholder"] in litellm.model_cost
fields = {field["key"]: field for field in entry["credential_fields"]}
assert fields["api_key"]["required"] is True
assert fields["api_key"]["field_type"] == "password"
assert fields["api_base"]["required"] is False
assert fields["api_base"]["placeholder"] == "https://api.clfaigateway.dev/v1"