OpenCode

Add AivoKey as an OpenCode provider.

Use OpenCode with any model on AivoKey.

Step 1 — Save your key in an environment variable

export AIVOKEY_API_KEY="sk-aivo_..."

(Add it to ~/.bashrc or ~/.zshrc to keep it. On Windows use setx AIVOKEY_API_KEY "..." and open a new terminal.)

Step 2 — Add AivoKey as a provider

Edit ~/.config/opencode/opencode.json (global) or opencode.json in your project folder:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "aivokey": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "AivoKey",
      "options": {
        "baseURL": "https://api.aivokey.dev/v1",
        "apiKey": "{env:AIVOKEY_API_KEY}"
      },
      "models": {
        "deepseek-v4-pro": { "name": "deepseek-v4-pro" }
      }
    }
  },
  "model": "aivokey/deepseek-v4-pro"
}
  • baseURL includes /v1.
  • {env:AIVOKEY_API_KEY} reads the key from step 1, so it never sits in the file.
  • model is written as aivokey/<model id>.

Step 3 — Run OpenCode

opencode

Type /models to see and switch between the models you added.

Adding more models

Add one line per model to models, using ids from Models:

"models": {
  "deepseek-v4-pro": { "name": "DeepSeek V4 Pro" },
  "glm-5.3": { "name": "GLM 5.3" }
}

Web search

OpenCode uses its own search tool. Turn it on when you start OpenCode:

OPENCODE_ENABLE_EXA=1 opencode

AivoKey does not charge for it — see Web search & fetch.

Common problems

  • Model not found — the id in model must match a key under models exactly, with the aivokey/ prefix only in model.
  • 401 — AIVOKEY_API_KEY is not set in the terminal that started OpenCode.

More fixes: Troubleshooting.