From 44e5d663af0f5779f44bb2da4d4dfd8cb7c9ef99 Mon Sep 17 00:00:00 2001 From: pdtkts <69439526+pdtkts@users.noreply.github.com> Date: Wed, 11 Mar 2026 16:55:11 +0700 Subject: [PATCH] fix: respect API base when listing Anthropic models (#151) --- internal/http/provider_models.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/http/provider_models.go b/internal/http/provider_models.go index 55e2c8b7..f42d1986 100644 --- a/internal/http/provider_models.go +++ b/internal/http/provider_models.go @@ -57,7 +57,7 @@ func (h *ProvidersHandler) handleListProviderModels(w http.ResponseWriter, r *ht switch p.ProviderType { case "anthropic_native": - models, err = fetchAnthropicModels(ctx, p.APIKey) + models, err = fetchAnthropicModels(ctx, p.APIKey, p.APIBase) case "gemini_native": models, err = fetchGeminiModels(ctx, p.APIKey) case "bailian": @@ -88,8 +88,12 @@ func (h *ProvidersHandler) handleListProviderModels(w http.ResponseWriter, r *ht } // fetchAnthropicModels calls the Anthropic models API. -func fetchAnthropicModels(ctx context.Context, apiKey string) ([]ModelInfo, error) { - req, err := http.NewRequestWithContext(ctx, "GET", "https://api.anthropic.com/v1/models", nil) +func fetchAnthropicModels(ctx context.Context, apiKey, apiBase string) ([]ModelInfo, error) { + base := strings.TrimRight(apiBase, "/") + if base == "" { + base = "https://api.anthropic.com/v1" + } + req, err := http.NewRequestWithContext(ctx, "GET", base+"/models", nil) if err != nil { return nil, err }