Skip to Content

OpenCode Setup

OpenCode  is an open-source terminal AI coding tool, similar to an open-source alternative to Claude Code. With OfoxAI, you can use any model.

Setup Steps

1. Install OpenCode

# macOS / Linux curl -fsSL https://opencode.ai/install | bash # Or install with Go go install github.com/opencode-ai/opencode@latest

2. Configure Environment Variables

OpenCode supports multiple provider configurations. We recommend using OpenAI compatible mode:

~/.zshrc
# OpenAI compatible mode export OPENAI_API_KEY=<your OFOXAI_API_KEY> export OPENAI_BASE_URL=https://api.ofox.ai/v1

If you primarily use Claude models, you can configure Anthropic mode instead:

~/.zshrc
export ANTHROPIC_API_KEY=<your OFOXAI_API_KEY> export ANTHROPIC_BASE_URL=https://api.ofox.ai/anthropic

3. Configuration File

You can also configure via OpenCode’s config file:

~/.config/opencode/config.toml
[providers.ofoxai] api_key = "<your OFOXAI_API_KEY>" base_url = "https://api.ofox.ai/v1" [models.default] provider = "ofoxai" model = "anthropic/claude-sonnet-4.5"

4. Verify

opencode "Hello, how are you?"
ScenarioModelDescription
Daily codinganthropic/claude-sonnet-4.5Balanced performance
Complex tasksanthropic/claude-opus-4.6Most capable reasoning
Quick tasksmoonshotai/kimi-k2.5Low cost, high speed

OpenCode’s configuration options may change with version updates. See the OpenCode official documentation  for the latest information.

Last updated on