BETA

Docs
Instructions

How to connect OpenCode to Apily

OpenCode is an open-source terminal agent. Its provider system uses @ai-sdk/openai-compatible, which speaks the standard OpenAI chat protocol — exactly what Apily serves.

Tool
OpenCode OpenAI-compatible
Base URL
https://apily.pro/v1
Key
apily_your-api-key
Config file
opencode.json (project or ~/.config/opencode/)

Configuration

Declare the provider in opencode.json — in the project root or globally in ~/.config/opencode/opencode.json:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "apily": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Apily",
      "options": {
        "baseURL": "https://apily.pro/v1",
        "apiKey": "{env:APILY_API_KEY}"
      },
      "models": {
        "gpt-5.6-sol": { "name": "GPT-5.6 Sol" },
        "claude-opus-5": { "name": "Claude Opus 5" },
        "deepseek-v4-flash-0731": { "name": "DeepSeek V4 Flash" }
      }
    }
  }
}
  1. Add the block above to opencode.json, keeping your key out of the file — {env:APILY_API_KEY} reads it from the environment.
  2. Export the key:
    terminal
    export APILY_API_KEY=apily_your-api-key
  3. Restart opencode. The models you listed appear in the model picker under Apily.

Switching models

Add or remove entries under models and pick one in the TUI. The @ai-sdk/openai-compatible driver targets /v1/chat/completions, which Apily serves for the whole catalog — check the current list on the Models page or with GET /v1/models.

Common errors and how to fix them

SymptomCauseFix
401 Invalid API keyKey not exported, or wrong value.Export APILY_API_KEY in the same shell and restart.
Provider not found / npm errorThe @ai-sdk/openai-compatible package is not resolvable.Ensure npm: "@ai-sdk/openai-compatible" is set exactly; OpenCode fetches it on demand.
404 Not foundBase URL missing /v1.Base URL: https://apily.pro/v1 — every request must land on a path Apily serves (/chat/completions, /responses, /models, …).
503 Model temporarily unavailableThe model exists, but no upstream provider is reachable right now.Retry in a moment — it usually recovers within a minute. Switch models if it keeps happening.