Coding agents
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). Of the five agents the Melious CLI launches, it's the one we recommend.
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.
With the Melious CLI
With the Melious CLI installed and signed in, two commands take you from nothing to a session:
melious tools install opencode
melious launch opencodeFor OpenCode, tools install prints the installer command rather than running it — the install script on macOS and Linux, npm install -g opencode-ai on Windows (which needs Node.js and npm). Run that line yourself, then launch from inside your project.
The first launch in a project asks Trust this workspace? The agent runs as you, with your Melious key, so Melious asks before handing it over; the answer defaults to no. Workspace trust covers what a grant means and how to revoke it.
Melious generates an opencode.json in its own directory on every launch and points OpenCode at it with OPENCODE_CONFIG: Melious as the only enabled provider, your main and lightweight models, and a models map from the live /v1/models. An inline overlay in OPENCODE_CONFIG_CONTENT re-pins the base URL and key reference, so a project's own opencode.json can't send your key elsewhere; your existing OpenCode config is otherwise left alone. Models, -- passthrough, and exit status: launching a coding agent.
Manual setup (alternative)
For when you'd rather not use the Melious CLI. OpenCode already knows Melious as a provider, so this is mostly one environment variable.
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/<MODEL_ID>",
"small_model": "melious/<LIGHTWEIGHT_MODEL_ID>"
}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/<MODEL_ID> "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.
Usage reporting
OpenCode streams over Chat Completions, so environment_impact and billing_cost arrive on the final usage chunk of each stream. 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 OpenCode is still holding an old one. With the CLI, re-run
melious auth login; the nextmelious launch opencodepasses the new key. Manually, re-exportMELIOUS_API_KEYor runopencode auth loginagain. - 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.