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

# OpenCode

> Configure OpenCode CLI to use KiosAPI as the backend provider.

# OpenCode

[OpenCode](https://github.com/opencode-ai/opencode) is an AI coding agent for the terminal. This guide shows you how to set it up with KiosAPI.

## Prerequisites

* **Node.js 18+** — check with `node --version`
* A **KiosAPI API key** (starts with `sk-`) created in the group matching your models — `Codex-Pro`/`Codex-Plus` for gpt-5.x/gpt-6, `Claude-Kiro` for Claude, `Gemini` for Gemini (see [Choosing a Token Group](https://docs.kiosapi.com/getting-started/token-groups.md))

## Installation

Install OpenCode globally:

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

Verify the installation:

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

## Configuration

### 1. Set environment variables

**Windows (PowerShell):**

```powershell theme={null}
setx OPENAI_API_KEY "sk-xxx"
setx OPENAI_BASE_URL "https://kiosapi.com/v1"
```

**macOS / Linux:**

Add to `~/.bashrc` or `~/.zshrc`:

```bash theme={null}
export OPENAI_API_KEY="sk-xxx"
export OPENAI_BASE_URL="https://kiosapi.com/v1"
```

Reload your shell:

```bash theme={null}
source ~/.bashrc  # or ~/.zshrc
```

### 2. Config file

Create or edit `~/.config/opencode/config.json`:

```json theme={null}
{
  "provider": "openai",
  "apiBase": "https://kiosapi.com/v1",
  "apiKey": "sk-xxx",
  "model": "gpt-5.5"
}
```

Replace `sk-xxx` with your actual KiosAPI key.

## Usage

### Interactive mode

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

### Direct question

```bash theme={null}
opencode "Write a Python script to parse CSV files"
```

### Specify a model

```bash theme={null}
opencode --model gpt-5.5 "Explain this error message"
```

> [!TIP]
>
> OpenCode supports any OpenAI-compatible model on KiosAPI. See the [models list](https://docs.kiosapi.com/api-reference/models/list-models.md) for available options.

## Troubleshooting

### Authentication Error

* Verify `OPENAI_API_KEY` is set correctly: `echo $OPENAI_API_KEY`
* Ensure the key starts with `sk-`
* Check that `apiBase` in the config file matches the environment variable

### Model Not Found

* Check the model name is valid on the [KiosAPI models page](https://kiosapi.com/pricing)
* Ensure the model is included in your token group

## Verify Your Setup

```bash theme={null}
opencode "Say hello"
```

## Need Help?

* [KiosAPI Dashboard](https://kiosapi.com)
* [Available Models](https://docs.kiosapi.com/api-reference/models/list-models.md)


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