feat(config): allow custom providers of type gemini (#585)

kslamph created

This change extends the provider configuration to allow users to define custom providers with `type: "gemini"`.

This enables connecting to any Gemini-compatible API by specifying its `base_url` and `api_key` within the `providers` section of `crush.json`. It supports complex setups, such as using a local proxy or a model-balancing service.

Change summary

internal/config/load.go         | 2 +-
internal/llm/provider/gemini.go | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)

Detailed changes

internal/config/load.go 🔗

@@ -270,7 +270,7 @@ func (c *Config) configureProviders(env env.Env, resolver VariableResolver, know
 			c.Providers.Del(id)
 			continue
 		}
-		if providerConfig.Type != catwalk.TypeOpenAI && providerConfig.Type != catwalk.TypeAnthropic {
+		if providerConfig.Type != catwalk.TypeOpenAI && providerConfig.Type != catwalk.TypeAnthropic && providerConfig.Type != catwalk.TypeGemini {
 			slog.Warn("Skipping custom provider because the provider type is not supported", "provider", id, "type", providerConfig.Type)
 			c.Providers.Del(id)
 			continue

internal/llm/provider/gemini.go 🔗

@@ -43,6 +43,9 @@ func createGeminiClient(opts providerClientOptions) (*genai.Client, error) {
 	cc := &genai.ClientConfig{
 		APIKey:  opts.apiKey,
 		Backend: genai.BackendGeminiAPI,
+		HTTPOptions: genai.HTTPOptions{
+			BaseURL: opts.baseURL,
+		},
 	}
 	if config.Get().Options.Debug {
 		cc.HTTPClient = log.NewHTTPClient()