opencode

Cut Your opencode Token Costs by 40–70%

opencode is the most-starred open-source terminal coding agent — provider-agnostic and bring-your-own-key, so every token is billed straight to you. Terse auto-detects the opencode process, compresses every prompt before it reaches the model, and tracks per-turn cost. All on-device.

40–70%prompt compression
Autoopencode detection
Any providermodel-aware cost tracking
0data leaves device

How Terse Works with opencode

opencode runs an agentic loop: it reads your repo, edits files, and runs commands, feeding every diff and command output back into context each turn. That context — and the bill on your own API key — grows fast. Terse compresses what it can (your typed prompts) and flags what you shouldn't ignore: the same files being re-read turn after turn.

Terminal — opencode Session
Terse Active
$ opencode
opencode · provider: anthropic · model: claude-sonnet-4-5 · repo indexed
● Terse detected opencode — monitoring (Sonnet 4.5 · $3.00/M input)
> could you please go ahead and update the payment webhook handler so that it retries on failure and also i think we should probably add some logging around it just to be safe
Terse: 38 tokens → 15 tokens · "update payment webhook handler to retry on failure, add logging" · 60% reduction
opencode reading: src/payments/webhook.ts [2,480 tokens]
⚠ Terse: payments/webhook.ts read 3× this session — it's already in context, re-read is wasted tokens
12.6Kprompt tokens
34.1Kwithout Terse
63%compressed
$0.05this turn

Auto opencode Detection

Terse scans running processes every 5 seconds. When opencode launches in your terminal, a floating monitor bar appears automatically — no plugin, no config, no changes to opencode itself.

Automatic
🗜️

Prompt Compression

Every instruction you type into opencode's prompt goes through Terse's 7-stage pipeline: typo correction, filler removal, hedge stripping, and phrase shortening. Code blocks and file paths pass through unchanged.

7-Stage Pipeline
📁

Redundant File Read Flagging

opencode's agentic loop re-reads files as it edits — often the same file several times per session. Terse tracks this and warns when a file has already been read, so you can stop it re-loading context it already has.

Session Tracking
🔀

Provider-Agnostic Cost Tracking

opencode works with Claude, GPT, Gemini, OpenRouter, or a local model. Terse reads whichever model is active and tracks per-turn cost at that provider's real rate. Switch providers mid-project and the numbers follow.

Per-Turn Visibility
📊

Session Cost Summary

At the end of each opencode session, Terse shows total token usage, total cost on your own API key, and a breakdown of where tokens went — prompts, file reads, command output. Know exactly what drove the bill.

Session Analytics
🔒

100% On-Device

Terse reads your terminal input via OS Accessibility APIs and compresses locally in Rust. No prompt text, no code, and no file contents are ever sent to Terse's servers — fitting for an open-source, self-hosted workflow.

Zero Cloud

Supported opencode Providers

opencode is provider-agnostic, and so is Terse. It tracks token costs and monitors sessions regardless of which model you point opencode at — directly or through OpenRouter.

Claude Sonnet 4.5
$3/M input · $15/M output
Claude Opus 4
$15/M input · $75/M output
GPT-4o
$2.50/M input · $10/M output
Gemini 2.5 Pro
$1.25/M input · $10/M output
GPT-4o mini
$0.15/M input · $0.60/M output
Gemini 2.5 Flash
$0.075/M input · $0.30/M output
Claude Haiku 4.5
$0.80/M input · $4/M output
Local (Ollama)
Token count monitoring · no cost tracking

Frequently Asked Questions

Everything about using Terse with opencode.

Does Terse work with opencode?
Yes. Terse scans running processes every 5 seconds. When opencode launches in your terminal, Terse detects it and activates a floating monitor bar — no plugin and no changes to opencode. It reads the active provider and model, so cost tracking works whether you're on Claude, GPT, Gemini, or a local model.
Why is my opencode session so expensive?
opencode is agentic — each turn it reads files, runs commands, and applies diffs, then feeds that output back into context for the next turn. That context accumulates every turn, and since you supply your own API key, the growth bills straight to you. Terse compresses your typed prompts and flags redundant file reads so the context doesn't snowball unnoticed.
Which providers and models does Terse track?
All of them that opencode supports. Point opencode at Claude Sonnet/Opus, GPT-4o, Gemini 2.5, an OpenRouter model, or a local model via Ollama, and Terse reads the active model and shows per-turn cost at that model's real input/output rate. Change providers mid-project and the tracking follows automatically.
Does Terse interfere with opencode's agentic editing?
No. Terse only compresses the prompts you type into the terminal input. It never touches opencode's file edits, the commands it runs, the diffs it applies, or the context it builds. Your agentic loop runs exactly as before — you just send shorter, cleaner instructions into it.

Also Works With

Terse reduces token costs across every major terminal coding agent.

Claude Code 🧰 Aider — Terminal Pair Programmer 🤖 Codex CLI — Terminal Agent Gemini CLI — Terminal Agent

Stop Burning Tokens on Verbose Prompts

30-day free trial. No credit card required until your trial ends. Works with any provider opencode uses — Claude, GPT, Gemini, and local models.

Start Free Trial — macOS Calculate Your Savings