> ## Documentation Index
> Fetch the complete documentation index at: https://docs.opper.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode

> Run SST's open-source terminal coding agent on any model in the Opper catalog

[OpenCode](https://opencode.ai) is SST's open-source terminal coding agent (MIT, [source](https://github.com/anomalyco/opencode)). It reads a provider block from its config file, so Opper slots in as one more provider.

## Setup

<Tip>
  One command, no config files:

  ```bash theme={null}
  npx @opperai/cli launch opencode
  ```

  This writes the Opper provider block into `~/.config/opencode/opencode.json` and starts OpenCode.
</Tip>

To wire it by hand, add an `opper` provider to `~/.config/opencode/opencode.json`:

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "opper": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Opper",
      "options": {
        "baseURL": "https://api.opper.ai/v3/compat",
        "apiKey": "{env:OPPER_API_KEY}"
      },
      "models": {
        "anthropic/claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
        "openai/gpt-5.5": { "name": "GPT-5.5" }
      }
    }
  }
}
```

```bash theme={null}
export OPPER_API_KEY=your-opper-api-key
opencode
```

<Warning>
  If `opencode.json` already exists, merge the `opper` block into it rather than overwriting the file — replacing it wholesale drops any other providers you have configured.
</Warning>

## Choosing a model

Use `/model` inside a session to switch. The picker lists whatever the provider block exposes; model IDs follow the `provider/model` convention from the [catalog](/capabilities/models).

## Troubleshooting

<AccordionGroup>
  <Accordion title="401 Unauthorized">
    `OPPER_API_KEY` has to be exported in the shell that launches OpenCode. Opper keys start with `op-`.
  </Accordion>

  <Accordion title="The provider block disappeared">
    `opper launch opencode` merges its entry alongside your existing providers rather than replacing the file, so re-running it restores the Opper block without touching the rest.
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="Opper CLI" icon="terminal" href="/developer-tools/cli">
    Every agent the CLI can launch.
  </Card>

  <Card title="All integrations" icon="plug" href="/integrations/overview">
    Every app that runs on Opper.
  </Card>
</CardGroup>
