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

# OpenCode

> Install OpenCode and declare Triw as a custom provider.

OpenCode is a terminal agent with a config-driven provider system. Anything OpenAI-compatible can be declared in `opencode.json` / `opencode.jsonc`.

## Requirements

| Item | Note |
| - | - |
| OS | macOS, Linux, Windows (WSL recommended) |
| Node | 20+ if installed through npm |

## Install

```bash install script theme={null}
curl -fsSL https://opencode.ai/install | bash
```

```bash npm theme={null}
npm install -g opencode-ai
```

```bash Homebrew theme={null}
brew install sst/tap/opencode
```

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

## Configure

Config lives at `~/.config/opencode/opencode.jsonc` (global) or `./opencode.json` (project). Current schema uses a `providers` object:

```jsonc ~/.config/opencode/opencode.jsonc theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "triw": {
      "name": "Triw",
      "env": ["TRIW_API_KEY"],
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "https://router.triw.io/v1"
      },
      "models": {
        "claude-sonnet-4-5": { "name": "Claude Sonnet 4.5" },
        "gpt-4o-mini": { "name": "GPT-4o mini" }
      }
    }
  }
}
```

```bash theme={null}
export TRIW_API_KEY="sk-..."
```

| Field | Purpose |
| - | - |
| `env` | Ordered env vars that may hold the credential |
| `package` | Runtime provider package for an OpenAI-compatible endpoint |
| `settings.baseURL` | The Triw endpoint |
| `models` | Model ids you want in the picker |

## Select a model

Models are addressed as `<provider>/<model>`:

```bash theme={null}
opencode --model triw/claude-sonnet-4-5
```

Inside the TUI, `/models` lists what you declared; `/connect` is for catalog providers.

## Verify

Ask for something that requires a tool call ("list files in this directory"). Then confirm the entry in Triw **Logs**.

## Troubleshooting

| Symptom | Cause | Fix |
| - | - | - |
| Provider missing from picker | Wrong key: `provider` instead of `providers` | Use the `providers` object |
| `Cannot find module` | Wrong `package` value | Use `@opencode/ai/providers/openai-compatible` |
| Model id rejected | Id not declared under `models` | Add it, or copy the exact id from `/v1/models` |
| 404 on every call | `baseURL` without `/v1` | `https://router.triw.io/v1` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.