Authenticate the Opencode CLI with your Google account. This plugin enables you to use your existing Gemini plan and quotas (including the free tier) directly within Opencode, bypassing separate API billing.
- π OAuth Authentication β browser-based Google account login
- π₯ Multi-Account Pool β register multiple accounts with priority-based fallback
- π Auto Account Switching β automatically switches to the next account on
QUOTA_EXHAUSTED - π All-Account Quota View β
/gquotashows quota for every account in your pool - βοΈ Account Management β list, remove, disable, enable accounts via
opencode auth login
- Opencode CLI installed.
- A Google account with access to Gemini.
Add the plugin to your Opencode configuration file
(~/.config/opencode/opencode.json or similar):
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-gemini-auth-plus@latest"]
}Important
If you're using a paid Gemini Code Assist subscription (Standard/Enterprise),
explicitly configure a Google Cloud projectId. Free tier accounts should
auto-provision a managed project, but you can still set projectId to force
a specific project.
- Run
opencode auth login - Select Google β OAuth with Google (Gemini CLI)
- Approve access in the browser
Add multiple accounts for quota fallback:
- Run
opencode auth login - Select Google β π Manage Gemini accounts
- Available actions:
- π List all accounts β view status (ACTIVE / EXHAUSTED / DISABLED), priority, email
- ποΈ Remove an account β remove from the managed pool
- π« Disable an account β temporarily skip without removing
- β Enable an account β re-enable a disabled account
Accounts are tried in priority order (lowest number = highest priority). When an account's daily quota is exhausted, the plugin automatically switches to the next available account.
Check quota for all accounts in your pool:
/gquota
Each account's quota is queried independently, showing per-model usage, remaining requests, and reset times.
By default, the plugin attempts to provision or find a suitable Google Cloud
project. To force a specific project, set the projectId in your configuration
or via environment variables:
File: ~/.config/opencode/opencode.json
{
"provider": {
"google": {
"options": {
"projectId": "your-specific-project-id"
}
}
}
}You can also set OPENCODE_GEMINI_PROJECT_ID, GOOGLE_CLOUD_PROJECT, or
GOOGLE_CLOUD_PROJECT_ID to supply the project ID via environment variables.
Below are example model entries you can add under provider.google.models in your
Opencode config. Each model can include an options.thinkingConfig block to
enable "thinking" features.
{
"provider": {
"google": {
"models": {
"gemini-2.5-flash": {
"options": {
"thinkingConfig": {
"thinkingBudget": 8192,
"includeThoughts": true
}
}
},
"gemini-2.5-pro": {
"options": {
"thinkingConfig": {
"thinkingBudget": 8192,
"includeThoughts": true
}
}
},
"gemini-3-flash-preview": {
"options": {
"thinkingConfig": {
"thinkingLevel": "high",
"includeThoughts": true
}
}
},
"gemini-3.1-pro-preview": {
"options": {
"thinkingConfig": {
"thinkingLevel": "high",
"includeThoughts": true
}
}
}
}
}
}
}Note: Available model names and previews may changeβcheck Google's documentation or the Gemini product page for the current model identifiers.
The plugin supports configuring Gemini "thinking" features per-model via
thinkingConfig. The available fields depend on the model family:
- For Gemini 3.x models: use
thinkingLevelwith values"low"or"high". - For Gemini 2.5 models: use
thinkingBudget(token count). includeThoughts(boolean) controls whether the model emits internal thoughts.
A combined example showing both model types:
{
"provider": {
"google": {
"models": {
"gemini-3.1-pro-preview": {
"options": {
"thinkingConfig": {
"thinkingLevel": "high",
"includeThoughts": true
}
}
},
"gemini-2.5-flash": {
"options": {
"thinkingConfig": {
"thinkingBudget": 8192,
"includeThoughts": true
}
}
}
}
}
}
}If you don't set a thinkingConfig for a model, the plugin will use default
behavior for that model.
If automatic provisioning fails, you may need to set up the project manually:
- Go to the Google Cloud Console.
- Create or select a project.
- Enable the Gemini for Google Cloud API
(
cloudaicompanion.googleapis.com). - Configure the
projectIdin your Opencode config as shown above.
Common causes of 429 RESOURCE_EXHAUSTED or QUOTA_EXHAUSTED:
- No project ID configured: the plugin uses a managed free-tier project, which has lower quotas.
- Model-specific limits: quotas are tracked per model (e.g.,
gemini-3.1-pro-previewvsgemini-3-flash-preview). - Large prompts: OAuth/Code Assist does not support cached content, so long system prompts and history can burn quota quickly.
- Parallel sessions: multiple Opencode windows can drain the same bucket.
Notes:
- Multi-account fallback: when the current account's daily quota is exhausted, the plugin automatically switches to the next available account in your pool. Use
opencode auth loginβ Manage Gemini accounts to add more accounts. - Paid plans still require a project: to use paid quotas in Opencode, set
provider.google.options.projectId(orOPENCODE_GEMINI_PROJECT_ID) and re-authenticate.
To view detailed logs of Gemini requests and responses, set the
OPENCODE_GEMINI_DEBUG environment variable:
OPENCODE_GEMINI_DEBUG=1 opencodeThis will generate gemini-debug-<timestamp>.log files in your working
directory containing sanitized request/response details.
This plugin mirrors the official Gemini CLI OAuth flow and Code Assist endpoints. In particular, project onboarding and quota retry handling follow the same behavior patterns as the Gemini CLI.
- Gemini CLI repository: https://github.com/google-gemini/gemini-cli
- Gemini CLI quota documentation: https://developers.google.com/gemini-code-assist/resources/quotas
For local parity checks, you can keep a separate clone of the official
gemini-cli in this repo at .local/gemini-cli.
This mirror is intentionally untracked, so contributors must set it up once on their machine:
git clone https://github.com/google-gemini/gemini-cli.git .local/gemini-cliAfter setup, pull upstream updates with:
bun run update:gemini-cliOpencode does not automatically update plugins. To update to the latest version, you must clear the cached plugin:
# Clear the specific plugin cache
rm -rf ~/.cache/opencode/node_modules/opencode-gemini-auth-plus
# Run Opencode to trigger a fresh install
opencodeTo develop on this plugin locally:
-
Clone:
git clone https://github.com/Heelc/opencode-gemini-auth-plus.git cd opencode-gemini-auth-plus bun install -
Link: Update your Opencode config to point to your local directory:
{ "plugin": ["/absolute/path/to/opencode-gemini-auth-plus"] } -
Test:
bun test
MIT