-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: add Gemini CLI provider for free access to Gemini models (#5134) #5137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Implement OAuth2-based authentication using Gemini CLI credentials - Add support for all Gemini models (Flash, Pro, Experimental) - Dynamic project discovery through Google Cloud Code Assist API - Proper SSE streaming with reasoning/thinking part detection - Add comprehensive tests for API handler and UI component - Update UI to match consistent styling of other providers - Add i18n translations for all UI text - Document setup requirements and usage This provider enables free access to Google's Gemini models through OAuth authentication without requiring API keys. Users need to have Gemini CLI installed and authenticated with a Google Cloud project that has the Code Assist API enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for a Gemini CLI provider that enables free access to Gemini models via OAuth authentication, eliminating the need for API keys. Key changes include:
- Implementation of OAuth2 authentication and dynamic project discovery in the API handler.
- Addition of a new Gemini CLI provider UI component with comprehensive tests and translations.
- Updates to provider settings, constants, and API handler mappings to integrate the new provider.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| webview-ui/src/utils/validate.ts | Added a case for "gemini-cli" to bypass API key validation. |
| webview-ui/src/i18n/locales/en/settings.json | Added translation keys and descriptions for Gemini CLI settings. |
| webview-ui/src/components/ui/hooks/useSelectedModel.ts | Integrated Gemini CLI models into model selection logic. |
| webview-ui/src/components/settings/providers/index.ts | Exported the new GeminiCli component. |
| webview-ui/src/components/settings/providers/tests/GeminiCli.spec.tsx | Added tests covering the Gemini CLI provider UI. |
| webview-ui/src/components/settings/providers/GeminiCli.tsx | Implemented the Gemini CLI provider UI component. |
| webview-ui/src/components/settings/constants.ts & ApiOptions.tsx | Updated to include Gemini CLI provider configuration. |
| src/api/providers/gemini-cli.ts | Implemented the Gemini CLI provider API handler with OAuth, streaming response parsing, and project discovery. |
| src/api/providers/tests/gemini-cli.spec.ts | Added unit tests for the Gemini CLI API handler. |
| src/api/index.ts | Updated API handler mapping to include Gemini CLI. |
| packages/types/src/providers/gemini-cli.ts | Defined types and models for the Gemini CLI provider. |
| packages/types/src/provider-settings.ts | Extended provider settings schema to support Gemini CLI. |
|
We have finished reviewing your PR. We have found no vulnerabilities. Reply to this PR with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I tested it and it works as expected.
I added translations for the error messages and fixed an unbounded while loop that could cause problems if the API keeps returning 401 responses.
The tests were failing because the implementation uses i18n keys for error messages, but the tests were expecting the actual English text. Updated the test expectations to match the i18n key format that the t() function returns in the test environment.
The test was failing on Windows because it expected forward slashes in the path but Windows uses backslashes. Updated the assertion to use a regex that matches both forward and backward slashes to make it work across all platforms.
- Change stringContaining to stringMatching with regex pattern - Support both forward and backward slashes for cross-platform compatibility - Fixes failing Windows unit test in CI
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
|
Do we need to modify src/shared/checkExistApiConfig.ts ? |
Co-authored-by: Matt Rubens <[email protected]>
- Add gemini-cli to the special case list in checkExistApiConfig.ts - This provider uses OAuth authentication instead of API keys
|
@mrubens 🤔 why the revert? |
More info: cline/cline#4495 |
#5137) Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Matt Rubens <[email protected]> Co-authored-by: Daniel Riccio <[email protected]> Co-authored-by: Daniel <[email protected]>
Description
Fixes #5134
This PR implements a new Gemini CLI provider that enables free access to Google's Gemini models through OAuth authentication without requiring API keys. The implementation is ported from Cline's Gemini CLI provider with adaptations for Roo Code's architecture.
Changes Made
~/.gemini/oauth_creds.jsonTesting
Verification of Acceptance Criteria
Checklist
Setup Requirements
Users need to:
npm install -g @google/generative-ai-cligemini auth loginTechnical Details
cloudcode-pa.googleapis.comendpointImportant
Introduces Gemini CLI provider for OAuth-based access to Gemini models, with UI, validation, and testing updates.
GeminiCliHandleringemini-cli.tsfor OAuth-based access to Gemini models without API keys.GeminiClicomponent inGeminiCli.tsxfor settings UI.ApiOptions.tsxandconstants.tsto include Gemini CLI.validate.tsto exclude API key validation forgemini-cli.gemini-cli.spec.tsfor unit tests ofGeminiCliHandler.GeminiCli.spec.tsxfor component tests ofGeminiCli.This description was created by
for fd58b29. You can customize this summary. It will automatically update as commits are pushed.