Extension for the pi coding agent, to add OpenCode as a provider. 🙂
-
Dozens of open and closed models
(Please raise an issue, if you find a model in this list, thats not available with this extension) -
opencode-go: Subscription service
-
opencode-zen: Pay-as-you-go
- Install pi and npm.
- Create an OpenCode account: https://opencode.ai/auth
- Pay for the service (Go is strongly recommended), and copy the API key.
Add this to your pi settings.json (~/.pi/agent/settings.json):
{
"packages": [
"git:https://github.com/ShalokShalom/pi-opencode.git"
]
}This is currently the recommended setup, so long as M3 is free on the Zen tier, and generally the strongest model on the subscription model.
(The free version is limited to a 256k context window, while the paid Go subscription is able to utilize the full 1 million token.)
{
"packages": [
"git:https://github.com/ShalokShalom/pi-opencode.git"
],
"model": "opencode-go-anthropic/minimax-m3",
"small_model": "opencode-zen-anthropic/minimax-m3-free"
}Add this line to your shell configuration:
# Bash, Zsh, etc
export OPENCODE_API_KEY="your-api-key-here"# Fish
set -Ux OPENCODE_API_KEY "your-api-key-here"(~/.bashrc, ~/.zshrc, ~/.config/fish/config.fish)
First, open a new shell to load the config (exec bash, exec zsh, exec fish).
Then open pi.
Type /model to select a model.
You can also select one directly via the full path:
/model opencode-go-anthropic/minimax-m3
/model opencode-zen/gpt-5.5| Provider | API | Endpoint |
|---|---|---|
| opencode-go | OpenAI Chat Completions | https://opencode.ai/zen/go/v1/chat/completions |
| opencode-zen | OpenAI Chat Completions | https://opencode.ai/zen/v1/chat/completions |
| opencode-go-anthropic | Anthropic Messages | https://opencode.ai/zen/go/v1/messages |
| opencode-zen-anthropic | Anthropic Messages | https://opencode.ai/zen/v1/messages |
The Anthropic Messages API provides you with Claude and MiniMax models.
All the other models come from the OpenAI API.
# Clone the repository
git clone https://github.com/ShalokShalom/pi-opencode.git
cd pi-opencode
# Test locally
pi -e ./src/index.tsTry:
echo $OPENCODE_API_KEYThis shows you your API key, if you had set it.
If you see no such key, you have to first set it as shown here..
Run /reload after changes.
Verify that the model name is correct; they are case-sensitive. Otherwise, rise an issue.
MIT