How to Configure OpenCode Models for Cheap, Fast Coding

September 21, 2026

OpenCode is unusual among coding agents in that you route different models to different jobs. A cheap model handles boilerplate and search; a frontier model handles the hard plan. Configured well, this cuts a monthly token bill by more than half without losing quality on the tasks that matter.

How does OpenCode choose a model?

OpenCode reads its config from ~/.config/opencode/opencode.json. Each provider block names a provider, its models, and the API key source. You can mark a default model and override it per session with a slash command. There is no hidden router deciding for you — the model used is the one you named, which makes costs predictable.

How do you set a cheap default?

Start cheap and escalate on purpose:

  1. Set a small, fast model as default — something in the Haiku or GPT-mini class.
  2. Keep one frontier model configured for planning and hard debugging.
  3. Switch mid-session when a task stalls: /model anthropic/claude-sonnet.
  4. Add a local model as offline fallback for trivial edits.

The pattern that saves the most money is planning cheap first. Let the small model attempt the change. Escalate only when tests fail twice.

How much can you actually save?

A typical day of light coding uses 200k-500k tokens. Run entirely on a frontier model that is $2-$6. Mix in a cheap default for the 70% of turns that are reads, searches, and small edits, and the same day lands closer to $0.80-$2.00. That is a 60-70% cut for work that rarely needed the big model.

Should you run models locally?

For autocomplete-like edits and commit messages, a local 7B-14B model on a modern laptop is fine and free. For repo-wide refactors it is frustrating: small models lose context and invent file paths. Keep local as the fallback, not the primary. If you already run droid on your own keys, the same key file can serve both tools.

What breaks?

Two gotchas. First, model names change often — a stale config silently fails or falls back. Second, mixing providers means mixing context limits; a 128k-context plan does not fit in a 32k local model. Pin explicit context windows in config so a large file does not blow the request size limit mid-task.

Quick Summary

  • OpenCode config lives at ~/.config/opencode/opencode.json.
  • Set a cheap small model as default, keep a frontier model for planning.
  • Mixing models can cut a day’s spend from ~$2-$6 to ~$0.80-$2.00.
  • Local models work for trivial edits but fail on repo-wide work.
  • Pin context limits — provider switching can break large tasks.

Last updated September 2026.