Skip to content

OpenCode

OpenCode is an open-source AI coding agent that can be configured to use custom API endpoints.

Official Websitehttps://opencode.ai

Use CC-Switch to quickly set it up with 3xCoder.

Installation

Install OpenCode via npm:

bash
npm install -g opencode

Or use npx:

bash
npx opencode

The easiest way to configure OpenCode with 3xCoder is through CC-Switch:

  1. Run CC-Switch:
bash
npx cc-switch@latest
  1. Select OpenCode as the target tool
  2. Enter your 3xCoder settings:
SettingValue
Base URLhttps://api.3xcoder.com/v1
API KeyYour 3xCoder key (sk-...)
  1. Click Apply
  2. Launch OpenCode — it will use the 3xCoder endpoint

Manual Configuration

If you prefer manual configuration, set environment variables:

powershell
$env:OPENAI_BASE_URL = "https://api.3xcoder.com/v1"
$env:OPENAI_API_KEY = "sk-your-api-key-here"
opencode
bash
export OPENAI_BASE_URL="https://api.3xcoder.com/v1"
export OPENAI_API_KEY="sk-your-api-key-here"
opencode

To make this permanent, add the export lines to your shell profile (~/.bashrc, ~/.zshrc, or $PROFILE).

Usage

Once configured, OpenCode works like any other AI coding assistant:

bash
opencode

It will connect to 3xCoder and use the available models for code generation, editing, and analysis.

Troubleshooting

opencode: command not found

  • Ensure Node.js is installed: node -v
  • Reinstall: npm install -g opencode
  • Check that npm global bin is in your PATH

Connection errors

  • Verify your API key works: curl https://api.3xcoder.com/v1/models -H "Authorization: Bearer sk-your-key"
  • Check the base URL has no trailing slash
  • Restart OpenCode after changing configuration

3xCoder — Unified AI API Endpoint