Jump straight to the numbers

← All articles

$10.08 for 10,000 Code Explanations: A Sample Receipt

01 / A $10.08 receipt, with the assumptions visible

A beginner’s code explainer does not need an autonomous agent, a repository crawler, or six model calls per question. Start with one small job: accept a pasted function and return a plain-English explanation. Under the illustrative rates below, 10,000 explanations plus 500 retries would cost $10.08 in model usage.

That is a planning example, not a CheapRelay price quote or a measured benchmark. The rates and token counts are explicit assumptions. Replace them with your selected model’s current prices and actual usage before committing a budget.

  • ■ Input price assumption: $0.30 per million tokens.
  • ■ Output price assumption: $1.20 per million tokens.
  • ■ Average request: 1,200 input tokens and 500 output tokens.
  • ■ Traffic: 10,000 initial requests, plus a 5% retry allowance.
  • ■ Cache reads and writes: none assumed in this example.

02 / Build one explanation screen, not a coding agent

The first version needs a code box, an optional language selector, an Explain button, and a response panel. Keep the API key on your server. The browser sends code to your backend; your backend checks the request, calls the model, and returns the explanation.

Ask for four sections: what the code does, how its main steps work, one example input and output, and one thing a beginner might misunderstand. Tell the model to explain unfamiliar terms on first use and distinguish observed behavior from guesses about the programmer’s intent.

Treat pasted code as untrusted content, not instructions. Do not execute it. Avoid automatic follow-up calls in the initial release: they complicate both the security boundary and the receipt.

03 / Give each explanation a 1,700-token planning envelope

Allocate the assumed 1,200 input tokens across instructions, pasted code, and the user’s question. For example, reserve 250 for instructions, 850 for code, and 100 for the question. These are budgeting targets, not reliable character-to-token conversions; tokenization varies by language and content.

Set an output ceiling around 600 tokens while budgeting for a 500-token average. A ceiling controls the maximum response, not its typical length. Reject oversized submissions or ask the reader to paste a smaller function rather than silently removing code that could change the explanation.

CheapRelay provides an OpenAI-compatible API under https://api.cheapapirelay.com/v1, so an existing OpenAI SDK integration can use that base URL. Keep the model configurable rather than hard-coding it throughout the application. Gemini 2.5 Flash is one available option to evaluate; the illustrative prices here are not a claim about its current rate.

04 / Print the receipt before adding extra features

  • ■ Input per explanation: 1,200 × $0.30 ÷ 1,000,000 = $0.00036.
  • ■ Output per explanation: 500 × $1.20 ÷ 1,000,000 = $0.00060.
  • ■ Total per explanation: $0.00096.
  • ■ 10,000 initial explanations: $9.60.
  • ■ 500 additional full-size retry calls: $0.48.
  • ■ Illustrative model-usage total: $10.08.

The retry line assumes each additional call consumes the same average tokens as a normal explanation. It is a conservative planning allowance, not a statement that every failed request is billed. Hosting, storage, taxes where applicable, and developer time are outside this receipt.

CheapRelay bills per real token, including cache reads and writes, with no monthly fee or subscription. If you enable caching, add its actual usage and rates as separate receipt lines. Do not quietly treat cached tokens as free.

05 / Measure 100 requests before buying complexity

Log input tokens, output tokens, model, retry count, and calculated cost without storing users’ source code by default. Review 100 representative submissions for correctness, understandable vocabulary, and unsupported claims. This is a suggested evaluation batch, not a proven quality threshold.

Add per-user limits, a server-side spending cutoff, and at most one automatic retry for transient failures. Sign up for CheapRelay when you are ready to test the integration, then replace every assumed receipt line with observed usage. The useful milestone is not the cheapest individual answer; it is a clear explanation with a cost you can reproduce.

Sign up Try the prices yourself, sign-up credit included.

More reading

DateAisleWritten inTitle
2026-10-26Cheap how-tosEN$13.66 for 10,000 AI Requests: A Backend Receipt
An illustrative AI proxy receipt, plus practical controls for API keys, retries, token limits, logging, and spending caps.
2026-10-26Cheap how-tosEN$5.20 to Triage 10,000 Emails: A Two-Model Receipt
An illustrative email-triage bill: small-model first, 10% big-model fallback, and the token math behind a $5.20 total.
2026-10-26Cheap how-tosEN$12 debugging receipt for a 400 model not found
Trace a model-not-found error through the base URL, model ID and client configuration, with a clear receipt for time and test-token costs.
2026-10-26Cheap how-tosEN$0.09 for 100 English Edits: An Example Receipt
A sample token receipt for an English writing assistant, with clear pricing assumptions, practical prompts, and limits that keep costs predictable.
2026-10-26Cheap how-tosEN¥0.60 Credit: A 95-Request Test Receipt
A practical ¥0.60 test budget: 95 illustrative API requests, a six-fen reserve, and clear limits on what a sign-up credit can prove.
2026-10-26Cheap how-tosENFour Few-Shot Examples: A $200 Prompt Receipt
A token-by-token receipt for zero, two, four and eight examples, plus a break-even test for deciding which prompts earn their cost.