33.7 Deploy and read the bill
- Approved by
- Panaversity ·
In everyday life. A new restaurant does not know its cost per plate until it has cooked a hundred plates and read the supplier's bill. The menu price was a guess until then.
What you will learn. How to deploy the worker safely, how to measure what 50 invoices really use, and how to turn that into a cost per invoice you can compare with Chapter 32.
Why it matters. Chapter 32 priced a worker from the paper's assumptions. Now you have a worker. Your own numbers replace the assumptions.
Deploy, with the spending notification in place
Step 7. Deploy the worker with wrangler deploy. Before you do, show me: the secrets it needs (the approval secret and the Neon connection string), that neither is in any file in the repository, and the spending notification on my account.
What to check. wrangler secret list shows both secrets. A search of the repository for the Neon host name finds nothing. Your billing notification from Chapter 32 is still set.
Run 50 invoices
The lab ships 50 invoices: 40 routine, 6 over $500 that need approval, 3 with a PO that does not match, and 1 duplicate. Run them first on the recorded answers. The recorded answers carry the token counts the live model used when they were recorded, so you can price the run without a key.
Step 8. Run the 50 invoices in fixtures/batch-50 against the deployed worker. Approve 5 of the 6 approvals and reject 1. Then write docs/cost-report.md: model calls, input and output tokens, active object seconds, and the cost of each line from model.ts. Show the cost per invoice.
Reading the result
Here is how to read the report, with the paper's numbers for a medium invoice: about 10 model calls, 12,000 input tokens and 1,000 output tokens per call. Your measured numbers will differ. Use yours.
| Line | One invoice | 50 invoices | How it is worked out |
|---|---|---|---|
| Model input | $0.012 | $0.60 | 120,000 tokens at $0.10 per million (Claude Haiku 5.5, as in model.ts) |
| Model output | $0.005 | $0.25 | 10,000 tokens at $0.50 per million |
| Active object time | under $0.0001 | under $0.01 | about a minute of work at $0.00576 per active hour |
| Time spent waiting | $0 | $0 | the object hibernates while it waits |
| Total | about $0.017 | about $0.85 |
For comparison, the lab's recorded answers give 200 model calls for the 50 invoices, four per invoice, and about 48,000 input tokens per invoice. That is $0.0049 per invoice on Claude Haiku 5.5. Each recorded call reads about 12,000 input tokens, as in the paper. The cost is lower because each invoice takes 4 calls, not 10, and writes about 233 output tokens, not 10,000. A live run depends on your own prompts and tools.
Three things in this table matter more than the totals.
The model is almost the whole bill. That is Chapter 32's main point, now measured on your own worker. If you want a cheaper worker, change the model setting, not the infrastructure.
The waits are free. Six invoices waited for approval. In the lab you also leave one approval waiting overnight. It adds nothing to the active time. On a platform that bills while a session is open, a wait of hours or days is a line of its own. Check how the platform you compare with bills a waiting session.
The runtime is small, but it is not zero on a busy worker. Chapter 32 priced the medium worker's runtime on Claude Managed Agents at $4.80 a month. That is 60 operating hours at $0.08 per session-hour. The same 60 hours of active Durable Object time is about $0.35. On the free plan you pay nothing while you learn.
Compare with Chapter 32
Put your cost per invoice next to Chapter 32's numbers for Brightline's medium worker: 300 invoices a month. Then answer:
- Is your token count per invoice close to the paper's 120,000 input tokens? If it is much higher, look for a tool that returns too much text, or a prompt that repeats itself.
- Did the rejected and unmatched invoices cost more or less than routine ones? Workers often spend most on the cases that go wrong.
- What would the economy-model port do to the first two lines? You find out in the lab.
The invariant. Price the worker from what it used, not from what you expected it to use.
Check yourself. Your report shows 300,000 input tokens per invoice, not 120,000, and most of them come from lookup_invoice. What do you ask Claude Code to change? (Make the tool return only the fields the model needs, not the whole invoice record and its history. Then rerun the tests and the 50 invoices.)
Sources
- Building Affordable, Self-Improving AI Workers (Panaversity, 29 November 2026), cost model model.ts
- Owner
- Panaversity