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.
- Opencode CLI installed.
- A Google account with access to Gemini.
Add the plugin to your Opencode configuration file
(~/.config/opencode/config.json or similar):
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-gemini-auth@latest"]
}-
Login: Run the authentication command in your terminal:
opencode auth login
-
Select Provider: Choose Google from the list.
-
Authenticate: Select OAuth with Google (Gemini CLI).
- A browser window will open for you to approve the access.
- The plugin spins up a temporary local server to capture the callback.
- If the local server fails (e.g., port in use or headless environment), you can manually copy/paste the callback URL as instructed.
Once authenticated, Opencode will use your Google account for Gemini requests.
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:
{
"provider": {
"google": {
"options": {
"projectId": "your-specific-project-id"
}
}
}
}Configure "thinking" capabilities for Gemini models using the thinkingConfig
option in your config.json.
Gemini 3 (Thinking Level)
Use thinkingLevel ("low", "high") for Gemini 3 models.
{
"provider": {
"google": {
"models": {
"gemini-3-pro-preview": {
"options": {
"thinkingConfig": {
"thinkingLevel": "high",
"includeThoughts": true
}
}
}
}
}
}
}Gemini 2.5 (Thinking Budget)
Use thinkingBudget (token count) for Gemini 2.5 models.
{
"provider": {
"google": {
"models": {
"gemini-2.5-flash": {
"options": {
"thinkingConfig": {
"thinkingBudget": 8192,
"includeThoughts": true
}
}
}
}
}
}
}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.
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.
Opencode 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
# Run Opencode to trigger a fresh install
opencodeTo develop on this plugin locally:
-
Clone:
git clone https://github.com/jenslys/opencode-gemini-auth.git cd opencode-gemini-auth bun install -
Link: Update your Opencode config to point to your local directory using a
file://URL:{ "plugin": ["file:///absolute/path/to/opencode-gemini-auth"] }
MIT