Claude courses
Course 4 · Lesson 5 of 6

Course 4 · Lesson 5 · about 20 minutes

Batch, caching and the right model

By the end, Claude has built you a cost table for one agent at 10 times its volume, from a price list in the kit that carries the date it was read. You change an assumption by saying it in a sentence, and you can say what batch, caching and a smaller model each save.

From lesson 4
When your company sends customer data to Claude through the API, who is the controller and who is the processor?

Your company is the controller and Anthropic is your processor, under Anthropic's data processing addendum. The controller's duties, such as keeping the record of processing, stay with you. Today you work out what that same agent costs when it runs ten times as often.

ThinkDelegation

What can wait, and what can be simple?

At scale, an agent's bill depends on when each job runs, what it repeats in every call, and which model does the work.

Overnight reports, invoices, sorting a backlog. Anything a customer is waiting for in a chat doesn't count.

Sorting, pulling fields out of a message and routing are the usual ones. You decide only after a test, which is the last step of this lesson.

PredictDiscernment

What does batch trade away, and where do Claude's prices come from?

Guess first. The first answer comes from Anthropic's batch page. The second is the idea behind today's prompt.

The Batch API takes 50 percent off. What do you give up?
Show the answer

Speed. The model and the answers are the same. Most batches finish within an hour, and the results are ready when every request is done or after 24 hours, whichever comes first. Use it for jobs nobody is waiting for.

Claude builds your cost table from the price list in the kit. Next month Anthropic changes a price. You ask Claude to run the table again. Which price does it use?
Show the answer

The old price. Your prompt tells Claude to use only the numbers in the kit, so the table is as current as the price list, and the price list says the date it was read. Without that rule Claude would use prices it remembers, which may be out of date. When a price changes, tell Claude the new figure and today's date.

Do

Have Claude price the agent at 10 times the volume

Five steps, about 15 minutes. Tick each one when it's done.

Opus 5.5, as is Sonnet 5.5, as is Sonnet 5.5 + caching Sonnet 5.5 + caching + batch Haiku 5.5 + caching + batch $540 $270 $145.50 $87.30 $4.57 $270: the bill with no changes
The same 30,000 runs a monthCaching and batch bring the bill to about a third of $270. A smaller model cuts it much further, if it passes your tests.
  1. Put the kit in a folder and open it in the Code tab.

    Unzip the kit and open the folder in the Code tab with the mode set to Manual, as you did in course 2, lesson 4.

    The Lantern Candles cost kit

    Lantern Candles' order agent goes from 3,000 to 30,000 orders a month. The ZIP holds prices.csv, Anthropic's prices for three models with the date they were read, assumptions.txt, with the runs, tokens and the five options to price, and a short README.txt. Unzipping it gives you a folder called c4-05.

    Download the ZIP (under 2 KB)
  2. Give Claude the build prompt.

    Paste it into the Code tab and press Enter.

    Build me a cost table for our order agent from prices.csv and assumptions.txt in this folder. Price each of the five options in assumptions.txt for a month at 3,000 runs and at 30,000 runs. Prices are US dollars per million tokens. Use only the numbers in these two files. If I ask about a model that isn't in prices.csv, say so instead of guessing. Do the sums with a small calculation you can run again when I change a number, not in your head. Round only the monthly totals, to the cent. Save the table as cost-table.csv so I can open it in a spreadsheet. Before you install anything, tell me what and why. Test it: show me the table and the sum for the Sonnet 5.5 with caching row, step by step, before you say it's done.

    It opens with the job and the two files it works from.

    "Use only the numbers in these two files" and "say so instead of guessing" keep Claude from bringing prices of its own. The table is then as current as the date in the price list.

    "A small calculation you can run again" means a change later takes one sentence from you, and "round only the monthly totals" keeps the cents right.

    "Test it" asks for proof: the table, and one row worked out so you can follow it with a calculator.

  3. Approve what Claude asks.

    Expect a request to create two files in your folder (the calculation and cost-table.csv), then a request to run the calculation. Read each request before you approve it. You can say no and ask Claude why it needs it.

    Before it says it's done, Claude shows you the table and the sum for the caching row. Sonnet 5.5 with no changes should cost $27.00 a month at 3,000 runs and $270.00 at 30,000.

  4. Ask Claude to explain what it built.

    Send this in the same session and read the answer:

    Explain what you built as if I've never seen code. One line per file. Then tell me what costs the table leaves out.

    Then open cost-table.csv from your folder. It opens in Excel, Numbers or Google Sheets, and it's the file you'd hand to whoever pays the bill.

  5. Decide the three levers for your own agent.

    Write one line each: which jobs go in a batch, which stay instant, and which job you'll try on a smaller model. Run your test questions from course 3 on the smaller model first, and switch only if it passes them.

If you see this instead

Claude says it can't find prices.csv
The Code tab is open on a different folder. Open the c4-05 folder and paste the prompt again.
Claude wants to install something you didn't expect
Before you approve, ask: "Why do you need this, and can you do it with what's already on my computer?" If a window from your Mac offers to install developer tools, ask Claude whether it needs them before you click Install.
A total is a cent or two off this page
Claude rounded along the way. Paste: "Keep exact numbers and round only the monthly totals. Run it again."
Your real bill is higher than the table
The table counts a plain call. An agent with tools sends their descriptions in every request, and computer use adds about 4,500 tokens each time. Count your real usage before you trust the table.
CheckDiscernment

Can you predict what a lever saves?

1 · WRITE 2,500 tokens 1.25 x input price The first call stores the instructions 2 · READ 2,500 tokens 0.05 x input price Calls within 5 minutes read it, and refresh it 3 · EXPIRE 5 minutes idle Next call writes again Steady traffic keeps it from expiring
The life of a cached blockPrices shown are for Sonnet 5.5. The write costs a little extra once, and every read after it costs a twentieth.

Write down your guess first: if none of the runs could wait for a batch, what would "Sonnet 5.5 with caching and batch" cost for 30,000 runs? Then send this in the same session:

Say none of our runs can wait for a batch. Change only that, run the calculation again and show me the new table.

Write the guess down before you send it, because the new table gives the answer away. Read the number in cost-table.csv, not only in Claude's reply.

You pass when your guess matches the new table: $145.50 for 30,000 runs, the same as the caching row, because with no runs in a batch there's no discount to add. The other four rows don't change.

Then say "Put the batch share back to 80 percent." The row returns to $87.30, which is 0.32 times the $270 bill, about a third.

Then try "Add a row for Claude Fable 5.2 with caching and batch." Claude should tell you Fable 5.2 isn't in prices.csv and ask for its prices, because your prompt said to use nothing else.

Two questions from memory

What does the Batch API cost compared with normal calls, and what do you give up?

Half the price for input and output. You give up speed: most batches finish within an hour, but results can take up to 24 hours, so it's wrong for anything a person is waiting for.

Why does the kit's price list carry the date it was read?

Claude builds the table only from that file, so the table is as current as the file. The date tells you when it's time to check Anthropic's pricing page again.

Lesson 6 opens by asking the first one again.

Check the ratio yourself

"About a third" holds under the kit's assumptions: 90 percent of runs read the cache and 80 percent go in a batch. If less of your work can wait, the saving is smaller. The Batch API keeps your requests and results for up to 29 days, so it isn't covered by zero data retention. Read Anthropic's data retention page before you batch customer data.

Course 4 so far

What you've built

Lesson 1: Old program
Lesson 2: Memory
Lesson 3: Team of agents
Lesson 4: Rules and law
Lesson 5: Cost
Lesson 6 turns the agent into a monthly service other companies pay for.