IntegrAuth Academy
Identity, security and practical AI — free, from zero. Byte-sized lessons, real diagrams, hands-on labs, zero fluff. Two programs, each with its own exam and certificate.
English is hard? Your browser can translate this page into Tamil, Telugu, Kannada, Malayalam or Hindi. Tech words stay in English so you learn the real names.
How?
- Chrome on phone: ⋮ menu → Translate
- Chrome on computer: right-click → Translate to …
- Edge: the translate icon in the address bar
Cost, limits and caching
Priya's team launched a help-desk bot on Monday. By Friday, the bill was huge. Users saw "429" errors, too. Your goal: see what makes the bill grow, and how to cut it.
🧪 Interactive lab — enable JavaScript to play with this one.
- Output usually costs several times more per token than input.
- Every new turn sends the whole chat again.
- Put the parts that never change first. Then the cache can reuse them.
- After a 429 error, wait longer each time. Add a random extra wait.
How the bill adds up
You pay per token (Tokens and context windows). Tokens you send are input tokens. Tokens the AI writes are output tokens. It works like a phone data pack: every token used is counted and billed.
Some costs are easy to miss. Each turn sends the whole chat again. Tool lists and documents are input on every call, too. A thinking model bills its hidden "thinking" as output.
Caching: reuse the same start
Many requests start with the same long text, like rules or a handbook. The provider can keep that start ready for a while. This is prompt caching. A request with the exact same start costs less and is faster.
The match begins at the very first token. So today's date or a user's name at the top breaks it.
Error 429: too many requests
Each account has a speed limit, its rate limit. It often counts requests and tokens per minute. Go over it, and you get error 429.
Then wait before you try again, and wait longer each time. This is exponential backoff. Add a small random wait, called jitter, so users don't all retry together.
Now build a request that the cache can reuse.
🧪 Interactive lab — enable JavaScript to play with this one.
Go deeper: work out one call
Prices are per million tokens. Input and output have separate prices.
cost = input tokens × input price + output tokens × output price
Here is an example with made-up prices. Real prices change often. A call sends 3,100 input tokens. The answer is 400 tokens. Input costs $3 per million. Output costs $15 per million. The call costs about 1.5 cents. At 50,000 calls a month, that is about $765.
Priya's bot sent a 6,000-token handbook with every message. It used the biggest model to reset passwords. It kept whole chats forever. A quick test with 3 messages showed none of this.
Go deeper: how caching works
- Cached input costs a small part of the normal input price.
- Some providers charge extra the first time they save a start. So caching pays only when you reuse it.
- A cache lasts for minutes to hours. Each use usually keeps it alive longer.
- Very short prompts are not cached at all.
- Some providers cache on their own. Others cache only when you turn it on.
A good order is tools, then rules, then documents, then the chat, then the new question. Why a change near the top breaks the match is in Inside one answer.
Go deeper: batch jobs
Some jobs can wait, like sorting 20,000 old support tickets. You can send many requests at once and get the results later. This is a batch API. As of October 2026, big providers charge about half the normal price for batch work. Results come within 24 hours, often sooner. Don't use batch when a person is waiting for the answer.
Go deeper: retry the right way
Limits often count over short time windows. So 60 requests per minute can act like 1 per second. A quick burst can get a 429, even when the minute total is fine.
- Retry only errors that can work later. Most 429s and short server problems can. A
400 Bad Requestwill not. - Some 429s say you are out of credit or over your spend limit. Waiting will not fix these. Stop and tell someone.
- If the error has a
retry-afterheader (a note that comes with the reply), wait that long. - If not, double the wait limit each time, up to a cap. Then wait a random time up to that limit.
- Stop after a set number of tries. Some providers count failed calls, too.
Official SDKs often retry for you. Check what yours does first.
Go deeper: more ways to save
- Use a smaller model for easy work. Test that quality holds (Choosing a model).
- Trim old chat. Drop the wrong part, and answers get worse (Context and memory).
- Cap the answer length with
max_tokens. Too low, and answers stop mid-sentence. - Set a monthly spend limit and alerts. A hard cap stops the service when you reach it.
- Use one API key per project. Log the
usagenumbers that come back with each answer.
Loops cost the most. An agent with no step limit can make thousands of calls (Agents, subagents and skills). So can a retry loop with no maximum. Give every loop a cap and a budget.
Open a real price list, like Anthropic's, OpenAI's or Google's. Type its prices into the first lab.