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

# OpenCode

> Add the AI Reserve gateway to OpenCode as a custom provider — one JSON block, every gateway model.

<Card title="Create your API key →" icon="key" href="https://portal.aireserve.com/profile#api-keys" horizontal>
  Mint an `aireserve_api_…` key in the portal — every OpenCode session is then
  metered and billed through your organization.
</Card>

OpenCode takes custom providers in `opencode.json` — globally at
`~/.config/opencode/opencode.json` or per project
([OpenCode's provider docs](https://opencode.ai/docs/providers/)). One
OpenAI-compatible block serves every gateway model, Claude included:

```json theme={"dark"}
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "aireserve": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "AI Reserve",
      "options": {
        "baseURL": "https://api.aireserve.com/v1",
        "apiKey": "{env:AIRESERVE_API_KEY}"
      },
      "models": {
        "gpt-5.4-mini": { "name": "AI Reserve GPT-5.4 Mini" },
        "claude-sonnet-4-6": { "name": "AI Reserve Claude Sonnet 4.6" }
      }
    }
  }
}
```

The `{env:…}` reference keeps the secret out of the file — export the key and
run:

```bash theme={"dark"}
export AIRESERVE_API_KEY="aireserve_api_…"   # your key
opencode                                     # models appear under "AI Reserve"
```

Model ids in the `models` map must match the gateway's ids exactly — the
list is one `GET https://api.aireserve.com/v1/models` away.

## Verify

Run a one-shot prompt against the provider you just added:

```bash theme={"dark"}
opencode run -m aireserve/gpt-5.4-mini "Reply with exactly: gateway-ok"
```

The reply streams back through the gateway, and the request appears on your
[usage page](https://portal.aireserve.com/profile) — metered against your
key.
