Repository navigation
Add Google Gemini API provider (via LiteLLM proxy) - #272
zwanski-start wants to merge 2 commits into
Conversation
Gemini has no Anthropic Messages API, so the new 'gemini' provider points the Claude Agent SDK at an Anthropic-compatible LiteLLM proxy (default http://localhost:4000) using ANTHROPIC_AUTH_TOKEN. The Settings UI shows the base URL and custom model input for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🔍 QA report: ✅ PassedTester: Dennis (cubefarm agent, in a fresh session) · Round: 1 · Author: Barbara Adds Google Gemini as an API provider, reached through a LiteLLM proxy and built on the existing API_PROVIDERS / get_effective_sdk_env() system. Choosing it sets the base URL to http://localhost:4000 and the default model to gemini-2.5-pro, and sends the proxy key as ANTHROPIC_AUTH_TOKEN while clearing ANTHROPIC_API_KEY and the Vertex variables. I checked this through the REST API, the SDK env output and the Settings UI in a real browser; tests, ruff, the UI build and lint pass, and mypy shows the same 24 errors as master. A live Gemini agent run and the e2e suite were not run (no credentials; the Playwright browser download was stuck on a cache lock).
🧪 Commands run
No browser screenshots were taken in this round. Posted by cubefarm · merges automatically once GitHub's checks pass |
Adaptations: manual merge with AutoForgeAI#241 — test_api_providers.py keeps both the GLM tests and the Gemini tests; the Settings base-URL / custom-model fields show for GLM and Gemini. Integrates AutoForgeAI#272 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeH26pcsqoxPb3CDs8g1VN
… keys and URLs Adaptations: - manual merge with AutoForgeAI#241/AutoForgeAI#272 (provider lists, test file, Settings texts); - the Base URL field now shows for Moonshot too (its help text asks China users to change the URL, which the UI did not allow); - a provider switch also clears the saved auth token: base URL and token are global settings shared by every provider, so the previous provider's secret key was sent to the new provider's server (and the UI showed it as set). test_settings_provider_switch covers the router. Integrates AutoForgeAI#308 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeH26pcsqoxPb3CDs8g1VN
Closes #94
What changed
Adds Google Gemini as a selectable API provider, built on the existing provider system (
API_PROVIDERSinregistry.py→get_effective_sdk_env()). That is the provider abstraction the issue asks for, so no new layer was added.AutoForge runs every agent through the Claude Agent SDK / Claude Code CLI, which only speaks the Anthropic Messages API. Gemini has no Anthropic-compatible endpoint (Google only offers native and OpenAI-compatible APIs). So the new provider sends requests to a LiteLLM proxy, which translates
/v1/messagesinto Gemini calls.registry.py: newgeminiprovider. Default base URL ishttp://localhost:4000, the proxy master key is sent asANTHROPIC_AUTH_TOKEN(so a realANTHROPIC_API_KEYis cleared and never reaches the proxy), and the models aregemini-2.5-pro(default) andgemini-2.5-flash.SettingsView.tsx/SettingsModal.tsx: info text for Gemini. The base URL field and the custom-model input are shown, because proxy host andmodel_namealiases vary per setup.examples/litellm_gemini_config.yaml: a ready-to-run proxy config (drop_params: trueso Anthropic-only fields don't fail requests).test_api_providers.py: tests that the Gemini settings map to the right SDK env vars (defaults and overrides).Verification
pytest test_api_providers.py: 3 passed.ruff check .is clean,mypyis clean, andpython test_security.pypasses.npm run lintshows 0 errors (the 6 warnings were already there).npm run buildsucceeds.HOMEon port 5443 and opened Settings in Playwright. "Google Gemini" appears in the provider list. Selecting it fills in the base URLhttp://localhost:4000, shows the API key field, both Gemini models and the custom model input.Assumptions / notes
get_effective_sdk_env(), so they also follow the provider setting.🤖 Generated with Claude Code