OpenCode
OpenCode supports OpenAI-compatible providers declared in its configuration file. We declare Kloria there, with the models you want in the picker.
-
Install OpenCode
Fenêtre de terminal curl -fsSL https://opencode.ai/install | bashOr with npm:
npm install -g opencode-ai.Fenêtre de terminal npm install -g opencode-aiScoop (
scoop install opencode) and Chocolatey (choco install opencode) work too. OpenCode recommends WSL on Windows. -
Put your key in an environment variable
Add to your
~/.zshrcor~/.bashrc, then open a new terminal:Fenêtre de terminal export KLORIA_API_KEY="sk-…"Fenêtre de terminal [Environment]::SetEnvironmentVariable("KLORIA_API_KEY", "sk-…", "User") -
Declare Kloria in the configuration
Global file:
~/.config/opencode/opencode.json. You can also put anopencode.jsonat a project’s root, but then without a plain-text key in it.~/.config/opencode/opencode.json {"$schema": "https://opencode.ai/config.json","provider": {"kloria": {"npm": "@ai-sdk/openai-compatible","name": "Kloria","options": {"baseURL": "https://api.kloria.dev/v1","apiKey": "{env:KLORIA_API_KEY}"},"models": {"claude-sonnet-5": { "name": "Claude Sonnet 5" },"claude-opus-5-5": { "name": "Claude Opus 5.5" },"claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },"gpt-6.1-sol": { "name": "GPT-6.1 Sol" },"gpt-5.6-terra": { "name": "GPT-5.6 Terra" }}}},"model": "kloria/claude-sonnet-5"}{env:KLORIA_API_KEY}tells OpenCode to read the key from the environment variable: it’s never written in the file. -
Start OpenCode and check
Fenêtre de terminal opencodeType
/models: the Kloria models appear under the Kloria provider. Pick one and send a message.
Not working?
Section titled “Not working?”| Symptom | Check |
|---|---|
Kloria doesn’t show up in /models |
The JSON is invalid or the file isn’t in the right place. Check the path and syntax (one extra comma is enough). |
| 401 error | KLORIA_API_KEY isn’t visible in this terminal, or the key is invalid. opencode auth list shows saved credentials. |
| “No available channel for model…” | An ID in the models section is wrong. |