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

# OpenCode

> Configure OpenCode to use LinkModel chat models through an OpenAI-compatible provider.

OpenCode can use custom OpenAI-compatible providers. Configure LinkModel with the `/v1` base URL and explicit model entries.

<Note>
  OpenCode v2 uses the `providers` object, `package`, and `settings.baseURL`. Older OpenCode examples may use `provider`, `npm`, and `options.baseURL`.
</Note>

## Configure

Set your API key:

```bash theme={null}
export LINKMODEL_API_KEY="<YOUR_API_KEY>"
```

Create or update `opencode.json` in your project:

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "model": "linkmodel/gpt-5.3-codex",
  "providers": {
    "linkmodel": {
      "name": "LinkModel",
      "env": ["LINKMODEL_API_KEY"],
      "package": "@opencode-ai/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "https://api.linkmodel.ai/v1"
      },
      "models": {
        "gpt-5.3-codex": {
          "name": "GPT-5.3 Codex",
          "modelID": "gpt-5.3-codex",
          "capabilities": {
            "tools": true,
            "input": ["text"],
            "output": ["text"]
          }
        },
        "claude-opus-4-7": {
          "name": "Claude Opus 4.7",
          "modelID": "claude-opus-4-7",
          "capabilities": {
            "tools": true,
            "input": ["text"],
            "output": ["text"]
          }
        },
        "deepseek-v4-pro": {
          "name": "DeepSeek V4 Pro",
          "modelID": "deepseek-v4-pro",
          "capabilities": {
            "tools": true,
            "input": ["text"],
            "output": ["text"]
          }
        }
      }
    }
  }
}
```

Start OpenCode:

```bash theme={null}
opencode
```

Use `/models` and select a `linkmodel/*` model.

## Notes

* Keep API keys in environment variables. Do not commit them in `opencode.json`.
* Add more models from [Models](/models) as needed.
* If your OpenCode version expects the older config shape, use the official OpenCode provider docs linked below.

## Official Reference

* [OpenCode Providers](https://opencode.ai/v2/docs/providers)
* [OpenCode Config](https://opencode.ai/v2/docs/config)
