OpenCode
Open-source Go-based terminal coding assistant. Configure BeansAI as a custom provider.
Overview
OpenCode is a fully open-source terminal coding tool with a TUI built on Bubble Tea. It reads a opencode.json config file that lets you define custom AI providers — point it at BeansAI to access Claude, GPT, and every other model in the catalog from your terminal.
Installation
Choose the method that suits your platform:
curl -fsSL https://opencode.ai/install | bashnpm i -g opencode-ai@latestbrew install --cask opencode-desktopConfiguration
Step 1 — Register BeansAI as a provider. Run the auth command and select other from the list:
# Select "other" from the provider list when prompted
opencode auth loginWhen prompted, enter: Provider ID: beansai (must match the key in the config file below) and your BeansAI API key.
Step 2 — Write the config file. Create or edit ~/.config/opencode/opencode.json (Windows: %USERPROFILE%\.config\opencode\opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"beansai": {
"npm": "@ai-sdk/anthropic",
"name": "BeansAI",
"options": {
"baseURL": "https://api.beansai.dev/v1"
},
"models": {
"claude-opus-4-7": {
"name": "Claude Opus 4.7"
},
"claude-sonnet-4-6": {
"name": "Claude Sonnet 4.6"
},
"claude-haiku-4-5-20251001": {
"name": "Claude Haiku 4.5"
}
}
}
}
}The provider key ("beansai") in the JSON must exactly match the Provider ID you entered during opencode auth login. baseURL must end with /v1.
Basic usage
cd your-project
opencodeUse /models inside the TUI to list configured providers and switch models. Type requests in natural language — OpenCode reads your project files and applies changes directly.
Tips
- Add more models to the
modelsblock in the config — any model ID from the BeansAI catalog works. - To access GPT models alongside Claude, add a second provider block using
"npm": "@ai-sdk/openai"with a separate API key. - OpenCode has LSP integration — it sees type errors and diagnostics from your editor and can auto-fix them.
- Use session management (
/sessions) to save and restore conversations per project.