This guide shows how to configure OpenCode to use Lunos as your AI provider so you can run coding workflows powered by Lunos models directly from your terminal.
OpenCode is a terminal-based AI coding assistant that runs in your shell. It supports multiple providers through the AI SDK ecosystem and can be extended with subagents for tasks like codebase exploration. Configuration is done via a single JSONC file.
https://api.lunos.tech/v1curl -fsSL https://opencode.ai/install.sh | bash
irm https://opencode.ai/install.ps1 | iex
Check the OpenCode docs for alternative installation methods (Homebrew, Scoop, etc.) if available.
OpenCode reads its config from .config/opencode/opencode.jsonc relative to your home directory.
Create the config directory and file:
mkdir -p ~/.config/opencode
Then create ~/.config/opencode/opencode.jsonc with the following content:
Create the config directory:
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\.config\opencode"
Then create %USERPROFILE%\.config\opencode\opencode.jsonc with the following content:
Paste this into your opencode.jsonc file:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lunos": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.lunos.tech/v1",
"apiKey": "your-lunos-api-key"
},
"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"
}
}
}
Replace "your-lunos-api-key" with your actual Lunos API key.
You can register multiple Lunos models under the same provider:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"lunos": {
"npm": "@ai-sdk/openai-compatible",
"options": {
"baseURL": "https://api.lunos.tech/v1",
"apiKey": "your-lunos-api-key"
},
"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"
}
}
}
From your project directory:
opencode
OpenCode will use the Lunos provider and model specified in your config.
| Field | Description |
|---|---|
provider.lunos.npm |
The AI SDK package for OpenAI-compatible providers |
provider.lunos.options.baseURL |
Lunos API endpoint (https://api.lunos.tech/v1) |
provider.lunos.options.apiKey |
Your Lunos API key |
provider.lunos.models |
Map of model IDs available through this provider |
model |
Default model in provider/model-id format |
agent.explorer |
Subagent config for codebase exploration tasks |
To change the active model, update the "model" field in your config:
"model": "lunos/anthropic/claude-sonnet-4-20250514"
The format is provider-name/model-id — where provider-name matches the key you defined under "provider" (in this case lunos).
OpenCode supports subagents for delegating specific tasks. The example config includes an explorer subagent for fast codebase navigation. You can add more subagents following the same pattern:
"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" field must use the format lunos/model-id (provider prefix + model ID).~/.config/opencode/opencode.jsonc%USERPROFILE%\.config\opencode\opencode.jsonchttps://api.lunos.tech/v1 (with the /v1 suffix).opencode.jsonc to your global .gitignore if it contains secrets:# Linux/macOS
echo ".config/opencode/opencode.jsonc" >> ~/.gitignore_global
# Windows (PowerShell)
Add-Content "$env:USERPROFILE\.gitignore_global" ".config/opencode/opencode.jsonc"
No headings found on this page.
