> ## 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

> Konfigurasikan OpenCode CLI untuk menggunakan KiosAPI sebagai penyedia backend.

# OpenCode

[OpenCode](https://github.com/opencode-ai/opencode) adalah agen coding AI untuk terminal. Panduan ini menjelaskan cara menyiapkannya dengan KiosAPI.

## Prasyarat

* **Node.js 18+** — periksa dengan `node --version`
* **Kunci API KiosAPI** (diawali dengan `sk-`)

## Instalasi

Instal OpenCode secara global:

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

Verifikasi instalasi:

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

## Konfigurasi

### 1. Atur variabel lingkungan

**Windows (PowerShell):**

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

**macOS / Linux:**

Tambahkan ke `~/.bashrc` atau `~/.zshrc`:

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

Muat ulang shell Anda:

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

### 2. File konfigurasi

Buat atau edit `~/.config/opencode/config.json`:

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

Ganti `sk-xxx` dengan kunci KiosAPI Anda yang sebenarnya.

## Penggunaan

### Mode interaktif

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

### Pertanyaan langsung

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

### Tentukan model

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

> [!TIP]
>
> OpenCode mendukung model kompatibel OpenAI apa pun di KiosAPI. Lihat [daftar model](https://docs.kiosapi.com/id/api-reference/models/list-models.md) untuk opsi yang tersedia.

## Pemecahan Masalah

### Kesalahan Autentikasi

* Pastikan `OPENAI_API_KEY` sudah benar: `echo $OPENAI_API_KEY`
* Pastikan kunci diawali dengan `sk-`
* Periksa bahwa `apiBase` dalam file konfigurasi sesuai dengan variabel lingkungan

### Model Tidak Ditemukan

* Periksa bahwa nama model valid di [halaman model KiosAPI](https://kiosapi.com/pricing)
* Pastikan model termasuk dalam grup token Anda

## Verifikasi Pengaturan

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

## Butuh Bantuan?

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


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