Skip to main content

OpenCode Setup

OpenCode is an open-source AI coding agent that runs in your terminal, similar to Claude Code.

Prerequisites

  • OpenCode installed (install guide)
  • Your API key and endpoint URL from admin

Installation

curl -fsSL https://opencode.ai/install | bash

Setup

1

Create Config Directory

mkdir -p ~/.opencode-pro
2

Create Config File

Create ~/.opencode-pro/opencode.json:
{
  "$schema": "https://opencode.ai/config.json",
  "model": "antigravity/claude-opus-4-5-20250514",
  "provider": {
    "antigravity": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Antigravity",
      "options": {
        "baseURL": "https://gateway.classicgroup.asia/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "claude-opus-4-5-20250514": {
          "name": "Claude Opus 4.5"
        },
        "claude-sonnet-4-5-20250514": {
          "name": "Claude Sonnet 4.5"
        }
      }
    }
  }
}
Use @ai-sdk/openai-compatible provider - native Anthropic provider won’t work with custom endpoints.
3

Create Shell Alias

Add to your ~/.zshrc or ~/.bashrc:
alias opencode-pro='OPENCODE_CONFIG_DIR=~/.opencode-pro opencode'
Then reload:
source ~/.zshrc
4

Launch and Test

opencode-pro
The bottom of the screen should show “Claude Opus 4.5 Antigravity”.

Switching Models

Inside OpenCode, type /models to see available models and switch between them.

Available Models

Model IDDescription
antigravity/claude-opus-4-5-20250514Most capable, complex tasks
antigravity/claude-sonnet-4-5-20250514Fast, great for coding

Troubleshooting

  • Make sure opencode.json exists in the config directory
  • Check the model field is set to antigravity/claude-opus-4-5-20250514
  • Verify you’re using the alias that sets OPENCODE_CONFIG_DIR
  • Use @ai-sdk/openai-compatible provider, not native anthropic
  • This routes through OpenAI-compatible endpoint which works reliably
  • Make sure the config file is valid JSON
  • Check the npm field is exactly @ai-sdk/openai-compatible
  • Ensure OPENCODE_CONFIG_DIR is set correctly in your alias
  • Check JSON syntax is valid