Melious
Integrations

OpenCode

Open-source terminal coding agent, pre-configured by the Melious CLI

OpenCode

OpenCode is an open-source terminal coding agent from the team behind SST. Model-agnostic — configured through opencode.json, 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.

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 opencode

It writes its config to $MELIOUS_CONFIG/opencode/opencode.json and points OpenCode at it via the OPENCODE_CONFIG env var, so any opencode.json you already have is left alone.

Install OpenCode

Use OpenCode's official installer. The universal script works on macOS and Linux:

curl -fsSL https://opencode.ai/install | bash

Or 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-ai

Or 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

Create opencode.json in your project (or ~/.config/opencode/config.json for a global default).

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "melious/<MODEL_ID>",
  "small_model": "melious/<SMALL_MODEL_ID>",
  "provider": {
    "melious": {                                                                  
      "npm": "@ai-sdk/openai-compatible",                                         
      "name": "Melious",                                                          
      "options": {                                                                
        "baseURL": "https://api.melious.ai/v1",                                   
        "apiKey": "{env:MELIOUS_API_KEY}"
      },                                                                          
      "models": {                                                                 
        "<MODEL_ID>": {                                                           
          "name": "<Display Name>",                                               
          "limit": { "context": 128000, "output": 16384 }                         
        }                                                                         
      }                                                                           
    }                                                                             
  }
}

The npm field points at the @ai-sdk/openai-compatible provider package — OpenCode auto-installs it on first run. 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. limit.context and limit.output size the prompt window inside the picker UI; check the models hub for each model's real context length.

The models map is not auto-discovered from /v1/models. Without an entry, OpenCode refuses to resolve a melious/<id> model at startup. List one entry per model you plan to use, or let the Melious CLI write the file for you on each launch — it pulls the live list from /v1/models?include_meta=true and populates the map.

Run OpenCode

export MELIOUS_API_KEY=sk-mel-<YOUR_API_KEY>
opencode

Model names are namespaced by provider — every Melious model is melious/<MODEL_ID>.

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 own model picker only surfaces what you've added to the models map in opencode.json.

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

  • Model picker only lists what's in your config. To surface more Melious models, add them to the models map in opencode.json, or let the CLI overwrite the file next time you run melious launch opencode.
  • Tool-calling on supported models via the OpenAI-compatible tool_calls schema. Not every open-weight model handles tools — check the models hub for the tool_use capability flag, or filter GET /v1/models?include_meta=true by capabilities.tool_use. Streaming, parallel_tool_calls, and strict-mode JSON work where the underlying model supports them.
  • No prompt caching. OpenAI-shape caching isn't uniform across open-weight providers, and we don't expose a synthetic one.

When it breaks

  • 404 model not found — the model ID doesn't exist on Melious, or you forgot the melious/ prefix. GET /v1/models to check.
  • Auth errors — your key was rotated, or the config has an old one. Re-run melious auth login, then melious launch opencode to 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.

On this page