$1 Budget: OpenCode With Pay-Per-Token Billing
Set a $1 spending target for your first OpenCode experiment. That is a personal limit, not a quoted package price or a claim about how much credit you can buy. Your actual cost depends on the model, tokens processed, and work you request. The practical goal is simple: connect a backend, finish one small task, and check the bill before continuing.
OpenCode brings an AI coding assistant into your terminal. With a pay-per-token backend, you pay for usage instead of committing to a monthly subscription. That makes small experiments possible, but it also means a long conversation or repeated tool calls can keep adding charges.
01 / Set the $1 target before connecting OpenCode
CheapRelay provides one API key for multiple model families, with no monthly fee or subscription. Billing follows real token usage, including cache reads and writes. Sign up for CheapRelay, then check the available funding amounts and current model rates before adding credit.
If the minimum funding amount exceeds $1, distinguish your account balance from your experiment budget. Keeping $5 in an account, for example, does not make $5 your intended session spend. Check whether the service offers a spending limit you can enable; a number written in your notes will not stop API requests.
For this walkthrough, consider DeepSeek V4 Flash, then verify its current input, output, and cache prices. A model name alone does not establish what your session will cost.
02 / Install OpenCode and open a small project
With Node.js and npm installed, run this command in your terminal:
npm install -g opencode-ai
Run opencode --version to confirm installation. Then change into a small project directory. Prefer a disposable project or a repository with a clean Git working tree so you can inspect and reverse edits easily.
Keep credentials outside the project. In Bash, run the following command and enter your relay key when prompted. The hidden prompt keeps the key out of the command text saved in shell history:
read -r -s -p 'CheapRelay API key: ' CHEAPRELAY_API_KEY; export CHEAPRELAY_API_KEY; printf '\n'
This variable lasts for the current shell session. Start OpenCode from that same terminal.
03 / Point OpenCode at the relay’s /v1 endpoint
Create an opencode.json file in the project root. The following configuration defines a custom OpenAI-compatible provider. Replace MODEL_ID in both places with the exact API model identifier supplied by CheapRelay; the display name and API identifier may differ.
{"provider":{"cheaprelay":{"npm":"@ai-sdk/openai-compatible","name":"CheapRelay","options":{"baseURL":"https://api.cheapapirelay.com/v1","apiKey":"{env:CHEAPRELAY_API_KEY}"},"models":{"MODEL_ID":{"name":"DeepSeek V4 Flash"}}}},"model":"cheaprelay/MODEL_ID"}
The /v1 suffix matters here because this configuration uses OpenAI-compatible routes. Save the file, run opencode, and confirm the selected provider and model. If configuration validation fails, check the custom-provider instructions for your installed OpenCode version before changing settings at random.
For authentication errors, check that the environment variable is available in the launching shell. For an unknown-model error, check the exact model identifier. Never paste your API key into a troubleshooting conversation.
04 / Buy one small result before a longer session
Give the assistant a narrow first request: “Read the README only and suggest one clearer sentence. Do not edit files or run commands.” This checks the connection with limited work, although OpenCode may still send system instructions and other context.
After the response, inspect usage and billing in the relay dashboard. Then try one bounded edit, such as correcting that sentence. Review the diff yourself.
- ■ Name the file and desired change explicitly.
- ■ Ask for a short response when you only need a small answer.
- ■ Review tool permissions before allowing commands or edits.
- ■ Check spending after each of your first few requests.
05 / Turn the first receipt into your next limit
Calculate costs using the published billing units. With per-million-token pricing, each category costs its token count divided by 1,000,000, multiplied by its rate. Include output and applicable cache categories; avoid counting cached tokens twice if the dashboard separates them.
Use that first receipt to decide whether another task fits your remaining $1 target. Fresh conversations can reduce accumulated history, but rereading files also costs tokens. Keep the task small, inspect the result, and expand only when the bill supports it.
Sign up Try the prices yourself, sign-up credit included.
More reading
| Date | Aisle | Written in | Title |
|---|---|---|---|
| 2026-10-29 | Coding agents, cheaply | EN | Review 1 Small Diff Before Spending More A beginner workflow for getting useful AI code review on a tiny budget, with a fixed token cap and focused questions. |
| 2026-10-29 | Coding agents, cheaply | EN | A $5 Coding Agent Memory File Can Cost More A beginner guide to coding agent memory files, token costs, cache billing, and a tiny-budget workflow that keeps context useful. |
| 2026-10-29 | Coding agents, cheaply | EN | 4 Slash Commands for a Tiny Claude Code Budget A beginner-friendly Claude Code routine using /clear, /compact, /cost, and /context to control token spending. |
| 2026-10-29 | Coding agents, cheaply | EN | A $10 Shared AI Budget for a Tiny Coding Team A beginner-friendly setup for sharing AI coding tools across a small team while keeping usage visible, flexible, and capped. |
| 2026-10-29 | Coding agents, cheaply | EN | $1 Cherry Studio Budget, Several Models, One Key Connect Cherry Studio to CheapRelay, add two models with one key, and track token costs with a $1 practice budget. |
| 2026-10-29 | Coding agents, cheaply | EN | $1 Test Budget: Connect Cursor to a Custom API Connect Cursor to an OpenAI-compatible endpoint, verify the model, and keep your first API test small with a $1 spending target. |