Use OpenCode with Shannon
Add Shannon as a provider in opencode.json and OpenCode plans, edits and runs code on Shannon models.
- Tested Nov 7, 2026
- OpenAI Chat Completions
- About 3 min
About OpenCode
OpenCode is an open-source coding agent with a terminal interface, a desktop app and IDE extensions. It works with many model providers, plans and edits code with its own tools, and keeps sessions you can come back to. A provider block in opencode.json adds Shannon next to the providers you already use.
What you need
- A Shannon API key
- Keys & usage
- Base URL
-
https://api.shannon-ai.com/v1Endpoint:/v1/chat/completions - Every snippet below follows your choice.
Set it up
-
Export your API key
The config reads it as
{env:SHANNON_API_KEY}, so the key stays out of the file.Shellexport SHANNON_API_KEY=YOUR_API_KEY -
Add Shannon as a provider
Put this in
~/.config/opencode/opencode.jsonfor every project, or inopencode.jsonat the root of one project.limit.contexttells OpenCode when to compact the conversation.~/.config/opencode/opencode.json{ "$schema": "https://opencode.ai/config.json", "provider": { "shannon": { "npm": "@ai-sdk/openai-compatible", "name": "Shannon", "options": { "baseURL": "https://api.shannon-ai.com/v1", "apiKey": "{env:SHANNON_API_KEY}" }, "models": { "Kimi-K3-uncensored-NVFP4": { "name": "Kimi-K3-uncensored-NVFP4", "limit": { "context": 1022976, "output": 262144 } } } } }, "model": "shannon/Kimi-K3-uncensored-NVFP4" }
Check that it works
Send: What does this project do?
You should see: OpenCode reads your files and answers; the status line shows shannon/<id>.
Models that fit OpenCode
Every id below meets what OpenCode needs. The first one is the default in the snippets.
| Model id | Context window | Max output | Image input |
|---|---|---|---|
Kimi-K3-uncensored-NVFP4 | 1,022,976 | 262,144 | Yes |
shannon-coder-1 | 131,072 | 65,536 | No |
Kimi-K3.1-Pro-uncensored-NVFP4 | 1,022,976 | 262,144 | Yes |
Kimi-K3-uncensored-3BIT-REAP | 225,280 | 225,280 | Yes |
shannon-3 | 196,608 | 65,536 | Yes |
Model settings
OpenCode asks for these values. They follow the model you picked.
| Setting | Value | Why |
|---|---|---|
limit.context | 1022976 | The model's window; OpenCode compacts before it. |
limit.output | 262144 | The longest answer. |
Good to know
- OpenCode 1.19 reads the
providerblock shown here. The newerproviders/package/settingsform in OpenCode's online schema is skipped by 1.19 ("Omitted native setting") and OpenCode then waits without a model. - In a script, close standard input:
opencode run "…" < /dev/null. Without a terminal,opencode runwaits for input first. - List several ids under
modelsto switch between them with/models.
Tips
- Put the provider in
~/.config/opencode/opencode.jsonto use it in every project, or inopencode.jsonat the project root for one project. - Type
/modelsin the interface to switch between the ids listed under the provider. - Set
limit.contextandlimit.outputfor each model so OpenCode knows when to compact. opencode run "…" < /dev/nullruns one task without the interface, for scripts.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| OpenCode starts and then waits forever | The config uses providers (plural), which this version drops, so no model is selected; or opencode run is waiting on standard input. | Use provider with npm, options and models as above; in scripts add < /dev/null. |
401 | SHANNON_API_KEY is not set where OpenCode starts. | Export it, or write the key into options.apiKey. |
| "Model not found" | The model value does not match a provider and model id. | Write it as shannon/<id>, with the id exactly as listed under models. |
401 Unauthorized | The key is missing, mistyped or rotated. | Copy the key again from Keys & usage; it starts with sk-. |
context_length_exceeded / "prompt is too long" | The conversation is longer than the model's window. | Start a new chat, let the tool compact it, or pick a model with a larger window. |
insufficient_quota | Your balance cannot pay for the request. | Top up or change plan; the request is not retried by itself. |
Questions
Does OpenCode work with Shannon?
Yes, as a custom provider with the @ai-sdk/openai-compatible package and the base URL https://api.shannon-ai.com/v1.
Which model should OpenCode use?
A model with tool calls and a long window, such as Kimi-K3-uncensored-NVFP4; shannon-coder-1 suits shorter tasks.