OverpayingForAIPricing desk

Lesson 2 of 6 · 12 min read · Beginner

Turn a real file into a usable answer

Stop pasting documents into a chat box. Send a file straight from your machine, get structured output back, and learn why the length of what you send is the thing that costs money.

In this lesson you will

  • Send the contents of a real file to a model
  • Ask for structured output you can use, not prose you have to re-read
  • See how input length maps to cost

The browser workflow for a document is: open the file, select all, copy, switch tabs, paste, wait, read, copy the answer back out. That is six steps of manual labour around one second of machine work, and it caps you at whatever the chat window will accept.

Here is the same job as one command. The important shift is not speed — it is that the output arrives in a shape you can feed to something else.

Summarising a real file into structured JSON

The file here is a 4,000-word meeting transcript. Substitute any text file you have.

recorded session — not a live shell0 / 3
  1. wc -w transcript.txt4,127 words. As a rough rule, English runs about 1.3 tokens per word, so expect roughly 5,400 input tokens.
  2. curl -s https://openrouter.ai/api/v1/chat/completions \ -H "Authorization: Bearer $OPENROUTER_API_KEY" \ -H "Content-Type: application/json" \ -d "$(jq -n --rawfile doc transcript.txt '{ model: \"google/gemini-2.5-flash-lite\", messages: [{role:\"user\", content: (\"Return JSON with keys decisions, owners, risks. Transcript:\\n\" + $doc)}] }')" | jq -r '.choices[0].message.content'jq reads the file safely into JSON (handling quotes and newlines you would otherwise have to escape by hand), and pulls just the answer out of the response.
  3. curl -s https://openrouter.ai/api/v1/chat/completions -H "Authorization: Bearer $OPENROUTER_API_KEY" \ -H "Content-Type: application/json" -d @request.json | jq '.usage'5,416 in, 148 out. At Gemini 2.5 Flash Lite's $0.10 input / $0.40 output per 1M that is $0.00054 + $0.00006 = about $0.0006 — six hundredths of a cent for a document you would have spent five minutes reading.

Your own numbers will differ — token counts depend on your text, and rates move. The arithmetic is what transfers.

Notice which number got big

Compare with lesson 1: the output barely moved (51 tokens then, 148 now) but the input went from 24 to 5,416 — a 225× jump. Document work is input-heavy work. That single fact decides most of your architecture later: it is why long context windows are a feature you pay for, why re-sending the same document on every question is wasteful, and why caching exists.

Knowledge check

You ask ten separate questions about the same 5,000-token document, re-sending the document each time. What is your input token total?

Lesson FAQ

What is jq and do I need it?

A small tool for handling JSON on the command line. It saves you from escaping quotes and newlines by hand, which is the main thing that makes beginners give up here. Install with `brew install jq` on macOS or `apt install jq` on Linux.

What if my document is larger than the context window?

Split it and summarise the pieces, then summarise the summaries. Gemini 2.5 Flash Lite in this lesson carries a 1M-token window, which is far more than most documents — but check the window before assuming.

Finished reading?

Mark it done to track your progress through the course.

Save progress across devices

Get a private link that restores your lessons on any device. Email is optional and only used to send you the link.

Compare, calculate, decide

If our calculators helped you cut down on hidden AI wallet leaks, thanks for using them. A tiny fraction of your savings is what keeps our pricing indexes updated daily.

Not sure which AI is cheapest for your use case? Find out in 30 seconds — no signup required.

AI cost intelligence

Stop overpaying for AI tools

Join the OverpayingForAI list for pricing updates, cheaper alternatives, and practical buying guidance.

Now tracking 50+ AI tools, models, platforms, subscriptions, coding tools, and automation products.

We use your email only for OverpayingForAI updates. Unsubscribe anytime.