# OpenCode Setup Guide

> Configure OpenCode as an OpenAI-compatible provider through opencode.json to connect LLMoxy.

Website: [https://opencode.ai (click to open)](https://opencode.ai)

OpenCode is an open-source terminal / editor agent. Use `@ai-sdk/openai-compatible` for custom providers, and don't borrow built-in vendor names such as `google`.

Before you start, get an [LLMoxy token](https://en.llmoxy.com/docs/get-started/get-token). The **auto** group is recommended.

## Connect to LLMoxy

Write this in your project root or in `~/.config/opencode/opencode.json`:

```json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "llmoxy/grok-4.7",
  "provider": {
    "llmoxy": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "LLMoxy",
      "options": {
        "baseURL": "https://llmoxy.com/v1",
        "apiKey": "your LLMoxy API Key"
      },
      "models": {
        "grok-4.7": { "name": "Grok 4.7" },
        "claude-opus-5-5": { "name": "Claude Opus 5.5" }
      }
    }
  }
}
```

| Field | Description |
| --- | --- |
| `options.baseURL` | `https://llmoxy.com/v1`; don't append `/chat/completions` |
| `options.apiKey` | LLMoxy token; you can also use `{env:LLMOXY_API_KEY}` |
| Keys under `models` | Must match the LLMoxy model IDs exactly |
| Top-level `model` | `provider-ID/model-ID`, for example `llmoxy/grok-4.7` |

After starting OpenCode, use `/models` to pick a model under `LLMoxy`.

> **💡 Tip**
> If you previously ran `opencode auth login openai`, the built-in `openai` provider may be hijacked by OAuth. For custom providers, use a separate ID (such as `llmoxy`) and don't reuse `openai`.

This is the markdown version of https://en.llmoxy.com/docs/code-tutorials/opencode.
