$0.37 for an OpenCode Session: An Example Receipt
01 / A $0.37 receipt, not a promised session price
A terminal coding assistant does not have a fixed cost per task. The bill depends on how much context it sends, how much text it generates, how often it retries, and whether repeated context qualifies for caching. OpenCode is the interface; the backend’s token accounting determines the charge.
Here is a worked receipt for one hypothetical session: $0.37 across 990,000 billed tokens. These are deliberately illustrative rates and token counts, not CheapRelay’s published prices, a measured benchmark, or a prediction for your repository. Check the selected model’s current rates before spending.
02 / The four lines behind the $0.37 total
Assume the session’s billing record separates ordinary input, cache reads, cache writes, and output into non-overlapping categories. All example rates below are in dollars per million tokens.
- ■ Ordinary input: 120,000 tokens at $1.00 per million = $0.120.
- ■ Cache reads: 800,000 tokens at $0.10 per million = $0.080.
- ■ Cache writes: 40,000 tokens at $1.25 per million = $0.050.
- ■ Generated output: 30,000 tokens at $4.00 per million = $0.120.
- ■ Total: 990,000 tokens and $0.370.
The arithmetic is tokens divided by 1,000,000, multiplied by the applicable rate. Keeping three decimal places on each receipt line makes this example easy to audit. Actual billing can retain more precision than the displayed balance.
The 990,000 tokens are cumulative across requests, not a claim that one request contained that much context. An agent can resend repository instructions, conversation history, and file contents several times while editing and testing.
03 / Cache reads explain more than the headline token count
In this example, cache reads account for roughly 81% of all tokens but only eight cents. Output accounts for roughly 3% of tokens yet costs twelve cents. A single blended token count would hide that difference.
For a narrow arithmetic comparison, suppose the same 960,000 input-side tokens were all charged at the example’s $1.00 ordinary-input rate. Input would cost $0.96; adding $0.12 of output gives $1.08. That is $0.71 more than the example receipt.
This is not a promised caching discount. It holds token volume constant and changes only the assumed billing categories. Real cache eligibility, retention, minimum lengths, and write accounting depend on the backend and model. Do not assume every repeated file becomes a cheap cache read, or count cache-write tokens twice when reconciling usage.
04 / Point OpenCode at the relay before running the task
CheapRelay provides a pay-as-you-go backend with no monthly fee or subscription. It bills real token usage, including cache reads and writes, so those categories belong in your budget rather than in a footnote.
In OpenCode, configure a custom provider using its supported OpenAI-compatible provider mechanism. Use https://api.cheapapirelay.com/v1 as the API base, supply your relay key through the supported secret or environment-variable mechanism, and select the exact model identifier shown by the service. Configuration fields can vary by OpenCode release; follow the documentation for your installed version rather than copying an outdated provider block.
Keep the key out of repository files. First send a short test request, then check that usage appears under the intended model and credential. Successful authentication alone does not establish the eventual task cost.
05 / Make the next receipt smaller and easier to audit
- ■ Start with one bounded change: one failing test or one function, not an unrestricted repository cleanup.
- ■ Exclude generated files, dependency directories, and irrelevant logs from context where your workflow allows it.
- ■ Inspect tool results before another attempt. Repeating a failing command can add context without moving the task forward.
- ■ Record opening balance, closing balance, model identifier, and usage categories. Separate other API activity during the measurement.
Sign up for CheapRelay if you want to try this pay-per-token workflow, then measure one small OpenCode task before expanding it. The useful number is not a universal price per coding session. It is your reconciled receipt for a specific change.
Sign up Try the prices yourself, sign-up credit included.
More reading
| Date | Aisle | Written in | Title |
|---|---|---|---|
| 2026-10-26 | Coding agents, cheaply | EN | $0.1325 for a focused Codex run: a sample receipt A worked Codex receipt shows how tighter scope, smaller tool output, and deliberate stopping points can reduce token spending. |
| 2026-10-26 | Coding agents, cheaply | EN | $0.0685 and $0.195: two shell-chore receipts Two illustrative shell-task receipts show how input, output and cache charges add up in Gemini CLI and Claude Code. |
| 2026-10-26 | Coding agents, cheaply | EN | $2.28 for 100 Code Reviews: An Illustrative Receipt A transparent token-cost receipt for 100 AI-assisted code reviews, with retry costs, spending limits, and a workflow that keeps context small. |
| 2026-10-26 | Coding agents, cheaply | EN | $1.50 a Day Just to Repeat Your Agent’s Memory A token-by-token receipt for coding agent memory files, with hypothetical rates, cache math, and a practical way to measure the trade-off. |
| 2026-10-26 | Coding agents, cheaply | EN | $0.84 Saved by Clearing Unrelated Claude Code Tasks A worked Claude Code token receipt: when /clear saves money, what /compact costs, and why cache billing can change the result. |
| 2026-10-26 | Coding agents, cheaply | EN | $13 of Usage, $7 of Headroom: A Tiny-Team AI Receipt A three-developer coding assistant budget with token math, cache charges, shared configuration, and safeguards against surprise spending. |