Jump straight to the numbers

← All articles

Software 0 Cents, AI Capped at 40,000 Tokens

01 / Free tools first, then one hard token cap

This plan builds a small receipt-sorting script over one weekend. The software side costs nothing: Python 3, a text editor, git and a terminal are either already installed or free to install. That leaves one line item on the receipt, and it is the only one you control by counting: tokens.

Before writing code, set a hard cap of 40,000 tokens for the whole weekend. Not an estimate you hope to beat, a ceiling you stop at. Split it like this:

  • ■ 12,000 tokens for building, which is roughly 25 to 35 short requests while you fix syntax, prompt wording and JSON formatting
  • ■ 20,000 tokens for the real test run across 20 receipts, about 800 to 1,000 tokens per receipt round trip including the response
  • ■ 8,000 tokens held in reserve for one extra debugging session on Sunday

Those three lines add up to 40,000 exactly. If your counter hits the cap before the script works, you stop and finish on another weekend. That rule is what keeps a beginner project from turning into an open-ended bill.

For the metered side, use a pay-as-you-go relay instead of a subscription. CheapRelay charges per real token, including cache reads and cache writes, with no monthly fee and no subscription. Sign up at cheapapirelay.com, create one key, and store it in an environment variable called CHEAPRELAY_API_KEY; every line after that is usage you can count.

02 / One boring input folder and one narrow JSON shape

Pick the smallest possible project. Open your last 20 grocery, hardware or coffee receipts, paste each one into a plain text file, and save them in a folder called receipts. Twenty files is enough to expose edge cases and small enough that you can read every output by hand.

Now fix the output format before you write any code. The script should emit one JSON object per receipt with exactly these fields:

  • ■ store, a single string
  • ■ date, in YYYY-MM-DD form, or null when the receipt does not show one
  • ■ total, a number with two decimals, or null when it is unclear
  • ■ category, one of groceries, hardware, dining, transport, other
  • ■ line_items, at most five short strings, empty when the receipt is unreadable

The narrow shape matters more than the feature list. Every extra field is extra output tokens on all 20 runs, and every extra field is one more thing that breaks the JSON. Skip PDF parsing, skip screenshots, skip a database and skip a web page. A folder of text files in and one results.json out is the whole product.

Start with a model listed on sale, Claude Haiku 4.5, and keep temperature at zero so repeated runs of the same receipt give you comparable output while you debug. You can swap the model name later without touching anything else, which is the point of using one relay key across many models.

03 / Wire the script with the OpenAI SDK in six steps

The cheapest way to start is the tooling most examples already use: the OpenAI Python SDK pointed at a different base URL. Do the setup in this order.

  • ■ Install the client with pip install openai, which is free and takes under a minute
  • ■ Set CHEAPRELAY_API_KEY in your shell so the key never sits inside the script file
  • ■ Set the base URL to https://api.cheapapirelay.com/v1, the OpenAI-compatible routes
  • ■ Create one chat completion call with the model name, a system message and a single user message containing the receipt text
  • ■ Request JSON output and parse it with json.loads inside a try block, so one malformed response does not kill the run
  • ■ Write the parsed object to results.json and print one line per receipt so you can watch progress

That same key also works with Claude Code, Codex, Gemini CLI and any OpenAI SDK, so the script you write on Saturday is not a dead end. If you later want a model with native Gemini routes, they live under /v1beta on the same host. Nothing else in the project changes.

Keep the script under 80 lines. A beginner file you can read top to bottom on Sunday night is worth more than a package structure, and it burns far fewer tokens while you debug, because you paste less context into each question.

04 / Token hygiene: stable prompts, capped output, real logs

Most beginner overspending comes from the prompt, not the model. Write one system message of about 220 words that defines the five fields, the category list and the null rules. Keep it byte-identical across all calls. Two reasons: it keeps your results consistent, and a stable repeated prefix is what can land on cache reads on later runs.

Cache is not free, though. CheapRelay bills cache reads and cache writes as real tokens, so treat a cache write as part of your budget rather than a hidden saving. If you change one word in the system message between runs, you pay for a fresh cache write on top of the normal input.

Cap the response at 300 tokens. A receipt needs a short JSON object, not a paragraph, and a tight cap turns an over-explaining answer into a predictable cost. Keep the receipt text in the user message to a few hundred tokens by trimming long item lists before you send them.

Finally, make the script log itself. After each call, append prompt_tokens, completion_tokens and the file name to usage.csv. This is the part that turns the weekend into an honest receipt instead of a guess, and it takes about five lines of code.

05 / A Saturday and Sunday schedule with a receipt at the end

Do not spread this across seven evenings. Two focused blocks are cheaper in tokens because you keep the context in your head.

  • ■ Saturday morning, 90 minutes: set the env var, write the six wiring steps, run one receipt and fix the JSON parsing
  • ■ Saturday afternoon, 30 minutes: run all 20 receipts, skim results.json, mark the wrong rows and log the token totals
  • ■ Sunday, 45 minutes: handle the three worst cases only, usually a missing date, a blurry total and a store name in capitals
  • ■ Sunday evening, 20 minutes: write receipt.txt with your numbers and stop

Your receipt file should look like this: software 0.00, keys 1, models used 1, receipts processed 20, total tokens for the weekend, then the cost line at the model's per-token rate as shown on your dashboard. The token count is the number from your usage.csv, not an estimate. If that total sits under 40,000 tokens, you beat the cap you set before touching the keyboard.

Compare that final line to whatever you pay for a coffee. The software was free, the cap was your idea, and you can stop billing at any moment because there is no monthly fee to cancel. If a friend later signs up and starts sending traffic, the referral program pays 20 percent of what invited users spend, which is a small bonus for a project you were going to build anyway.

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

More reading

DateAisleWritten inTitle
2026-10-30Spend lessENTwo Receipts, 2 Million Tokens, $0.80 Saved
Two receipts for the same 2 million tokens: one bills input and output, the other caches. Same results, $0.80 cheaper per cycle.
2026-10-30Spend lessENTwo Chatbot Receipts: $0.03 and $0.31 per Resolved Ticket
Two support chatbot bills side by side, judged only on price per useful result, with the routing and caching math that cut spend.
2026-10-30Spend lessENTag 10,000 Feedback Lines for About $0.66
A beginner walkthrough: tag 10,000 feedback lines with a cheap model for roughly $0.66, plus batching, caching and a human review plan.
2026-10-30Spend lessENOne AI Request Costs $0.004: The Receipt Math
Estimate cost per user for an AI feature on a tiny budget: token counting, cache billing, a $20/month worked example, and a receipt line that proves it.
2026-10-30Spend lessEN50k tokens, one key, under $1: a fair price check
A beginner, tiny-budget walkthrough for comparing official list prices with relay prices using per-token math, cache lines and a real receipt.
2026-10-30Spend lessEN$0.0031 per accepted answer: rank models by the receipt
A beginner walkthrough of cost per accepted answer, run on a $10 budget with two toy price schedules and a real receipt line.