Amux AI

OpenCode

Last updated August 26, 2026

Point OpenCode at Amux with a custom OpenAI-compatible provider in opencode.json.

OpenCode is a coding agent that runs in your terminal. It speaks the OpenAI protocol and its provider list is extensible, so a custom entry pointing at Amux is all it takes.

CC Switch supports OpenCode — add a provider with https://gateway.amux.ai/v1 as the Base URL, without editing JSON manually. Open a fresh terminal after switching.

The manual route is below.

1. Install

curl -fsSL https://opencode.ai/install | bash
# or
npm i -g opencode-ai@latest

2. Create an Amux key

Create one on the keys page in the console. The key remains viewable there after creation, so you do not need to rotate it just to retrieve it again.

export AMUX_API_KEY=your Amux key

Put it in ~/.zshrc or ~/.bashrc.

3. Configure

Add this to opencode.json in your project directory:

opencode.json

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "amux": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Amux",
      "options": {
        "baseURL": "https://gateway.amux.ai/v1",
        "apiKey": "{env:AMUX_API_KEY}"
      },
      "models": {
        "anthropic/claude-opus-5": {
          "name": "Claude Opus 5"
        },
        "openai/gpt-5.6": {
          "name": "GPT-5.6"
        },
        "deepseek/deepseek-v3.2": {
          "name": "DeepSeek V3.2"
        }
      }
    }
  }
}
FieldNotes
npm@ai-sdk/openai-compatible targets /v1/chat/completions. For /v1/responses, use @ai-sdk/openai; both endpoints are implemented natively
options.baseURLKeep the /v1; the client appends the path directly
options.apiKeyUse {env:NAME} to reference an environment variable. Do not inline the key — this file usually gets committed
modelsOnly what is listed here shows up in the model picker. Keys are canonical IDs

4. Start and verify

source ~/.zshrc
cd my-project
opencode

Then, inside it:

/models

Seeing the models you listed means the configuration was read. Pick one and send a message.

Choosing models

Whatever is under models is what you can pick. Names are canonical IDs and are not limited to OpenAI's models — anthropic/claude-opus-5 and deepseek/deepseek-v3.2 work too, with conversion handled for you.

To pin a provider or choose a routing strategy, append a colon to the model ID (anthropic/claude-opus-5:anthropic, :@price) — see the API reference. The models key then has to be the full suffixed form.

Troubleshooting

Amux models do not appear under /models

The configuration file was not read. OpenCode reads opencode.json from the current working directory, so starting it elsewhere misses it. Check the JSON is valid too — one stray comma invalidates the whole file.

Authentication failure

echo $AMUX_API_KEY

Empty means the variable referenced by {env:AMUX_API_KEY} was never exported, or the terminal predates it. If it has a value, check the key is still enabled in the console and the workspace has balance.

Cannot connect

curl https://gateway.amux.ai/v1/models -H "Authorization: Bearer $AMUX_API_KEY"

A model list coming back means the network and the key are fine.

The model reports as unsupported

npm is set to @ai-sdk/openai-compatible (Chat Completions) while the model's upstream only serves Responses, or the other way around. Each model's page lists the protocols actually available for it — change the model or the npm field.