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

# OpenAI Codex CLI

> Konfigurasikan OpenAI Codex CLI untuk menggunakan KiosAPI sebagai penyedia backend.

# OpenAI Codex CLI

[OpenAI Codex CLI](https://github.com/openai/codex) adalah agen coding baris perintah dari OpenAI. Panduan ini menjelaskan cara mengonfigurasikannya agar berfungsi dengan KiosAPI.

## Persyaratan Sistem

| Persyaratan | Minimum | Direkomendasikan |
| - | - | - |
| **Sistem Operasi** | macOS 12+, Ubuntu 20.04+, atau Windows 11 (WSL2) | — |
| **RAM** | 4 GB | 8 GB |
| **Node.js** | 22+ | LTS terbaru |
| **Ruang Disk** | 200 MB | 500 MB |

## Instalasi

Instal Codex CLI secara global melalui npm:

```bash theme={null}
npm i -g @openai/codex
```

Atau melalui Homebrew (macOS/Linux):

```bash theme={null}
brew install codex
```

Verifikasi instalasi:

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

## Dapatkan Kunci API Anda

1. Masuk ke [Dashboard KiosAPI](https://kiosapi.com)
2. Buka **Token Management**
3. Buat atau salin kunci API yang ada (diawali dengan `sk-`)
4. Pilih grup **`Codex-Pro`** (0.04×) atau **`Codex-Plus`** (0.02×) — cek grup mana yang mencakup model yang kamu mau di halaman [harga](https://kiosapi.com/pricing)
5. Simpan dan salin kuncinya (diawali `sk-`)

> [!WARNING]
>
> Token di grup yang salah tidak bisa memanggil model Codex. Lihat [Memilih Grup Token](https://docs.kiosapi.com/getting-started/token-groups.md).

## Konfigurasi

### 1. Buat file konfigurasi

Buat `~/.codex/config.toml`:

```toml theme={null}
[model_providers.kiosapi]
name = "KiosAPI"
base_url = "https://kiosapi.com/v1"
wire_api = "responses"
env_key = "KIOSAPI_KEY"

[profiles.kiosapi]
model = "gpt-5.5"
model_provider = "kiosapi"
```

> [!NOTE]
>
> Pengaturan `wire_api = "responses"` memberi tahu Codex agar menggunakan format Responses API OpenAI, yang didukung KiosAPI.

### 2. Atur variabel lingkungan

Atur kunci KiosAPI Anda sebagai variabel lingkungan `KIOSAPI_KEY`.

**Windows (PowerShell):**

```powershell theme={null}
setx KIOSAPI_KEY "sk-xxx"
```

**macOS / Linux:**

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

```bash theme={null}
export KIOSAPI_KEY="sk-xxx"
```

Kemudian muat ulang:

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

## Penggunaan

### Mode interaktif

```bash theme={null}
codex
```

### Pertanyaan langsung

```bash theme={null}
codex "Explain how async/await works in Python"
```

### Menggunakan profil KiosAPI

```bash theme={null}
codex --profile kiosapi "Write a function to reverse a linked list"
```

## Plugin VSCode

Codex juga tersedia sebagai [ekstensi VSCode](https://marketplace.visualstudio.com/items?itemName=openai.codex). Setelah memasangnya, konfigurasikan KiosAPI dengan variabel lingkungan yang sama di pengaturan VSCode atau terminal Anda.

> [!WARNING]
>
> Ekstensi VSCode membaca variabel lingkungan dari shell Anda. Pastikan `KIOSAPI_KEY` diekspor di shell yang menjalankan VSCode, atau atur di terminal terintegrasi.

## Konfigurasi Lanjutan

### Mode CI Noninteraktif

Untuk pipeline CI/CD, jalankan Codex dalam mode noninteraktif:

```bash theme={null}
codex --quiet --auto-approve "Fix the failing test in tests/auth.test.js"
```

| Flag | Deskripsi |
| - | - |
| `--quiet` | Menyembunyikan prompt interaktif |
| `--auto-approve` | Menyetujui perubahan file secara otomatis |
| `--json` | Menghasilkan output sebagai JSON |

### Server MCP

Codex mendukung server [Model Context Protocol (MCP)](https://modelcontextprotocol.io) untuk akses alat tambahan. Tambahkan server MCP di `~/.codex/config.toml`:

```toml theme={null}
[mcp.filesystem]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]

[mcp.github]
command = "npx"
args = ["-y", "@modelcontextprotocol/server-github"]
env = { GITHUB_PERSONAL_ACCESS_TOKEN = "ghp_xxx" }
```

## Pemecahan Masalah

### Kesalahan Autentikasi (401)

* Pastikan `KIOSAPI_KEY` sudah benar: `echo $KIOSAPI_KEY`
* Pastikan kunci diawali dengan `sk-`
* Periksa bahwa `env_key` di konfigurasi sesuai dengan nama variabel lingkungan

### Model Tidak Ditemukan

* Pastikan nama model di profil Anda benar
* Periksa model yang tersedia pada [halaman harga KiosAPI](https://kiosapi.com/pricing)

### Kesalahan Koneksi

* Pastikan `base_url` adalah `https://kiosapi.com/v1` (dengan `/v1`)
* Periksa koneksi jaringan dan pengaturan firewall Anda

## Verifikasi Pengaturan

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

## Butuh Bantuan?

* [Dashboard KiosAPI](https://kiosapi.com)
* [Memilih Grup Token](https://docs.kiosapi.com/getting-started/token-groups.md)
* [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.