OpenCode
Open-source terminal coding agent with Melious built in — one env var and the whole catalog shows up
OpenCode is an open-source terminal coding agent from the team behind SST. Model-agnostic — it talks to any provider that speaks OpenAI-compatible Chat Completions (plus Anthropic-shape and a few others through the Vercel AI SDK). Where Claude Code is opinionated and verbose, OpenCode is disciplined: short system prompts, minimal scratchpad chatter, no automatic summarization until it matters — and that design choice shows up directly in your bill. It's the agent we reach for by default on Melious.
Melious is a built-in provider. OpenCode reads its provider list from models.dev and we're in it, so there's no provider block to write and no model list to maintain — export one environment variable and the whole catalog is in the picker.
Setup
Skip the steps with the Melious CLI
The CLI installs OpenCode, writes opencode.json with us as the provider plus every Melious model in the models map, and launches it. One command.
melious tools install opencode
melious launch opencodeIt writes its config to ~/.melious/tool-configs/opencode/opencode.json and points OpenCode at it via the OPENCODE_CONFIG env var, so any opencode.json you already have is left alone. The models map it writes comes from the live /v1/models, so you also get models newer than the registry's snapshot.
Install OpenCode
Use OpenCode's official installer. The universal script works on macOS and Linux:
curl -fsSL https://opencode.ai/install | bashOr a Node.js package manager (any platform, requires Node.js):
npm install -g opencode-ai
bun install -g opencode-ai
pnpm install -g opencode-ai
yarn global add opencode-aiOr a system package manager:
brew install anomalyco/tap/opencode # macOS, Linux (Homebrew)
choco install opencode # Windows (Chocolatey)
scoop install opencode # Windows (Scoop)OpenCode recommends WSL on Windows for the smoothest experience.
Point OpenCode at Melious
Export your key. That's the whole configuration.
export MELIOUS_API_KEY=sk-mel-<YOUR_API_KEY>Our registry entry names MELIOUS_API_KEY as the auth variable and carries the base URL, so OpenCode picks the key up without being told where to look. opencode auth list shows what it found:
┌ Environment
│
● Melious MELIOUS_API_KEY
│
└ 1 environment variableIf you'd rather store the key than keep it in your shell, run opencode auth login and pick Melious from the list.
Every model we serve arrives with that entry — context window, output limit, and per-token price included. opencode models | grep melious prints the set.
Want a default model? opencode.json in your project (or ~/.config/opencode/config.json globally) needs two keys, not a provider block:
{
"$schema": "https://opencode.ai/config.json",
"model": "melious/glm-5.2",
"small_model": "melious/qwen3.5-9b"
}small_model is what OpenCode picks for cheap, fast tasks like title generation; if you skip it, OpenCode falls back to the provider's cheapest. Anything under provider.melious still overrides the registry — reach for it when you want a different base URL or a tighter limit, not to enumerate models.
Run OpenCode
opencodeModel names are namespaced by provider — every Melious model is melious/<MODEL_ID>. Switch with /models inside the TUI, or name one per run:
opencode run -m melious/glm-5.2 "explain this repo's build pipeline"Picking a model
OpenCode works well against any model that handles long tool sequences without losing track. The models hub and GET /v1/models?include_meta=true flag the ones we recommend for agent work, including context length and tool-calling support.
OpenCode's picker shows the whole catalog, with the context window and price it read from the registry. Fair warning: those numbers are a snapshot taken when the registry entry was last updated, so a model we shipped this week can lag by a few days. GET /v1/models is always current.
Cost notes
OpenCode is disciplined about tokens — short system prompts, minimal scratchpad chatter, no auto-summarization until it matters. The cheapest way we've found to do serious agent work. In our own usage it runs noticeably cheaper than Claude Code on the same model — your mileage will vary with the task shape and model choice.
Every response carries environment_impact and billing_cost. OpenCode ignores the extra fields, but your usage dashboard aggregates them.
What's different
- No
modelsmap to maintain. OpenCode reads our catalog from the models.dev registry, so the picker is populated before you write a line of config. The cost is freshness — the registry is a snapshot, and a brand-new model may be missing from it.melious launch opencodewrites a config from the live/v1/modelson every launch, which is the way around that. - Tool-calling on supported models via the OpenAI-compatible
tool_callsschema. Not every open-weight model handles tools — check the models hub for thetool_usecapability flag, or filterGET /v1/models?include_meta=truebycapabilities.tool_use. Streaming,parallel_tool_calls, and strict-mode JSON work where the underlying model supports them. - No explicit cache control. There's no field to mark a prefix as cacheable. Transparent prefix caching still happens on the provider side and shows up as
usage.cached_tokens, billed at the cheaper cache-read rate. See Models.
When it breaks
- Melious missing from
opencode auth list— your local copy of the models.dev catalog predates our entry. OpenCode fetches that catalog at runtime and caches it under~/.cache/opencode/;opencode models --refreshpulls a fresh one. opencode modelsdoesn't list anymelious/models — it only shows providers it can authenticate, so this is almost always an unset or misspelledMELIOUS_API_KEY.opencode auth listtells you which one it is.404 model not found— the model ID doesn't exist on Melious, or you forgot themelious/prefix.GET /v1/modelsto check.- Auth errors — your key was rotated, or the config has an old one. Re-run
melious auth login, thenmelious launch opencodeto rewrite the config. - Rate limit errors during long sessions — you're on a plan with a per-minute token cap and the session's context is big. Rate limits explains which plan lifts which limit.
Errors and retry patterns: Errors.