diff --git a/pkg/providers/factory.go b/pkg/providers/factory.go index d82a623a2..5b3e42b9e 100644 --- a/pkg/providers/factory.go +++ b/pkg/providers/factory.go @@ -107,6 +107,9 @@ func resolveProviderSelection(cfg *config.Config) (providerSelection, error) { sel.apiKey = cfg.Providers.LiteLLM.APIKey sel.apiBase = cfg.Providers.LiteLLM.APIBase sel.proxy = cfg.Providers.LiteLLM.Proxy + if sel.apiBase == "" { + sel.apiBase = "http://localhost:4000/v1" + } } case "zhipu", "glm": if cfg.Providers.Zhipu.APIKey != "" { diff --git a/pkg/providers/factory_test.go b/pkg/providers/factory_test.go index 345b8631f..f7a916d9e 100644 --- a/pkg/providers/factory_test.go +++ b/pkg/providers/factory_test.go @@ -29,6 +29,15 @@ func TestResolveProviderSelection(t *testing.T) { wantAPIBase: "http://localhost:4000/v1", wantProxy: "http://127.0.0.1:7890", }, + { + name: "explicit litellm provider defaults base when only key is configured", + setup: func(cfg *config.Config) { + cfg.Agents.Defaults.Provider = "litellm" + cfg.Providers.LiteLLM.APIKey = "litellm-key" + }, + wantType: providerTypeHTTPCompat, + wantAPIBase: "http://localhost:4000/v1", + }, { name: "explicit claude-cli provider routes to cli provider type", setup: func(cfg *config.Config) {