feat: add Google Gemini as OpenAI-compatible API provider#1002
Conversation
📝 WalkthroughWalkthroughGoogle Gemini API models are added to configuration, provider mappings, the built-in provider registry, and provider-resolution tests. Google API model sessions are classified as OpenAI-compatible so background execution uses the existing OpenAI-compatible generator. ChangesGoogle API integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant executeApi
participant isUsingOpenAICompatibleApiSession
participant generateAnswersWithOpenAICompatibleApi
executeApi->>isUsingOpenAICompatibleApiSession: evaluate Google API model session
isUsingOpenAICompatibleApiSession->>executeApi: return true
executeApi->>generateAnswersWithOpenAICompatibleApi: generate answers for Google API model
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoAdd Google Gemini as a built-in OpenAI-compatible API provider
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
There was a problem hiding this comment.
Code Review
This pull request adds support for Google Gemini models via the OpenAI-compatible API endpoint. It introduces Google-specific configuration keys, API key management, model definitions (including Gemini 3.1, 3.5, and 2.5 variants), and registers Google as a built-in provider with its base URL. I have no feedback to provide as there are no review comments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Overview
Files Reviewed (5 files)
Resolution Notes
Previous Review Summary (commit 2101379)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 2101379)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (4 files)
Reviewed by hy3:free · Input: 60.6K · Output: 7.5K · Cached: 228.4K |
There was a problem hiding this comment.
Pull request overview
Adds Google Gemini as a first-class OpenAI-compatible (chat/completions-style) API provider in the extension’s provider/model selection system, wiring it into the existing OpenAI-compatible provider registry and API-mode routing.
Changes:
- Register a new built-in OpenAI-compatible provider (
google) and map legacy “gemini” presets to it. - Add Google API model group + model definitions, plus a new
googleApiKeyconfig field. - Include Google API-mode sessions in the background’s “OpenAI-compatible API session” detection.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/services/apis/provider-registry.mjs |
Adds the built-in google provider and legacy preset→provider resolution. |
src/config/openai-provider-mappings.mjs |
Maps google to googleApiKey and links the googleApiModelKeys group to provider id google. |
src/config/index.mjs |
Defines Google model keys/models, adds googleApiKey default, and includes Google models in default active API modes. |
src/background/index.mjs |
Routes Google API-mode sessions through the OpenAI-compatible API path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review by Qodo
1.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 210137921a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Register Google as a built-in provider using the Gemini OpenAI-compatible endpoint. Add curated Gemini model presets, provider credential mapping, and background routing through the shared API path. Reuse supported Bearer authorization so API keys stay out of request URLs. Limit legacy resolution to configured Google preset keys so raw model IDs are not truncated by custom model parsing.
2101379 to
b2f4173
Compare
There was a problem hiding this comment.
Code Review
This pull request adds support for Google Gemini models as a built-in provider using the OpenAI-compatible endpoint. It introduces Google API key configuration, model definitions, provider mapping, and associated unit tests. However, the reviewer pointed out that several of the added Gemini model IDs (such as Gemini 3.1, 3.5, and 2.5) are hallucinated and do not exist in the actual Google API. Feedback has been provided to replace these with valid Gemini models (such as Gemini 1.5 and 2.0) across the configuration, default active models, and unit tests to prevent API errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| export const googleApiModelKeys = [ | ||
| 'googleGemini3_1Pro', | ||
| 'googleGemini3_5Flash', | ||
| 'googleGemini3Flash', | ||
| 'googleGemini2_5Pro', | ||
| 'googleGemini2_5Flash', | ||
| 'googleGemini2_5FlashLite', | ||
| ] |
There was a problem hiding this comment.
The Google Gemini API does not have models named Gemini 3.1, 3.5, or 2.5. These appear to be hallucinated model names. The actual current Gemini models available via the API are Gemini 1.5 Pro, Gemini 1.5 Flash, Gemini 2.0 Flash, Gemini 2.0 Flash-Lite, and Gemini 2.0 Pro. Using the hallucinated model IDs will result in API errors (e.g., 404 or 400 Bad Request).
export const googleApiModelKeys = [
'googleGemini1_5Pro',
'googleGemini1_5Flash',
'googleGemini2_0Flash',
'googleGemini2_0FlashLite',
'googleGemini2_0Pro',
]There was a problem hiding this comment.
These model IDs are current and documented by Google. Gemini 3.1, 3.5, 3 Flash, and 2.5 models are available, while Gemini 2.0 was shut down on June 1, 2026. No change is needed: https://ai.google.dev/gemini-api/docs/models
| googleGemini3_1Pro: { | ||
| value: 'gemini-3.1-pro-preview', | ||
| desc: 'Google (Gemini 3.1 Pro Preview)', | ||
| }, | ||
| googleGemini3_5Flash: { | ||
| value: 'gemini-3.5-flash', | ||
| desc: 'Google (Gemini 3.5 Flash)', | ||
| }, | ||
| googleGemini3Flash: { | ||
| value: 'gemini-3-flash-preview', | ||
| desc: 'Google (Gemini 3 Flash Preview)', | ||
| }, | ||
| googleGemini2_5Pro: { | ||
| value: 'gemini-2.5-pro', | ||
| desc: 'Google (Gemini 2.5 Pro)', | ||
| }, | ||
| googleGemini2_5Flash: { | ||
| value: 'gemini-2.5-flash', | ||
| desc: 'Google (Gemini 2.5 Flash)', | ||
| }, | ||
| googleGemini2_5FlashLite: { | ||
| value: 'gemini-2.5-flash-lite', | ||
| desc: 'Google (Gemini 2.5 Flash-Lite)', | ||
| }, |
There was a problem hiding this comment.
Replace the hallucinated Gemini model IDs and descriptions with the actual existing Gemini models supported by the Google API.
| googleGemini3_1Pro: { | |
| value: 'gemini-3.1-pro-preview', | |
| desc: 'Google (Gemini 3.1 Pro Preview)', | |
| }, | |
| googleGemini3_5Flash: { | |
| value: 'gemini-3.5-flash', | |
| desc: 'Google (Gemini 3.5 Flash)', | |
| }, | |
| googleGemini3Flash: { | |
| value: 'gemini-3-flash-preview', | |
| desc: 'Google (Gemini 3 Flash Preview)', | |
| }, | |
| googleGemini2_5Pro: { | |
| value: 'gemini-2.5-pro', | |
| desc: 'Google (Gemini 2.5 Pro)', | |
| }, | |
| googleGemini2_5Flash: { | |
| value: 'gemini-2.5-flash', | |
| desc: 'Google (Gemini 2.5 Flash)', | |
| }, | |
| googleGemini2_5FlashLite: { | |
| value: 'gemini-2.5-flash-lite', | |
| desc: 'Google (Gemini 2.5 Flash-Lite)', | |
| }, | |
| googleGemini1_5Pro: { | |
| value: 'gemini-1.5-pro', | |
| desc: 'Google (Gemini 1.5 Pro)', | |
| }, | |
| googleGemini1_5Flash: { | |
| value: 'gemini-1.5-flash', | |
| desc: 'Google (Gemini 1.5 Flash)', | |
| }, | |
| googleGemini2_0Flash: { | |
| value: 'gemini-2.0-flash', | |
| desc: 'Google (Gemini 2.0 Flash)', | |
| }, | |
| googleGemini2_0FlashLite: { | |
| value: 'gemini-2.0-flash-lite-preview', | |
| desc: 'Google (Gemini 2.0 Flash-Lite Preview)', | |
| }, | |
| googleGemini2_0Pro: { | |
| value: 'gemini-2.0-pro-exp', | |
| desc: 'Google (Gemini 2.0 Pro Experimental)', | |
| }, |
There was a problem hiding this comment.
These definitions match the current official model IDs. Replacing them with Gemini 1.5 or 2.0 models would introduce outdated or unavailable entries: https://ai.google.dev/gemini-api/docs/deprecations
| 'googleGemini3_1Pro', | ||
| 'googleGemini3_5Flash', |
There was a problem hiding this comment.
The current defaults intentionally use available Gemini 3.x models. The suggested Gemini 1.5 replacements are outdated, so no change is needed.
| test('resolveProviderIdForSession resolves legacy Google preset keys', () => { | ||
| assert.equal(resolveProviderIdForSession({ modelName: 'googleGemini2_5Flash' }), 'google') | ||
| assert.equal(resolveProviderIdForSession({ modelName: 'googleApiModelKeys-custom' }), 'google') | ||
| }) | ||
|
|
||
| test('resolveProviderIdForSession does not treat raw Gemini model IDs as legacy presets', () => { | ||
| assert.equal(resolveProviderIdForSession({ modelName: 'gemini-2.5-flash' }), null) | ||
| }) |
There was a problem hiding this comment.
Update the test cases to use the corrected Gemini model names for consistency and clarity.
| test('resolveProviderIdForSession resolves legacy Google preset keys', () => { | |
| assert.equal(resolveProviderIdForSession({ modelName: 'googleGemini2_5Flash' }), 'google') | |
| assert.equal(resolveProviderIdForSession({ modelName: 'googleApiModelKeys-custom' }), 'google') | |
| }) | |
| test('resolveProviderIdForSession does not treat raw Gemini model IDs as legacy presets', () => { | |
| assert.equal(resolveProviderIdForSession({ modelName: 'gemini-2.5-flash' }), null) | |
| }) | |
| test('resolveProviderIdForSession resolves legacy Google preset keys', () => { | |
| assert.equal(resolveProviderIdForSession({ modelName: 'googleGemini1_5Flash' }), 'google') | |
| assert.equal(resolveProviderIdForSession({ modelName: 'googleApiModelKeys-custom' }), 'google') | |
| }) | |
| test('resolveProviderIdForSession does not treat raw Gemini model IDs as legacy presets', () => { | |
| assert.equal(resolveProviderIdForSession({ modelName: 'gemini-1.5-flash' }), null) | |
| }) |
There was a problem hiding this comment.
The test values match the configured current model keys and IDs. Changing them to Gemini 1.5 would make the tests inconsistent with the supported model configuration.
|
Code review by qodo was updated up to the latest commit b2f4173 |
Add Google as a built-in OpenAI-compatible API provider using https://generativelanguage.googleapis.com/v1beta/openai/ endpoint.
Default models:
Uses the shared OpenAI-compatible Bearer authentication path and supports legacy resolution for configured Google preset keys.
Ref:
Summary by CodeRabbit