Panduan ini menunjukkan cara mengkonfigurasi OpenCode agar menggunakan Lunos sebagai provider AI sehingga Anda bisa menjalankan workflow coding bertenaga model Lunos langsung dari terminal.
OpenCode adalah asisten coding AI berbasis terminal yang berjalan di shell Anda. OpenCode mendukung berbagai provider melalui ekosistem AI SDK dan bisa diperluas dengan subagent untuk tugas seperti eksplorasi codebase. Konfigurasi dilakukan lewat satu file JSONC.
https://api.lunos.tech/v1curl -fsSL https://opencode.ai/install.sh | bash
irm https://opencode.ai/install.ps1 | iex
Cek dokumentasi OpenCode untuk metode instalasi alternatif (Homebrew, Scoop, dll.) jika tersedia.
OpenCode membaca konfigurasi dari .config/opencode/opencode.jsonc relatif terhadap home directory Anda.
Buat direktori dan file konfigurasi:
mkdir -p ~/.config/opencode
Lalu buat file ~/.config/opencode/opencode.jsonc dengan isi berikut:
Buat direktori konfigurasi:
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.config\opencode"
Lalu buat file %USERPROFILE%\.config\opencode\opencode.jsonc dengan isi berikut:
Paste ini ke file opencode.jsonc Anda:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lunos": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.lunos.tech/v1",
"apiKey": "api-key-lunos-anda"
},
"models": {
"deepseek/deepseek-v4-flash": {
"name": "deepseek/deepseek-v4-flash"
}
}
}
},
"model": "lunos/deepseek/deepseek-v4-flash",
"agent": {
"explorer": {
"description": "Fast explorer subagent for codebase exploration",
"mode": "subagent",
"model": "lunos/deepseek/deepseek-v4-flash"
}
}
}
Ganti "api-key-lunos-anda" dengan API key Lunos Anda yang sebenarnya.
Anda bisa mendaftarkan beberapa model Lunos di provider yang sama:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lunos": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.lunos.tech/v1",
"apiKey": "api-key-lunos-anda"
},
"models": {
"deepseek/deepseek-v4-flash": {
"name": "deepseek/deepseek-v4-flash"
},
"anthropic/claude-sonnet-4-20250514": {
"name": "anthropic/claude-sonnet-4-20250514"
},
"openai/gpt-4o": {
"name": "openai/gpt-4o"
}
}
}
},
"model": "lunos/deepseek/deepseek-v4-flash",
"agent": {
"explorer": {
"description": "Fast explorer subagent for codebase exploration",
"mode": "subagent",
"model": "lunos/deepseek/deepseek-v4-flash"
}
}
}
Dari direktori project Anda:
opencode
OpenCode akan menggunakan provider dan model Lunos yang ditentukan di konfigurasi Anda.
| Field | Deskripsi |
|---|---|
provider.lunos.npm |
Paket AI SDK untuk provider OpenAI-compatible |
provider.lunos.options.baseURL |
Endpoint API Lunos (https://api.lunos.tech/v1) |
provider.lunos.options.apiKey |
API key Lunos Anda |
provider.lunos.models |
Map model ID yang tersedia melalui provider ini |
model |
Model default dalam format provider/model-id |
agent.explorer |
Konfigurasi subagent untuk tugas eksplorasi codebase |
Untuk mengubah model aktif, update field "model" di konfigurasi:
"model": "lunos/anthropic/claude-sonnet-4-20250514"
Formatnya adalah nama-provider/model-id — di mana nama-provider sesuai dengan key yang Anda definisikan di "provider" (dalam hal ini lunos).
OpenCode mendukung subagent untuk mendelegasikan tugas tertentu. Contoh konfigurasi sudah menyertakan subagent explorer untuk navigasi codebase yang cepat. Anda bisa menambahkan subagent lain dengan pola yang sama:
"agent": {
"explorer": {
"description": "Fast explorer subagent for codebase exploration",
"mode": "subagent",
"model": "lunos/deepseek/deepseek-v4-flash"
},
"reviewer": {
"description": "Code review subagent",
"mode": "subagent",
"model": "lunos/anthropic/claude-sonnet-4-20250514"
}
}
"model" harus menggunakan format lunos/model-id (prefix provider + model ID).~/.config/opencode/opencode.jsonc%USERPROFILE%\.config\opencode\opencode.jsonchttps://api.lunos.tech/v1 (dengan suffix /v1).opencode.jsonc ke .gitignore global jika berisi secret:# Linux/macOS
echo ".config/opencode/opencode.jsonc" >> ~/.gitignore_global
# Windows (PowerShell)
Add-Content "$env:USERPROFILE\.gitignore_global" ".config/opencode/opencode.jsonc"
Tidak ada judul di halaman ini.
