ShalokShalom/pi-opencode

Use Opencode Zen and Go as model providers in pi

★ 0Forks 0TypeScriptGitHub ↗Compare

README

pi-opencode

Extension for the pi coding agent, to add OpenCode as a provider. 🙂

Features

Prerequisites

Installation

Add this to your pi settings.json (~/.pi/agent/settings.json):

{
  "packages": [
    "git:https://github.com/ShalokShalom/pi-opencode.git"
  ]
}

Recommended Configuration

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"
}

Set the API key

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)

Open pi

First, open a new shell to load the config (exec bash, exec zsh, exec fish).
Then open pi.

Usage

Select a provider and model

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

Available Provider

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.

Development

# Clone the repository
git clone https://github.com/ShalokShalom/pi-opencode.git
cd pi-opencode

# Test locally
pi -e ./src/index.ts

Troubleshooting

"No API key" error

Try:

echo $OPENCODE_API_KEY

This 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..

Extension is not loading successfully

Run /reload after changes.

Model is not found

Verify that the model name is correct; they are case-sensitive. Otherwise, rise an issue.

License

MIT

Links

Contributors

awtottyShalokShalom

Issues