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 }