chore: fix gemini validation

This commit is contained in:
Kujtim Hoxha
2025-07-28 22:55:44 +02:00
parent 28f4f21516
commit 90961a6a03

View File

@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"log/slog" "log/slog"
"net/http" "net/http"
"net/url"
"os" "os"
"slices" "slices"
"strings" "strings"
@@ -471,6 +472,12 @@ func (c *ProviderConfig) TestConnection(resolver VariableResolver) error {
testURL = baseURL + "/models" testURL = baseURL + "/models"
headers["x-api-key"] = apiKey headers["x-api-key"] = apiKey
headers["anthropic-version"] = "2023-06-01" headers["anthropic-version"] = "2023-06-01"
case catwalk.TypeGemini:
baseURL, _ := resolver.ResolveValue(c.BaseURL)
if baseURL == "" {
baseURL = "https://generativelanguage.googleapis.com"
}
testURL = baseURL + "/v1beta/models?key=" + url.QueryEscape(apiKey)
} }
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel() defer cancel()