Connect OpenCode

OpenCode can use the Arena API as a custom OpenAI-compatible provider. Point OpenCode at https://api.preview.arena.ai/v1, add your Arena API key through env-backed config, and use arena/auto or arena/fast in OpenCode.

1. Create an Arena API key

  1. Open the Keys page and create a new key.
  2. Set your gateway URL and Arena API key as environment variables.
export ARENA_GATEWAY_URL=https://api.preview.arena.ai
export ARENA_API_KEY=<your-arena-key>

2. OpenCode config

Add this to opencode.json in your project root, or merge it into your existing OpenCode config. OpenCode reads placeholders like {env:ARENA_API_KEY} from your shell environment when it starts.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "arena": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Arena API",
      "options": {
        "baseURL": "{env:ARENA_GATEWAY_URL}/v1",
        "apiKey": "{env:ARENA_API_KEY}"
      },
      "models": {
        "auto": { "name": "Arena Auto (balanced quality + speed)" },
        "fast": { "name": "Arena Fast (optimized for latency)" }
      }
    }
  }
}

OpenAI reasoning models

For gpt-5.5 and gpt-5.4, change "npm" to "@ai-sdk/openai" so OpenCode targets /v1/responses instead of /v1/chat/completions. The default @ai-sdk/openai-compatible provider only speaks chat/completions, which these models reject when tools and reasoning are combined.

3. Select the model in OpenCode

After saving your opencode.json, restart OpenCode and run the /models command. You will see the Arena models listed under the arena provider.

Select arena/auto or arena/fast from the list. OpenCode will remember your selection for future sessions.

You can also set a default model in your config so you don't have to select it each time:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "arena/auto"
}

4. Verify the gateway connection

Before debugging OpenCode itself, confirm your key works directly against the gateway.

curl https://api.preview.arena.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ARENA_API_KEY" \
  -d '{
    "model": "auto",
    "messages": [
      {"role": "user", "content": "Say hello in exactly five words"}
    ],
    "max_tokens": 64
  }'

Routing modes

arena/auto is the balanced default for most tasks. arena/fast prioritizes lower latency for interactive workloads.

Arena API — Dashboard