# OpenCode

> Connecting OpenCode to the gateway through an OpenAI-compatible provider in opencode.json.

OpenCode works through `/v1/chat/completions` in the OpenAI format.

## Quick start

Put your key from the cabinet in the `AISELLER_API_KEY` environment variable —
the config below reads it from there:

```bash
export AISELLER_API_KEY="your-key"
```

Add the provider to `~/.config/opencode/opencode.json` (or to `opencode.json`
in a project root — then the setting applies only there):

```json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "aiseller": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "ai-seller",
      "options": {
        "baseURL": "https://ai-seller.vibe-codes.ru/v1",
        "apiKey": "{env:AISELLER_API_KEY}"
      },
      "models": {
        "gpt-5.6-sol": { "name": "gpt-5.6-sol" }
      }
    }
  },
  "model": "aiseller/gpt-5.6-sol"
}
```

Run `opencode`. The `aiseller` provider name is arbitrary; the model is set as
`aiseller/<catalog ID>`.

## Choosing a model

List the IDs from the [catalog](https://ai-seller.vibe-codes.ru/en/docs/models) you want to use under `models` —
OpenCode shows them in the `/models` command. The `model` field sets the
default.

## How it works

- The `@ai-sdk/openai-compatible` package sends requests to
  `/v1/chat/completions` with your key; usage shows up in the cabinet.
- OpenCode's tools (reading and editing files, shell commands) are your own
  functions — the gateway passes them to the model as is.

## Troubleshooting

| Symptom | Cause and fix |
| --- | --- |
| The model is missing from `/models` | It is not listed in `provider.aiseller.models` — add its ID. |
| `401 invalid_api_key` | `AISELLER_API_KEY` is not set in this terminal, or the key is revoked. |
| `404 model_not_found` | The model ID has a typo — check `GET /v1/models`. |
