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

# OpenCode

[OpenCode](https://opencode.ai) is an open-source AI coding agent, available as a terminal-based interface, a desktop app, and an IDE extension. All of them are driven by the same `opencode.json`, so the provider configuration below applies everywhere. OpenCode supports custom OpenAI-compatible providers, so you can add the ScitiX Model Inference API as a provider.

## Configure

### 1. Install OpenCode

<CodeGroup>
  ```bash macOS/Linux (install script) theme={null}
  curl -fsSL https://opencode.ai/install | bash
  ```

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

  ```bash macOS (Homebrew) theme={null}
  brew install anomalyco/tap/opencode
  ```
</CodeGroup>

Arch, Docker, and other install methods are listed in the [official docs](https://opencode.ai/docs/). The install script and Homebrew ship a standalone binary, so no Node.js is required. The npm route needs Node installed.

### 2. Configure the provider

Create an API Key on the [API Keys](https://console.scitix.ai/model-inference/api_keys) page, then edit `~/.config/opencode/opencode.json`, or a project-level `opencode.json`.

Project config overrides global config, and the two are merged. On a fresh machine, create the directory first:

```bash theme={null}
mkdir -p ~/.config/opencode
```

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "model": "scitix/glm-5.2",
  "provider": {
    "scitix": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "ScitiX",
      "options": {
        "baseURL": "https://api.scitix.ai/model-api/v1",
        "apiKey": "{env:SCITIX_API_KEY}"
      },
      "models": {
        "glm-5.2": {
          "name": "ScitiX glm-5.2",
          "limit": { "context": 131072, "output": 8192 }
        }
      }
    }
  }
}
```

Export the key and start OpenCode:

```bash theme={null}
export SCITIX_API_KEY="<Your API Key>"
opencode
```

<Warning>
  An `export` only lasts for the current shell session. In a new terminal, the variable is gone, and `{env:...}` silently resolves to an empty string, so requests fail with an authentication error. To make it permanent, add the export line to `~/.bashrc` or `~/.zshrc`. In CI or containers, inject it as a secret.
</Warning>

| Field                             | Description                                                                                                                                                                       |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`                           | Default model in `provider/model` form. This pins ScitiX so you do not have to pick it each session.                                                                              |
| `provider.scitix.npm`             | Use `@ai-sdk/openai-compatible` for chat-completions APIs like ScitiX.                                                                                                            |
| `provider.scitix.options.baseURL` | ScitiX OpenAI-compatible endpoint: `https://api.scitix.ai/model-api/v1`.                                                                                                          |
| `provider.scitix.options.apiKey`  | Reads from the `SCITIX_API_KEY` environment variable.                                                                                                                             |
| `provider.scitix.models`          | Model IDs to expose, such as `glm-5.2`.                                                                                                                                           |
| `models.*.limit`                  | Context/output token budgets. Built-in providers get these from models.dev automatically, but custom providers must set them manually or OpenCode cannot track remaining context. |

<Warning>
  Use a model with native tool calling support. OpenCode's core workflow relies on it for file and command actions.
</Warning>

## Verify

Run a quick config check:

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

It should list `glm-5.2`.

Then run a non-interactive one-shot task:

```bash theme={null}
opencode run -m scitix/glm-5.2 "introduce this project in one sentence"
```

Or start `opencode` interactively, run `/models`, select **scitix / glm-5.2**, and give it a coding task to confirm tool calls and streaming output work.

## Other Interfaces

* **IDE extension**: in VS Code, Cursor, Windsurf, or VSCodium, the OpenCode extension auto-installs the first time you run `opencode` in the integrated terminal. You can also install **OpenCode** from the marketplace. Quick-launch with `Cmd+Esc` / `Ctrl+Esc`. It runs the same OpenCode with the same config.
* **Web UI**: `opencode web` starts a local server and opens the browser UI. It shares sessions and state with the TUI.

## FAQ

* If the provider does not show up, check the JSON syntax. `opencode.json` can also live in your project root, `.jsonc` is supported, and `OPENCODE_CONFIG` can point to a custom path.
* If authentication fails, confirm that `SCITIX_API_KEY` is exported in the shell that launches `opencode`. An unset environment variable silently becomes an empty string.
