OpenCode
OpenCode is an open source AI coding agent available as a terminal interface, CLI, IDE extension, and desktop app. The ai& OpenCode plugin adds ai& as a first-class OpenCode provider backed by the OpenAI-compatible ai& gateway.
The plugin:
- routes requests to
https://api.aiand.com/v1; - adds an ai& login method for API keys;
- loads ai&’s live model catalog into OpenCode’s model picker.
Quick install
Section titled “Quick install”The fastest path is the hosted one-line installer. It installs OpenCode if it isn’t already on your PATH, adds the @aiand/opencode-plugin plugin to your global OpenCode config, and sets a default ai& model — leaving any model you’ve already chosen untouched. It backs up your config before editing and is safe to re-run.
curl -fsSL https://opencode.aiand.com/install.sh | bashRun the installer inside WSL:
curl -fsSL https://opencode.aiand.com/install.sh | bashWhen it finishes, continue with Authenticate and Run OpenCode below. Prefer to set things up by hand? Follow the manual steps instead.
1. Install OpenCode
Section titled “1. Install OpenCode”For the terminal or one-shot CLI:
curl -fsSL https://opencode.ai/install | bashOther supported installers include npm and Homebrew:
npm install -g opencode-aibrew install anomalyco/tap/opencodeOpenCode recommends WSL for the terminal experience. You can also install the Windows package:
choco install opencodeor:
scoop install opencodeFor the desktop app, download OpenCode Desktop (Beta) from opencode.ai/download. On macOS, you can also install it with Homebrew:
brew install --cask opencode-desktop2. Add the ai& plugin
Section titled “2. Add the ai& plugin”Add the npm plugin to an OpenCode config file. Use a project config when only this repository should use ai&, or a global config when you want ai& available in the terminal and the Desktop app across projects.
- Project:
opencode.jsonin your project root - Global:
~/.config/opencode/opencode.jsonor~/.config/opencode/opencode.jsonc
{ "$schema": "https://opencode.ai/config.json", "plugin": ["@aiand/opencode-plugin"], "model": "aiand/zai-org/glm-5.2"}OpenCode installs npm plugins automatically on startup and caches them. To pin a version or force a cached upgrade, include the version explicitly:
{ "$schema": "https://opencode.ai/config.json", "plugin": ["@aiand/opencode-plugin@0.1.0"], "model": "aiand/zai-org/glm-5.2"}3. Authenticate
Section titled “3. Authenticate”Create an API key in the ai& console, then choose one auth path.
Terminal login
Section titled “Terminal login”opencode auth loginChoose ai&, then paste your sk-... key. OpenCode stores the credential and reuses it for future sessions.
Inside OpenCode
Section titled “Inside OpenCode”In the OpenCode TUI or Desktop app, run:
/connectSelect ai&, choose the API key method, and paste your key.
Environment variable
Section titled “Environment variable”For CI, scripts, or non-interactive runs:
export AIAND_API_KEY="sk-your-aiand-api-key"$env:AIAND_API_KEY = "sk-your-aiand-api-key"4. Run OpenCode
Section titled “4. Run OpenCode”Interactive terminal UI:
opencodeOne-shot CLI:
opencode run "say hi in one word"Use the model picker when you want to switch models:
/modelsDesktop App
Section titled “Desktop App”The Desktop app uses the same OpenCode provider setup. For the smoothest setup:
- Install OpenCode Desktop (Beta) from opencode.ai/download.
- Put the plugin in your global config at
~/.config/opencode/opencode.json. - Open a project folder in the Desktop app.
- Run
/connect, select ai&, and paste your API key. - Run
/modelsand choose anaiand/...model, or rely on themodelvalue in your config.
This keeps the Desktop app, terminal TUI, and opencode run using the same ai& provider and model catalog.
Verify
Section titled “Verify”Check that OpenCode can see ai& models:
opencode run -m aiand/zai-org/glm-5.2 "reply with only: ok"You can also test the key directly against ai&:
curl -sS https://api.aiand.com/v1/models \ -H "Authorization: Bearer $AIAND_API_KEY"Invoke-RestMethod https://api.aiand.com/v1/models ` -Headers @{ Authorization = "Bearer $env:AIAND_API_KEY" }Troubleshooting
Section titled “Troubleshooting”- No ai& provider appears — confirm the config file contains
"plugin": ["@aiand/opencode-plugin"], then restart OpenCode so it loads the plugin. - Model picker is empty — the plugin could not fetch
https://api.aiand.com/v1/api.json. Check network access, proxy settings, or setAIAND_BASE_URLif you use a different ai& environment. - Unauthorized request — run
opencode auth loginagain or confirmAIAND_API_KEYis set in the process running OpenCode. - The Desktop app does not see your key — authenticate with
/connectin Desktop, or launch Desktop from a shell whereAIAND_API_KEYis already exported.