fix: validate named custom provider endpoints

This commit is contained in:
chengyongru authored and Xubin Ren committed 2026-06-13 00:04:13 +08:00
1 parent a9308eb8e2
commit 09d24e6c25
6 files changed
+164 -12

No files matched your search

+10
View File
@@ -42,6 +42,8 @@ def _make_provider_core(
p = config.get_provider(model, preset=resolved)
spec = find_by_name(provider_name) if provider_name else None
if provider_name and not spec and p:
if not p.api_base:
raise ValueError(f"Provider '{provider_name}' requires api_base in config.")
spec = create_dynamic_spec(provider_name)
if spec and spec.is_transcription_only:
raise ValueError(f"Provider '{provider_name}' only supports transcription.")
@@ -50,6 +52,14 @@ def _make_provider_core(
if backend == "azure_openai":
if not p or not p.api_base:
raise ValueError("Azure OpenAI requires api_base in config.")
elif (
backend == "openai_compat"
and spec
and spec.is_direct
and not spec.default_api_base
and not (p and p.api_base)
):
raise ValueError(f"Provider '{provider_name}' requires api_base in config.")
elif backend == "openai_compat" and not model.startswith("bedrock/"):
needs_key = not (p and p.api_key)
exempt = spec and (spec.is_oauth or spec.is_local or spec.is_direct)