opencode-gemini-cli-providerUse Gemini CLI as an OpenCode language model provider without an API key
0
17
近 7 天 4
21.5
生态多维模型
3 个月前
2026-04-24
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-gemini-cli-provider@0.1.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-gemini-cli-provider@0.1.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-gemini-cli-provideropencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Use Gemini CLI as an OpenCode provider without a Gemini API key.
The plugin registers gemini-local/* models and calls your local gemini command directly. There is no local HTTP server and no provider block to copy into opencode.json.
Quick Start
# 1. Install Gemini CLI
brew install gemini-cli
# 2. Make sure Gemini CLI works first
gemini -p "Say hi" -m gemini-3.1-flash-lite-preview
# 3. Optional: configure a proxy if your Gemini CLI needs one
mkdir -p ~/.config/opencode
printf '{"proxy":"http://127.0.0.1:10808"}\n' > ~/.config/opencode/gemini-proxy.json
# 4. Install the plugin globally
opencode plugin -g opencode-gemini-cli-provider
# 5. Verify models are available
opencode models | grep gemini-local
# 6. Test
opencode run "Say hello" --model gemini-local/gemini-3.1-flash-lite-preview
Models
The plugin currently exposes:
gemini-local/gemini-3-flash-preview
gemini-local/gemini-3.1-flash-lite-preview
gemini-local/gemini-3.1-pro-preview
Proxy Configuration
Proxy is often required in regions where Gemini is not directly reachable. The plugin checks proxy settings in this order:
https_proxyorHTTPS_PROXYfrom the environment that startsopencode~/.config/opencode/gemini-proxy.json- no proxy
Option A: Environment Variable
Use this when you only want the proxy for the current shell:
export https_proxy=http://127.0.0.1:10808
export http_proxy=http://127.0.0.1:10808
opencode run "Say hello" --model gemini-local/gemini-3.1-flash-lite-preview
Option B: Config File
Use this when you want OpenCode to remember the proxy:
mkdir -p ~/.config/opencode
printf '{"proxy":"http://127.0.0.1:10808"}\n' > ~/.config/opencode/gemini-proxy.json
Change http://127.0.0.1:10808 to your own proxy address.
If you do not need a proxy, do not create this file.
OpenCode Configuration
Only the plugin needs to be configured. Do not manually add a provider.gemini-local block.
Example opencode.json:
{
"plugin": [
"opencode-gemini-cli-provider"
]
}
You can set Gemini as your default model if desired:
{
"model": "gemini-local/gemini-3.1-flash-lite-preview"
}
Troubleshooting
Check Gemini CLI first:
gemini -p "Say hi" -m gemini-3.1-flash-lite-preview
Check plugin registration:
opencode models | grep gemini-local
opencode debug config | grep -A 8 gemini-local
If responses hang, confirm the proxy is available and Gemini CLI can use it:
export https_proxy=http://127.0.0.1:10808
gemini -p "Say hi" -m gemini-3.1-flash-lite-preview -o json
Gemini CLI can be slow to start. A first response around 10-20 seconds is normal.
Development
npm install
opencode plugin add $(pwd)
opencode run "Say hello" --model gemini-local/gemini-3.1-flash-lite-preview
License
MIT