OpenCode coding agent on SovereignEG
Goal: run OpenCode (an open-source terminal coding agent, similar to Claude Code) with SovereignEG as the model provider.
Time: 10 minutes.
OpenCode supports "custom providers" through the @ai-sdk/openai-compatible adapter — any server with /v1/chat/completions works, including SovereignEG.
Step 1 — Install
# Linux / macOS / WSL
curl -fsSL https://opencode.ai/install | bash
# or with npm (all platforms)
npm install -g opencode-ai
# Windows
scoop install opencode # or: choco install opencodeCheck: opencode --version
Step 2 — Put your key in the environment
export SOVEREIGNEG_API_KEY="sk-..." # Linux / macOS$env:SOVEREIGNEG_API_KEY = "sk-..." # Windows PowerShellStep 3 — Create the config
Create opencode.json in your project folder (project config — simplest, works on every OS), or put it in ~/.config/opencode/opencode.json to use it in every project (global config, Linux/macOS).
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"sovereigneg": {
"npm": "@ai-sdk/openai-compatible",
"name": "SovereignEG",
"options": {
"baseURL": "https://backend.sovereigneg.com/v1",
"apiKey": "{env:SOVEREIGNEG_API_KEY}"
},
"models": {
"SovereignEG/Qwen3.8-27B-FP8": {
"name": "SovereignEG/Qwen3.8-27B-FP8 (SovereignEG)",
"limit": { "context": 131072, "output": 8192 }
}
}
}
},
"model": "sovereigneg/SovereignEG/Qwen3.8-27B-FP8"
}What each part means:
| Key | Meaning |
|---|---|
provider.sovereigneg | The provider id you will see in /models. Any name works |
npm | @ai-sdk/openai-compatible = "talk OpenAI chat-completions format" |
options.baseURL | https://backend.sovereigneg.com/v1 |
options.apiKey | {env:NAME} reads the key from an environment variable — never write the key into the file |
models | Only the models you list appear in the picker. Use the exact ids from /v1/models |
limit.context | Lets OpenCode manage the context window and compaction |
model (top level) | Default model in the form provider/model-id |
Step 4 — Run it
cd your-project
opencodeInside OpenCode:
/models— check that SovereignEG is listed and pick a model (from a normal terminal,opencode modelsprints the same list)./init— makes anAGENTS.mddescribing your repo (commit it).- Type a task: "Add input validation to the signup form and write a test."
/undoand/redo— roll back or restore file changes.
Step 5 — Add more SovereignEG models
Copy any id from the model list into the models block:
curl -H "Authorization: Bearer $SOVEREIGNEG_API_KEY" https://backend.sovereigneg.com/v1/modelsTroubleshooting
| Problem | Fix |
|---|---|
Provider missing from /models | JSON is invalid, or the file is in the wrong folder. Run opencode from the folder that holds opencode.json |
401 | SOVEREIGNEG_API_KEY is not set in the same terminal you launched opencode from |
400 model_not_found | The model key inside models must be the exact id from /v1/models |
| Tool calls fail / model just talks | Pick a model that supports tools (supports_tools: true in /v1/models) |
| Answers get cut off | Raise limit.output |
Next: Hermes Agent