fix(config): return provider default api base in config resolution

This commit is contained in:
moranfong
2026-04-13 23:42:58 +08:00
parent b3288fbc87
commit 0750d1f182
2 changed files with 35 additions and 4 deletions
+2 -4
View File
@@ -304,17 +304,15 @@ class Config(BaseSettings):
return p.api_key if p else None
def get_api_base(self, model: str | None = None) -> str | None:
"""Get API base URL for the given model. Applies default URLs for gateway/local providers."""
"""Get API base URL for the given model, falling back to the provider default when present."""
from nanobot.providers.registry import find_by_name
p, name = self._match_provider(model)
if p and p.api_base:
return p.api_base
# Only gateways get a default api_base here. Standard providers
# resolve their base URL from the registry in the provider constructor.
if name:
spec = find_by_name(name)
if spec and (spec.is_gateway or spec.is_local) and spec.default_api_base:
if spec and spec.default_api_base:
return spec.default_api_base
return None