From 6b161d29e9832fe1abafea231d7947e03d76f574 Mon Sep 17 00:00:00 2001 From: kslamph <15257433+kslamph@users.noreply.github.com> Date: Wed, 24 Sep 2025 21:12:37 +0800 Subject: [PATCH] feat(config): allow custom providers of type gemini (#585) 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. --- internal/config/load.go | 2 +- internal/llm/provider/gemini.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/config/load.go b/internal/config/load.go index ad2b75b75df8c6f8d7a5cd2e62df1a831157b9e1..e39074f78bdb8df0ddc98bfbc7322541175b71d6 100644 --- a/internal/config/load.go +++ b/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 diff --git a/internal/llm/provider/gemini.go b/internal/llm/provider/gemini.go index 256e21bf7d59216a41be4603c1475dc9e24bdeea..c1db9561e7db5fd3ae8da1ae1c9ea143f5ea20ec 100644 --- a/internal/llm/provider/gemini.go +++ b/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()