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

# OpenCode

> Route OpenCode through the Inference.net gateway with inf opencode.

`inf opencode` routes OpenCode through `https://api.inference.net/v1`. All three catalog models are registered in the provider registry, so you can switch models inside OpenCode without re-running `on`.

## Config file

`inf` writes fields in `~/.config/opencode/opencode.json` (JSON). If `XDG_CONFIG_HOME` is set, `inf` uses that root. `inf` owns fields, not the whole file. `$schema` and every other key stay untouched.

## `inf opencode on`

<Metadata text="cli/coding-agents/opencode/on-default[series=coding_agents_opencode]" />

```bash theme={"system"}
inf opencode on
```

| Flag              | Required | Description            | Default        |
| ----------------- | -------- | ---------------------- | -------------- |
| `--model <alias>` | No       | Default OpenCode model | `kimi-k3-fast` |

See [Model mapping](/cli/coding-agents#model-mapping) for supported aliases and limits.

## What gets written

`provider.inference` is an object with npm package `@ai-sdk/openai-compatible`, name `Inference.net`, options (`baseURL` and `apiKey` as a secret), and a `models` map. `model` is set to `inference/<selected alias>`.

The three registry entries are `glm-5.2-fast`, `kimi-k3-fast`, and `deepseek-v4-flash-0731`. `glm-5.2-fast` carries `limit.context` of 262,144.

<Metadata text="cli/coding-agents/opencode/provider-json" />

```json theme={"system"}
{
  "provider": {
    "inference": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Inference.net",
      "options": {
        "baseURL": "https://api.inference.net/v1",
        "apiKey": "<gateway-key>"
      },
      "models": {
        "glm-5.2-fast": {
          "name": "glm-5.2-fast",
          "limit": { "context": 262144, "output": 128000 }
        },
        "kimi-k3-fast": {
          "name": "kimi-k3-fast",
          "limit": { "context": 1048576, "output": 131072 }
        },
        "deepseek-v4-flash-0731": {
          "name": "deepseek-v4-flash-0731",
          "limit": { "context": 1048575, "output": 384000 }
        }
      }
    }
  },
  "model": "inference/kimi-k3-fast"
}
```

## `inf opencode status`

<Metadata text="cli/coding-agents/opencode/status[series=coding_agents_opencode]" />

```bash theme={"system"}
inf opencode status
```

## `inf opencode off`

<Metadata text="cli/coding-agents/opencode/off[series=coding_agents_opencode]" />

```bash theme={"system"}
inf opencode off
```

`off` restores unchanged owned fields. It keeps fields that you edited after `on`.

## Examples

Select the Fast-tier alias:

<Metadata text="cli/coding-agents/opencode/on-model[series=coding_agents_opencode]" />

```bash theme={"system"}
inf opencode on --model glm-5.2-fast
```

Restart OpenCode after `on` or `off`. See [Troubleshooting](/cli/coding-agents/troubleshooting) for drift, recovery, and key revocation.
