Attribute tokens and cost to each step
About 22 minutes to read, with 8 examples in 9 sections.
Written with AI. Verified by people. How we make books
This book is open to contributions, so anyone can check it or correct it. Its repository · Report an error · How to fix one
Labs
Learn this chapter by doing it
Run every example exactly as the book did, change the code to see what happens, and try your own ideas on the book's code and data. Nothing to install, and your work is saved. Opens in about 30 seconds.
Run every example exactly as the book did, change the code to see what happens, and try your own ideas on the book's code and data. Nothing to install, and your work is saved. Labs runs it for you: 40 hours a month.
On your own machine, free: download the book's notebooks, with its code and data, from GitHub.
Chapter 1 of every book is read aloud for everyone; every chapter with Labs. See plans, or sign in.
Read by an AI voice, word for word from this edition's text. Code, output and tables are on the page.
Pocket TTS by Kyutai, voice alba, from Alba MacKenna's recordings, CC BY 4.0.Pocket TTS by Kyutai, voice eve, from VCTK corpus speaker p361, CSTR, University of Edinburgh, CC BY 4.0, adapted by Kyutai.
Your browser can translate this page from its menu, and the code stays as the book has it.
Or read it with your AI assistant:
Running your code on the book's versions
By the end of this chapter you can split a day's model calls into input tokens, cached input tokens and output tokens, total them without counting any token twice, and say which step, route and user the money went to. You can also say which of those numbers depends on a price table and which does not.
Ambrewick's finance team asks two questions of the assistant's traces. The first is what one message costs, by route and by user. It sounds like a sum over the spans, and it is the question that goes wrong first: usage sits on more than one kind of span, so a sum over all of them is too high. The second is what the same messages would cost in other languages. This book's assistant serves English only, but the dataset's other locales hold the same utterances, and the same utterance takes a different number of tokens in each language. The chapter measures both on one day, baseline day 1, 2026-12-08, which holds 200 messages. Each message ran through the assistant on the baseline release, with Qwen3-4B-Instruct-2507 as the model, and each model call was recorded once and replayed on the virtual clock, as chapter 1 describes.
Tokens come first, because they are what the model did. Money comes second, because it needs a price, and the price is a choice the book makes and dates.
Three counts for each call
A token count is the number of tokens a model reads or writes for one call, in that model's own vocabulary. The book keeps three counts for each call. Input tokens are the whole prompt the model read, cached part included; cached input tokens are the part its cache held; output tokens are what it wrote. The GenAI conventions, at version 0.1.0, define the input total the same way: gen_ai.usage.input_tokens includes the cached tokens. So the cached count sits inside the input count, and adding the two together counts the cached part twice.
The prompt count and completion count in Agent Harnesses are close to these two, and they have no cached part. This book adds one, and it adds a price to the counts later in the chapter.
Each message makes one route call, and a message on any route but fallback makes one or more answer calls. The most calls one message made on this day is 3: a route call and two answer calls, when a tool's request comes before the reply. The script below sorts every call of the day by its three counts and its step.
1"""Tokens per model call (a request), per message, per resolved message and per route, over baseline day 1's 2002messages. Each rate names its denominator (PL-11): a resolved message is one the model answered, not the fallback reply.3The input count includes the cached part, so the cached share is printed beside it."""4from lib.dayrun import run_day5from lib.report import fmt_int, fmt_share67runs = run_day("2026-12-08")8model_steps = {run.message.message_id: [s for s in run.outcome.steps if s.name == "chat"] for run in runs}91011def totals(steps):12 """Input (cached part included), cached input (derived) and output tokens, summed over some model steps."""13 return (sum(s.prompt_tokens for s in steps), sum(s.cached_tokens for s in steps),14 sum(s.completion_tokens for s in steps))151617requests = [s for steps in model_steps.values() for s in steps]18inp, cached, out = totals(requests)19print("messages:", fmt_int(len(runs)))20print("requests (model calls):", fmt_int(len(requests)))21print("input tokens, total:", fmt_int(inp))22print("cached input tokens, derived, total:", fmt_int(cached))23print("output tokens, total:", fmt_int(out))24print("cached share of input tokens:", fmt_share(cached, inp))25print("input tokens per request:", f"{inp / len(requests):.1f}")26print("output tokens per request:", f"{out / len(requests):.1f}")27print("input tokens per message:", f"{inp / len(runs):.1f}")28# Every message makes a route call first; a fallback message stops there, so it has no answer call.29for step in ("route", "answer"):30 steps = [s for s in requests if s.step == step]31 print(f"{step} requests:", fmt_int(len(steps)))32 print(f"{step} requests, input tokens per request:", f"{totals(steps)[0] / len(steps):.1f}")33model_calls = {run.message.message_id: len(model_steps[run.message.message_id]) for run in runs}34assert all(sum(s.step == "route" for s in model_steps[m]) == 1 for m in model_calls) # one route call per message35print("most model calls in one message:", max(model_calls.values())) # the route call and up to two answer calls36resolved = [run for run in runs if run.outcome.source == "model"]37r_inp, _, r_out = totals([s for run in resolved for s in model_steps[run.message.message_id]])38print("resolved messages:", fmt_int(len(resolved)))39print("input tokens per resolved message:", f"{r_inp / len(resolved):.1f}")40print("output tokens per resolved message:", f"{r_out / len(resolved):.1f}")41for route in sorted({run.outcome.route for run in runs}):42 mine = [run for run in runs if run.outcome.route == route]43 route_inp, _, route_out = totals([s for run in mine for s in model_steps[run.message.message_id]])44 print(f"route {route}, messages:", fmt_int(len(mine)))45 print(f"route {route}, input tokens per message:", f"{route_inp / len(mine):.1f}")46 print(f"route {route}, output tokens per message:", f"{route_out / len(mine):.1f}")47assert sum(totals(steps)[0] for steps in model_steps.values()) == inp # every request belongs to exactly one message
python token-counts-per-step.pymessages: 200
requests (model calls): 321
input tokens, total: 104,811
cached input tokens, derived, total: 61,460
output tokens, total: 4,996
cached share of input tokens: 58.6%
input tokens per request: 326.5
output tokens per request: 15.6
input tokens per message: 524.1
route requests: 200
route requests, input tokens per request: 145.5
answer requests: 121
answer requests, input tokens per request: 625.6
most model calls in one message: 3
resolved messages: 111
input tokens per resolved message: 827.7
output tokens per resolved message: 40.2
route alarms, messages: 16
route alarms, input tokens per message: 883.6
route alarms, output tokens per message: 43.4
route calendar, messages: 27
route calendar, input tokens per message: 903.5
route calendar, output tokens per message: 38.8
route devices, messages: 17
route devices, input tokens per message: 627.9
route devices, output tokens per message: 44.5
route fallback, messages: 89
route fallback, input tokens per message: 145.4
route fallback, output tokens per message: 6.0
route lists, messages: 13
route lists, input tokens per message: 936.5
route lists, output tokens per message: 29.0
route media, messages: 31
route media, input tokens per message: 663.9
route media, output tokens per message: 41.6
route messages, messages: 7
route messages, input tokens per message: 1415.4
route messages, output tokens per message: 42.1
Cached share of the input
+10 proofsFrom Three counts for each call, chapter 6Read it again
A new edition changed what this practised. What changed in Edition 2026.11.2
Line 24 is blank. Write the line that prints the cached share of input tokens, using the totals computed on line 18 and the fmt_share helper imported on line 5.
Why it works
Why the per-message input rate is lower
+10 proofsFrom Three counts for each call, chapter 6Read it again
Builds on fallback reply, from chapter 1, “Where the time went in twenty messages”
Builds on message, from chapter 1, “One message, one trace”
A new edition changed what this practised. What changed in Edition 2026.11.2
Why is the input tokens per message line smaller than the input tokens per resolved message line in the output?
Why it works
Most of the day's input is cached. Of 104,811 input tokens across the day's model calls, 61,460 were cached, which is 58.6% of the input. The output is small by comparison, 4,996 tokens in all.
The two steps differ in size. A route request reads 145.5 input tokens on average, and an answer request reads 625.6, because the answer call carries more of the prompt, such as the retrieved articles and a tool's result.
Input tokens are the call's messages rendered through the chat template in the model's GGUF file and re-tokenized with the model's own tokenizer. Output tokens are the reply re-tokenized with the model's own tokenizer. Cached input is derived rather than reported, as chapter 1 says, and the cached-input section below shows the subtraction.
Divided by the messages, the day's input is 524.1 tokens per message. Per resolved message it is 827.7 input and 40.2 output tokens. A resolved message is one the assistant answered with a model reply, not a fallback reply. Each rate here names its denominator, because a count per request and a count per message answer different questions.
Working rule: Report a call's input as the whole prompt, cached part included, and report cached input beside it, never added to it. Give output on its own. Name the count's source beside any token total, because the same text takes a different number of tokens in a different vocabulary.
Summing spans double counts
The obvious way to total a day's tokens is to add the usage on every span. That is the sum a backend's query would run first, and here it is wrong. The conventions' note on aggregating token usage says not to sum gen_ai.usage.* over all spans without filtering by operation name, because the same tokens can be reported on more than one type of span, such as an agent span and an inference span. Usage sits on each model call's inference span, and the assistant also sets the message's total on its agent span, as the conventions allow. Chapter 2 names both span types.
Adding the usage up three ways over the same day shows where the extra comes from.
1"""Summing usage over every span counts each input token twice, because the agent span carries its message's usage as well as2its model calls do (the registry's aggregation note). The assistant's live meter counts each call once, as the call ends,3and matches the inference spans. The two asserts are the facts the prose relies on."""4from lib.dayrun import RELEASE, run_day_traced5from lib.metrics import PER_OPERATION, USAGE, make_meter_provider, totals6from lib.names_map import NAMES, REGISTRY_VERSION7from lib.report import fmt_int8from opentelemetry.sdk.metrics.export import InMemoryMetricReader910DAY = "2026-12-08"11INPUT = "gen_ai.usage.input_tokens"12reader = InMemoryMetricReader()13provider = make_meter_provider(reader, service_instance_id=f"{DAY}-metrics", service_version=RELEASE.service_version)14traced = run_day_traced(DAY, live=False, meter_provider=provider) # the assistant records each call's tokens as it ends15attributes = [s["attributes"] for s in traced.spans]16inference = [a for a in attributes if a.get("gen_ai.operation.name") == "chat"]17agents = [a for a in attributes if a.get("gen_ai.operation.name") == "invoke_agent"] # one per message181920def summed(rows, key):21 """The sum of one usage attribute over span attributes; a span without it adds zero."""22 return sum(row.get(key, 0) for row in rows)232425got = totals(reader)26spans_input = summed(inference, INPUT)27every_span_input = summed(attributes, INPUT)28counter_input = int(got[USAGE["input"]]["sum"])29print("messages:", fmt_int(len(traced.runs)))30print("inference spans, one per model call:", fmt_int(len(inference)))31print("agent spans, invoke_agent, one per message:", fmt_int(len(agents)))32print("input tokens, summed over the inference spans:", fmt_int(spans_input))33print("input tokens, summed over every span:", fmt_int(every_span_input))34print("input tokens, token counter total:", fmt_int(counter_input))35print("input tokens, per-operation histogram sum:", fmt_int(int(got[PER_OPERATION["input"]]["sum"])))36print("per-operation histogram, count of operations:", fmt_int(got[PER_OPERATION["input"]]["count"]))37print("output tokens, token counter total:", fmt_int(int(got[USAGE["output"]]["sum"])))38print("GenAI conventions version:", REGISTRY_VERSION)39print("package token histogram, gen_ai.client.token.usage, v0.1.0 names:", ", ".join(NAMES["gen_ai.client.token.usage"]))40assert every_span_input == 2 * spans_input # the agent spans repeat every inference token once more41assert counter_input == spans_input # the counter reads each call's usage once, as the call ends
python totals-metric-against-spans.pymessages: 200
inference spans, one per model call: 321
agent spans, invoke_agent, one per message: 200
input tokens, summed over the inference spans: 104,811
input tokens, summed over every span: 209,622
input tokens, token counter total: 104,811
input tokens, per-operation histogram sum: 104,811
per-operation histogram, count of operations: 321
output tokens, token counter total: 4,996
GenAI conventions version: 0.1.0
package token histogram, gen_ai.client.token.usage, v0.1.0 names: gen_ai.client.inference.operation.input_tokens, gen_ai.client.inference.operation.output_tokens
The assistant records each model call's tokens on its meter as the call ends, and the book reads two instruments from that meter. A metric is a measurement the SDK aggregates over many operations and exports without each one's detail; a counter only adds, and a histogram counts values into buckets with their sum and count. The input-token counter, gen_ai.client.inference.usage.input_tokens, gives one total for the day. The per-operation histogram records one value for each model call, its input tokens, and keeps their sum and their count.
Summed over the inference spans, the input is 104,811 tokens. Summed over every span, it is 209,622. The second figure is the first with the agent spans' copy added, so it is too high by exactly that copy. The token counter, which the assistant adds to on each model call, gives 104,811, the same total as the inference spans. The point to keep is that the counter and the inference spans agree, and the sum over every span does not.
The per-operation histogram's sum is 104,811 over 321 operations, the model calls, which matches the counter. The output counter gives 4,996 output tokens.
The package this book uses writes an older token metric: one histogram, gen_ai.client.token.usage, that splits by gen_ai.token.type. Chapter 3 shows its names beside the registry's, and in v0.1.0 that histogram's names are gen_ai.client.inference.operation.input_tokens, gen_ai.client.inference.operation.output_tokens. The counters split by gen_ai.token.modality instead, and for each operation the modality counts add up to the total. The conventions' note says that the token counters are not affected by trace sampling, so a total read from them survives a sampler that drops spans, and a total read from spans does not. A counter filled at each call counts every call whatever a sampler keeps; a total rebuilt from sampled spans falls with the sample, and must be scaled up, with an error, as chapter 11 shows.
Working rule: Take a day's token total from the counters, or sum usage over inference spans only, filtered by operation name. Usage on an agent span is that agent's total over its calls, so never add it to the calls' usage. In production we read totals from the counters, because a sampler cannot thin them.
Cached input, derived from the counters
The runtime does not report the reused count, so the book derives it: cached input is the prompt tokens minus the tokens the runtime evaluated. Reuse happens in two places. The runtime keeps the evaluated prefix of the last prompt, and a call whose prompt starts with the same tokens evaluates only the new suffix; the baseline also turns on a RAM cache, PromptCache(LlamaRAMCache) with cache_prompt: true, which restores the saved state of an earlier prompt with the longest shared prefix once the context's own prefix has been overwritten. The assistant's system prompt and its tool list sit at the front of every prompt, so most calls reuse them.
The pinned llama-cpp-python 0.3.37 has no cached-token field in its Python API or in the performance counters it ships. The recorder takes n_p_eval, the prompt tokens evaluated, as a difference between calls, because the counters accumulate. The counter n_reused sits in the same structure, but it counts graph reuse, not tokens, so this book does not read it as the cached count. We judge that a derived count of reused prefix tokens belongs in gen_ai.usage.cache_read.input_tokens and the cache-read counter, and we record a zero when nothing is reused. The registry defines that attribute as tokens served from a provider-managed cache, as the provider reports them, so the count is the book's own judgement and not a provider's report.
The same 60 messages run twice here, a seeded sample of baseline day 1: once on the baseline release, r0, and once on the cache-off release, r4. Release r4 differs from r0 in two ways. Its RAM cache is off, and llm.reset() clears the runtime's state before each call, which is the way the book's recorder gives each call a fresh state. Setting the cache to none is not enough, because the next call still reuses the prefix of the last one, as the book's probe at the pinned version found.
1"""Cached input tokens for each model call, derived as prompt tokens minus the tokens llama.cpp evaluated (PL-21), on baseline2day 1 and on the same 60 messages with the prompt cache reset before each call (release r4). The reset leaves the input3tokens the model reads unchanged; what it removes is the cached part, so the same tokens are all evaluated again. Each call4is priced at its own start on the replay clock."""5from decimal import Decimal67from lib.case import load_messages8from lib.dayrun import run_day9from lib.prices import PriceTable10from lib.report import fmt_int, fmt_share, fmt_usd11from lib.tokens import derived_cached, recorded_calls1213DAY, MODEL = "2026-12-08", "Qwen3-4B-Instruct-2507"14paired = {m.message_id for m in load_messages("2026-12-08-paired")} # the 60 messages r1, r3 and r4 replay15day = recorded_calls("baseline-day-1")16day_input, _, day_cached = derived_cached(day)17print("baseline day 1, model calls:", fmt_int(len(day)))18print("baseline day 1, input tokens, total:", fmt_int(day_input))19print("baseline day 1, cached input tokens, derived, total:", fmt_int(day_cached))20print("baseline day 1, cached share of input:", fmt_share(day_cached, day_input))21# The recorder's own derived field is the same subtraction, call by call.22assert all(c["cached_tokens_derived"] == c["prompt_tokens"] - c["tokens_evaluated"] for c in day)2324base = recorded_calls("baseline-day-1", paired)25cache_off = recorded_calls("release-cache-off", paired)26assert [(c["message_id"], c["step"]) for c in base] == [(c["message_id"], c["step"]) for c in cache_off] # the same calls27b_input, b_evaluated, b_cached = derived_cached(base)28o_input, o_evaluated, o_cached = derived_cached(cache_off)29print("same 60 messages, model calls:", fmt_int(len(base)))30print("r0, input tokens:", fmt_int(b_input))31print("r0, tokens evaluated:", fmt_int(b_evaluated))32print("r0, cached input tokens, derived:", fmt_int(b_cached))33print("r4, input tokens:", fmt_int(o_input))34print("r4, tokens evaluated:", fmt_int(o_evaluated))35print("r4, cached input tokens, derived:", fmt_int(o_cached))36print("tokens evaluated, r4 minus r0:", fmt_int(o_evaluated - b_evaluated))37assert o_input == b_input and o_cached == 0 # same input tokens; the cache reset leaves no cached part38assert o_evaluated - b_evaluated == b_cached # every cached token is evaluated again without the cache3940# The same calls at the book's rates. A recorded call has no clock of its own, so each takes the start the baseline replay41# gave its message and step, and r4 makes the same calls, so its calls take the same starts.42starts = {(run.message.message_id, s.step): s.start_ns for run in run_day(DAY, paired)43 for s in run.outcome.steps if s.name == "chat"}44price = PriceTable()454647def money(calls):48 """The money of recorded calls at the book's rates, each at its own start."""49 return sum((price.cost(MODEL, c["prompt_tokens"], c["cached_tokens_derived"], c["completion_tokens"],50 starts[(c["message_id"], c["step"])]) for c in calls), Decimal(0))515253print(f"cost difference, r4 minus r0, same 60 messages, {price.version}:", fmt_usd(money(cache_off) - money(base)))
python cached-tokens-from-replay.pybaseline day 1, model calls: 321
baseline day 1, input tokens, total: 104,811
baseline day 1, cached input tokens, derived, total: 61,460
baseline day 1, cached share of input: 58.6%
same 60 messages, model calls: 93
r0, input tokens: 29,107
r0, tokens evaluated: 11,682
r0, cached input tokens, derived: 17,425
r4, input tokens: 29,107
r4, tokens evaluated: 29,107
r4, cached input tokens, derived: 0
tokens evaluated, r4 minus r0: 17,425
cost difference, r4 minus r0, same 60 messages, book-2026-11-02: $0.001394
Under the baseline the 60 messages read 29,107 input tokens, and only 11,682 of them were evaluated; the rest were cached. Under the cache-off release they read the same 29,107 tokens, and all of them were evaluated. Resetting the state did not change what the model read; it changed how much of it the runtime had to evaluate, so 17,425 more tokens were evaluated.
That difference is the money. At the book's table the cache-off release costs $0.001394 more on those 60 messages, because cached tokens are billed at the cached rate and evaluated ones at the input rate. A release which changes the cache changes cost and leaves input tokens alone, so a comparison of input tokens would miss that change.
Working rule: Derive cached input at each call from the runtime's counters, never from a release's label. When a release changes the cache, we compare cost on the same messages, because the input count will not move.
The same utterances in other languages
Tokens are counted per vocabulary, and the same text can take very different numbers of tokens in different languages. Petrov and colleagues measured the gap for several tokenizers, found differences of up to fifteen times in some language pairs, and found the gap persisted in tokenizers built for many languages, as their NeurIPS 2023 paper reports. This section measures the gap for the dataset's utterances.
Only the English messages ran through the assistant. The other five locales are the same 200 utterances in the dataset's other locale files, joined by id. No model read them and no assistant served them, so each cost is an input rate on that text. The six locales are English (en-US), German (de-DE), Japanese (ja-JP), Hindi (hi-IN), Arabic (ar-SA) and Chinese (zh-CN). The example counts all six with the tokenizer file of the model the book uses, and prices the counts at the book's table.
Each locale's count is the tokenizer file's count: the utterance's text alone, normalised to NFC and tokenized by tokenizers 0.23.3 with the 4B's tokenizer.json; no model read it, and it is not a whole prompt.
1"""Count the same 200 baseline utterances in six locales with the 4B's own tokenizer file, and price the counts at the book's2input rate. The printed hi-IN ratio is the point the prose rests on: the same request takes several times the English3tokens. Each count is the utterance's text alone, not a whole prompt."""4from decimal import Decimal56from lib.case import load_locale, load_messages7from lib.clock import VirtualClock8from lib.prices import PriceTable9from lib.report import fmt_int, fmt_usd10from lib.tokens import LocaleCounter, is_nfc1112DAY = "2026-12-08"13MODEL = "Qwen3-4B-Instruct-2507"14LOCALES = ("en-US", "de-DE", "ja-JP", "hi-IN", "ar-SA", "zh-CN")15messages = load_messages(DAY)16ids = [m.message_id for m in messages]17texts = {m.message_id: m.text for m in messages}18by_id = sorted(messages, key=lambda m: int(m.message_id)) # the order load_locale returns each locale's utterances in19arrivals = [VirtualClock(DAY, start_ns=m.arrival_ns).now_ns for m in by_id] # each message's own arrival, on the day's clock20counter, price = LocaleCounter(), PriceTable()2122print("price table:", price.version)23print("utterances, the baseline day's messages joined by id:", fmt_int(len(ids)))24means = {}25for locale in LOCALES:26 utterances = load_locale(locale, ids) # the same messages, in ascending ID order, so the locales line up27 counts = [counter.count(text) for text in utterances]28 total = sum(counts)29 means[locale] = total / len(counts)30 # The text is not cached, so every token bills at the input rate, each utterance at its message's arrival.31 per_thousand = sum((price.cost(MODEL, n, 0, 0, at) for n, at in zip(counts, arrivals)), Decimal(0)) * 1000 / len(counts)32 print(f"{locale}, tokens, total:", fmt_int(total))33 print(f"{locale}, tokens per utterance:", f"{means[locale]:.1f}")34 print(f"{locale}, input cost per 1,000 utterances, {price.version}:", fmt_usd(per_thousand))3536print("hi-IN tokens per utterance, as a multiple of en-US:", f"{means['hi-IN'] / means['en-US']:.1f}")37hindi = load_locale("hi-IN", ids)38# NFC is applied by the tokenizer file, so only text that is not already NFC can count differently under another counter.39print(f"hi-IN utterances not in NFC, of {len(hindi)}:", sum(not is_nfc(text) for text in hindi))40assert [texts[i] for i in sorted(ids, key=int)] == load_locale("en-US", ids) # the English texts are the traffic's own41assert all(is_nfc(t) for locale in LOCALES if locale != "hi-IN" for t in load_locale(locale, ids))
python count-locales-with-the-tokenizer.pyprice table: book-2026-11-02
utterances, the baseline day's messages joined by id: 200
en-US, tokens, total: 1,508
en-US, tokens per utterance: 7.5
en-US, input cost per 1,000 utterances, book-2026-11-02: $0.000754
de-DE, tokens, total: 2,194
de-DE, tokens per utterance: 11.0
de-DE, input cost per 1,000 utterances, book-2026-11-02: $0.001097
ja-JP, tokens, total: 1,979
ja-JP, tokens per utterance: 9.9
ja-JP, input cost per 1,000 utterances, book-2026-11-02: $0.000990
hi-IN, tokens, total: 6,864
hi-IN, tokens per utterance: 34.3
hi-IN, input cost per 1,000 utterances, book-2026-11-02: $0.003432
ar-SA, tokens, total: 2,015
ar-SA, tokens per utterance: 10.1
ar-SA, input cost per 1,000 utterances, book-2026-11-02: $0.001008
zh-CN, tokens, total: 1,314
zh-CN, tokens per utterance: 6.6
zh-CN, input cost per 1,000 utterances, book-2026-11-02: $0.000657
hi-IN tokens per utterance, as a multiple of en-US: 4.6
hi-IN utterances not in NFC, of 200: 8
The same 200 utterances cost 4.6 times as many tokens in Hindi as in English. The table gives each locale's count per utterance, and the input cost of 1,000 utterances at the book's table.
| Locale | Tokens per utterance | Input cost per 1,000 utterances |
|---|---|---|
| English, en-US | 7.5 | $0.000754 |
| German, de-DE | 11.0 | $0.001097 |
| Japanese, ja-JP | 9.9 | $0.000990 |
| Hindi, hi-IN | 34.3 | $0.003432 |
| Arabic, ar-SA | 10.1 | $0.001008 |
| Chinese, zh-CN | 6.6 | $0.000657 |
The English utterances take 7.5 tokens each, and the Hindi ones take 34.3. A budget for input tokens written in English tokens is therefore wrong for a Hindi user, and the same holds for the cost of a request. The counts are of the utterance alone, so they understate a whole prompt in every locale. What carries into a budget is the ratio between locales, and that ratio should be measured on the traffic that will run.
Some of the Hindi text is not in the normal form the tokenizer expects. 8 of the 200 Hindi utterances are not in Unicode normalisation form NFC, as the Unicode report on normalisation defines it. The tokenizer file normalises them before counting. The GGUF tokenizer that llama.cpp uses applies no normalisation, so its count can differ from this one on those utterances, and at most 8 of the 200 can differ; the GGUF count was not run. This chapter prints the file's count and no other, and it says which counter each number comes from. The chapter quotes no utterance text, because no example prints it.
Working rule: Count each locale with the tokenizer that serves it, after the same normalisation, and name the counter beside every figure. Budget input in the locale's own tokens, and measure the locale's ratio on your own traffic before you rely on a multiple.
The price table
Every money figure in this chapter comes from one file, the book's price table, examples/data/case/prices.toml, at version book-2026-11-02. The price table is a dated, versioned file of rates per million tokens, read at each call's virtual timestamp. For each model it gives rates in US dollars for input, cached input and output, and a date from which each row applies. The rows were written for this book, not quoted from any provider; each row says what a hosted endpoint would charge at those rates. The ratios matter most: on the 4B row, output costs 4.0 times input, and cached input 0.2 of input.
Hosted providers do not all report input the same way. Anthropic's input_tokens excludes cached tokens, and the conventions' Anthropic note asks instrumentation to add them in, so a reader pricing such a provider normalises its fields to the registry's input total before pricing. Cache writes are counted apart, in gen_ai.usage.cache_write.input_tokens. The book's runtime writes no cache, so its table has no cache-write rate.
A self-hosted model is billed by its machine, not by its tokens. The table therefore attaches a money figure to a token count so that the book can compare requests. It is not a bill for the local model, and Small Open Models works out a machine's bill against per-token prices.
The nearest real price is the genai-prices listing, and it differs from the book's rows in three ways: it names a provider, it has no cache price, and it carries no date. genai-prices 0.2.5 lists the repository Qwen/Qwen3-4B-Instruct-2507 under the provider huggingface_nscale, with an input rate and an output rate. With no cache price, the listing bills cached input at the input rate. The rates are the snapshot the library bundles, and the library makes no network call unless its updater is started. A lookup needs both the full repository name and provider_id="huggingface_nscale": without the provider it raises LookupError, and so does a provider it does not list, as the example asserts. The listing has no text-model row for Qwen3-0.6B, so the book's 0.6B row has no source. The library's 4B row has no start date, and the book's probe at the pinned version found that it prices the same request the same on 2026-11-01, 2026-11-02 and 2026-12-08. So the 2026-11-02 date in the book's table is the book's own, and the library does not supply it.
One answer request from the day, priced three ways, shows how the tables differ.
1"""Price one answer call twice: at the book's own rates, and at the genai-prices 0.2.5 listing for the 4B, which needs its2provider and a virtual timestamp (B-59). The two prices differ because the rates differ; the book's rates were written3for the book and the listing is the real one, so the prose names which is which. Money prints with its table's version."""4from decimal import Decimal56from lib.dayrun import run_day7from lib.prices import PriceTable, datetime_of8from lib.report import fmt_int, fmt_usd9from genai_prices import Usage, calc_price1011MODEL, LISTED = "Qwen3-4B-Instruct-2507", "Qwen/Qwen3-4B-Instruct-2507" # the book's name, and the listing's repo name12runs = run_day("2026-12-08")13call = next(s for run in runs for s in run.outcome.steps if s.step == "answer") # the day's first answer call14print("request, input tokens, total:", fmt_int(call.prompt_tokens))15print("request, cached input tokens, derived:", fmt_int(call.cached_tokens))16print("request, output tokens:", fmt_int(call.completion_tokens))1718book = PriceTable()19money = book.cost(MODEL, call.prompt_tokens, call.cached_tokens, call.completion_tokens, call.start_ns)20no_cache = book.cost(MODEL, call.prompt_tokens, 0, call.completion_tokens, call.start_ns)21print(f"book's table, cached input at its own rate, {book.version}:", fmt_usd(money))22print(f"book's table, the same request with no cached input, {book.version}:", fmt_usd(no_cache))23row = book.row(MODEL, call.start_ns) # the row in force at the call's start24print("book's table, output rate to input rate:", f"{Decimal(row['output_per_mtok']) / Decimal(row['input_per_mtok']):.1f}")25print("book's table, cached input rate to input rate:",26 f"{Decimal(row['cache_read_per_mtok']) / Decimal(row['input_per_mtok']):.1f}")2728usage = Usage(input_tokens=call.prompt_tokens, cache_read_tokens=call.cached_tokens, output_tokens=call.completion_tokens)29when = datetime_of(call.start_ns) # the call's virtual time, never the machine's clock30listed = calc_price(usage, LISTED, provider_id="huggingface_nscale", genai_request_timestamp=when)31print("genai-prices listing, huggingface_nscale, the same request:", fmt_usd(listed.total_price))323334def lookup_fails(*args, **kwargs) -> bool:35 """True when genai-prices cannot find a price for the call: a LookupError, not a price from another model."""36 try:37 calc_price(*args, **kwargs)38 except LookupError:39 return True40 return False414243# The listing has no cache price, so cached input bills at the input rate: the total does not change with the cache.44assert calc_price(Usage(input_tokens=call.prompt_tokens, output_tokens=call.completion_tokens), LISTED,45 provider_id="huggingface_nscale", genai_request_timestamp=when).total_price == listed.total_price46assert lookup_fails(usage, LISTED, genai_request_timestamp=when) # no provider given: no price47assert lookup_fails(usage, LISTED, provider_id="openai", genai_request_timestamp=when) # the span's provider: no price48assert lookup_fails(usage, "Qwen/Qwen3-0.6B", provider_id="huggingface_nscale", genai_request_timestamp=when)
python price-one-request.pyrequest, input tokens, total: 212
request, cached input tokens, derived: 201
request, output tokens: 27
book's table, cached input at its own rate, book-2026-11-02: $0.000016
book's table, the same request with no cached input, book-2026-11-02: $0.000032
book's table, output rate to input rate: 4.0
book's table, cached input rate to input rate: 0.2
genai-prices listing, huggingface_nscale, the same request: $0.000003
Pricing a request with its cache removed
+10 proofsFrom The price table, chapter 6Read it again
Builds on token count, from chapter 6, “Three counts for each call”
A new edition changed what this practised. What changed in Edition 2026.11.2
Line 20 takes the cached tokens out of the input count before pricing the request with no cache. Fix it so the same request is priced with all of its input at the input rate and no cached input.
Why it works
The request reads 212 input tokens, most of them cached, and writes 27 output tokens. At the book's table it costs $0.000016. With the cache removed from the same request it would cost $0.000032, so the cache is what brings the bill down for this call.
The listing prices the same request at $0.000003. The gap between the two is the gap between the rate rows, since the tokens are the same in both.
A cost tool needs one more guard. The book's spans record gen_ai.provider.name as openai, because the assistant's client speaks OpenAI's API to a local server, as chapter 2 explains. A cost tool that reads that value could look up OpenAI's rates for a model OpenAI does not serve, and price the local model at OpenAI's rates. The listing fails loudly on that lookup, since it raises LookupError for the 4B under openai, so the risk is a tool that falls back to a default model or a fuzzy match. The book's table is keyed by model and does not read the provider value, and the listing is queried with its provider named by hand. A query that prices spans should do the same, and should never take the provider from the span. MLflow is one such tool: it prices a span only when its catalog knows the span's model, which is why it stored no cost for the 4B in chapter 5, and a self-hosted model reported under a hosted model's name could be priced at that model's rates.
The table's version and dates matter once a price changes. The release comparison in chapter 10 reads its money from this same table version, so one version holds every money figure that is compared.
Working rule: Attach a price table's version and its date to every money figure. Price each call at its own timestamp, and name the provider when you use a listing. Never take a provider from a span to choose the price. We key the book's table by model, and never by the span's provider.
Cost by route and step
A call's cost is its tokens priced by a named, dated price table, and cost attribution assigns each call's cost to the step, route and user that caused it. Agent Harnesses stops its cost at counts on purpose; this book adds money, tokens first. The book computes cost at query time, from each call's tokens and the table, and does not store cost on the spans. A price change then reprices the query and leaves the stored spans as they were. Chapter 1 asked which step costs the most money, and this section answers it.
1"""Cost by step, by route, per resolved message and per user on baseline day 1, at the book's rates. Each call is priced at2its own start, and the price row in force at that time is the one used (PL-20). Every rate names its denominator (PL-11):3messages sent to the route, messages the model resolved, or users. The fallback route makes a route call and no answer call."""4from collections import Counter5from decimal import Decimal67from lib.dayrun import run_day8from lib.prices import PriceTable9from lib.report import fmt_int, fmt_share, fmt_usd1011MODEL = "Qwen3-4B-Instruct-2507"12runs = run_day("2026-12-08")13price = PriceTable()14cost, by_step = Counter(), Counter() # Decimal money per message ID, and per step name15for run in runs:16 for step in (s for s in run.outcome.steps if s.name == "chat"):17 money = price.cost(MODEL, step.prompt_tokens, step.cached_tokens, step.completion_tokens, step.start_ns)18 cost[run.message.message_id] += money19 by_step[step.step] += money20total = sum(cost.values(), Decimal(0))21print("messages:", fmt_int(len(runs)))22print(f"cost, all messages, {price.version}:", fmt_usd(total))23for step in ("route", "answer"):24 print(f"{step} requests, cost, {price.version}:", fmt_usd(by_step[step]))25 print(f"{step} requests, share of cost:", fmt_share(by_step[step], total))26assert sum(by_step.values(), Decimal(0)) == total # the two steps make up the whole cost2728for route in sorted({run.outcome.route for run in runs}):29 mine = [run for run in runs if run.outcome.route == route]30 route_cost = sum((cost[run.message.message_id] for run in mine), Decimal(0))31 print(f"route {route}, messages:", fmt_int(len(mine)))32 print(f"route {route}, cost per 1,000 messages, {price.version}:", fmt_usd(route_cost * 1000 / len(mine)))3334resolved = [run for run in runs if run.outcome.source == "model"]35resolved_total = sum((cost[run.message.message_id] for run in resolved), Decimal(0))36print("resolved messages:", fmt_int(len(resolved)))37print(f"cost of a resolved message, its own calls, {price.version}:", fmt_usd(resolved_total / len(resolved)))38by_user = Counter() # Decimal money per user ID39for run in runs:40 by_user[run.message.user_id] += cost[run.message.message_id]41assert sum(by_user.values(), Decimal(0)) == total # the users make up the whole cost42costliest = max(sorted(by_user), key=by_user.get) # ties go to the lower ID, so the choice is stable43print("users with a message:", fmt_int(len(by_user)))44print(f"cost per user, mean over users with a message, {price.version}:", fmt_usd(total / len(by_user)))45print("costliest user, messages:", fmt_int(sum(run.message.user_id == costliest for run in runs)))46print("costliest user, share of cost:", fmt_share(by_user[costliest], total))
python cost-by-route-and-user.pymessages: 200
cost, all messages, book-2026-11-02: $0.007563
route requests, cost, book-2026-11-02: $0.001379
route requests, share of cost: 18.2%
answer requests, cost, book-2026-11-02: $0.006184
answer requests, share of cost: 81.8%
route alarms, messages: 16
route alarms, cost per 1,000 messages, book-2026-11-02: $0.063688
route calendar, messages: 27
route calendar, cost per 1,000 messages, book-2026-11-02: $0.057486
route devices, messages: 17
route devices, cost per 1,000 messages, book-2026-11-02: $0.056201
route fallback, messages: 89
route fallback, cost per 1,000 messages, book-2026-11-02: $0.006630
route lists, messages: 13
route lists, cost per 1,000 messages, book-2026-11-02: $0.074429
route media, messages: 31
route media, cost per 1,000 messages, book-2026-11-02: $0.057041
route messages, messages: 7
route messages, cost per 1,000 messages, book-2026-11-02: $0.101463
resolved messages: 111
cost of a resolved message, its own calls, book-2026-11-02: $0.000063
users with a message: 121
cost per user, mean over users with a message, book-2026-11-02: $0.000063
costliest user, messages: 3
costliest user, share of cost: 3.0%
Divide each route's cost by its own messages
+10 proofsFrom Cost by route and step, chapter 6Read it again
Builds on message, from chapter 1, “One message, one trace”
A new edition changed what this practised. What changed in Edition 2026.11.2
Line 32 divides every route's cost by the messages of the whole day instead of the messages on that route. Fix it so each route's rate uses that route's own message count.
Why it works
Why the fallback route costs least
+10 proofsFrom Cost by route and step, chapter 6Read it again
Builds on message, from chapter 1, “One message, one trace”
Builds on span, from chapter 1, “One message, one trace”
A new edition changed what this practised. What changed in Edition 2026.11.2
The fallback route prints the lowest cost per 1,000 messages of any route. Which statement explains that figure?
Why it works
The answer step costs most. Over the day's 200 messages, the answer requests cost $0.006184, which is 81.8% of the day's cost. The route requests cost $0.001379, or 18.2%. The route call is smaller, but every message makes one, so it still holds nearly a fifth of the money.
The routes differ in what a message costs. The table gives each route's messages, its tokens per message from the same day, and its cost per 1,000 messages. The denominator is the messages on each route.
| Route | Messages | Input tokens per message | Output tokens per message | Cost per 1,000 messages |
|---|---|---|---|---|
alarms |
16 | 883.6 | 43.4 | $0.063688 |
calendar |
27 | 903.5 | 38.8 | $0.057486 |
devices |
17 | 627.9 | 44.5 | $0.056201 |
fallback |
89 | 145.4 | 6.0 | $0.006630 |
lists |
13 | 936.5 | 29.0 | $0.074429 |
media |
31 | 663.9 | 41.6 | $0.057041 |
messages |
7 | 1415.4 | 42.1 | $0.101463 |
The messages route costs the most per message. It rests on 7 messages, though, so read it as one day's sample and not as a settled rate. The fallback route costs the least. Its reply is the fixed one that chapter 1 describes, and its span records that no model wrote it. The route makes its one route call and no answer call, so its row carries the route call alone.
1"""Draw the input, cached and output tokens per message on each route, over baseline day 1's 200 messages. The cached part is2drawn inside the input bar, hatched, so no reader adds it to input; output stands beside it. Every bar is printed by route3with its message count, since a tokens-per-message rate names its denominator (PL-11)."""4from lib.dayrun import run_day5from lib.figures import ACCENT, INK, MUTED, new_figure, save6from lib.report import fmt_int78runs = run_day("2026-12-08")9routes = sorted({run.outcome.route for run in runs})10per_message = {} # route: (input, cached, output) tokens per message, as floats11for route in routes:12 mine = [run for run in runs if run.outcome.route == route]13 steps = [s for run in mine for s in run.outcome.steps if s.name == "chat"] # model calls only; no tool time here14 averages = tuple(sum(values) / len(mine) for values in (15 [s.prompt_tokens for s in steps], [s.cached_tokens for s in steps], [s.completion_tokens for s in steps]))16 per_message[route] = averages17 print(f"route {route}, messages:", fmt_int(len(mine)))18 print(f"route {route}, input tokens per message:", f"{averages[0]:.1f}")19 print(f"route {route}, cached input tokens per message:", f"{averages[1]:.1f}")20 print(f"route {route}, output tokens per message:", f"{averages[2]:.1f}")2122fig, ax = new_figure(height=2.8)23positions, width = list(range(len(routes))), 0.3624left, right = [p - width / 2 for p in positions], [p + width / 2 for p in positions]25cached = [per_message[r][1] for r in routes]26uncached = [per_message[r][0] - per_message[r][1] for r in routes] # input minus its cached part, stacked on top of it27ax.bar(left, cached, width=width, color=MUTED, hatch="///", edgecolor=INK, label="cached input, part of input")28ax.bar(left, uncached, bottom=cached, width=width, color=ACCENT, label="input not cached")29ax.bar(right, [per_message[r][2] for r in routes], width=width, color=INK, label="output tokens")30ax.set_xticks(positions, routes)31ax.set_ylabel("tokens per message")32ax.set_ylim(0, 1.35 * max(v[0] for v in per_message.values())) # headroom above the tallest bar for the legend33ax.legend(loc="upper center", bbox_to_anchor=(0.5, -0.16), ncol=3, frameon=False) # below the plot, clear of the top tick34save(fig, "route-token-mix")
python figure-route-token-mix.pyroute alarms, messages: 16
route alarms, input tokens per message: 883.6
route alarms, cached input tokens per message: 525.3
route alarms, output tokens per message: 43.4
route calendar, messages: 27
route calendar, input tokens per message: 903.5
route calendar, cached input tokens per message: 604.9
route calendar, output tokens per message: 38.8
route devices, messages: 17
route devices, input tokens per message: 627.9
route devices, cached input tokens per message: 305.1
route devices, output tokens per message: 44.5
route fallback, messages: 89
route fallback, input tokens per message: 145.4
route fallback, cached input tokens per message: 128.9
route fallback, output tokens per message: 6.0
route lists, messages: 13
route lists, input tokens per message: 936.5
route lists, cached input tokens per message: 385.3
route lists, output tokens per message: 29.0
route media, messages: 31
route media, input tokens per message: 663.9
route media, cached input tokens per message: 325.1
route media, output tokens per message: 41.6
route messages, messages: 7
route messages, input tokens per message: 1415.4
route messages, cached input tokens per message: 711.7
route messages, output tokens per message: 42.1
figure: figures/route-token-mix.svg
Figure 6.1 shows each route's input tokens per message, with the cached part inside the input bar, and its output tokens beside it. A route can be cheap in output and still expensive in prompt.
Figure 6.1 shows that the lists route writes the least output of any route but the fallback route, 29.0 tokens per message, and still reads 936.5 input tokens per message. The messages route reads 1415.4 input tokens per message, of which 711.7 are cached. Every route reads far more than it writes.
Two per-unit figures close the section, each with its denominator. A resolved message costs $0.000063 in its own calls, over the 111 messages the model answered. Per user, the day costs $0.000063 on average, over the 121 users who sent a message that day.
The costliest of those users sent 3 messages and holds 3.0% of the day's cost.
Working rule: Attribute each call's cost to its step, route and user from each call's recorded counts, print each share beside its total, and name the denominator of every per-unit rate. Read a route's rate with its message count beside it, because a route with a handful of messages can move a lot from one day to the next. For the finance question we report each route's rate, not one mean over the day, because the money differs by route.
The expensive tail
An average hides the few messages that cost much more than the rest. The check is to rank the messages by cost and ask what share of the day's money the top 1% holds. With 200 messages, the top 1% is two messages.
1"""The most expensive 1% of baseline day 1's messages, and their share of the day's cost at the book's rates. The count is2exact over the day's 200 messages, with no interval: an interval for another day is chapter 7's. The count is the3nearest-rank count for 1% of n (PL-5), and equal costs are ordered by message ID so the choice is stable."""4import math5from decimal import Decimal6from fractions import Fraction78from lib.dayrun import run_day9from lib.prices import PriceTable10from lib.report import fmt_int, fmt_share, fmt_usd1112MODEL = "Qwen3-4B-Instruct-2507"13runs = run_day("2026-12-08")14price = PriceTable()15cost = {} # Decimal money per message ID16for run in runs:17 cost[run.message.message_id] = sum((price.cost(MODEL, s.prompt_tokens, s.cached_tokens, s.completion_tokens,18 s.start_ns)19 for s in run.outcome.steps if s.name == "chat"), Decimal(0))20ranked = sorted(runs, key=lambda run: (-cost[run.message.message_id], int(run.message.message_id)))21k = math.ceil(Fraction(1, 100) * len(runs)) # 1% of 200 is 2 messages22tail = ranked[:k]23total = sum(cost.values(), Decimal(0))24tail_money = sum((cost[run.message.message_id] for run in tail), Decimal(0))25print("messages:", fmt_int(len(runs)))26print("messages in the most expensive 1%:", fmt_int(k))27print(f"cost of the day, {price.version}:", fmt_usd(total))28print(f"cost of the most expensive 1%, {price.version}:", fmt_usd(tail_money))29print("share of the day's cost, most expensive 1%:", fmt_share(tail_money, total))30print("most expensive message, route:", tail[0].outcome.route)31print(f"most expensive message, cost, {price.version}:", fmt_usd(cost[tail[0].message.message_id]))32print("most expensive 1%, messages resolved by the model:", fmt_int(sum(run.outcome.source == "model" for run in tail)))33assert tail_money * len(runs) > total * k # the tail costs more per message than the day does on average
python expensive-tail-share.pymessages: 200
messages in the most expensive 1%: 2
cost of the day, book-2026-11-02: $0.007563
cost of the most expensive 1%, book-2026-11-02: $0.000234
share of the day's cost, most expensive 1%: 3.1%
most expensive message, route: messages
most expensive message, cost, book-2026-11-02: $0.000118
most expensive 1%, messages resolved by the model: 2
On this day there is no concentrated expensive tail. The two most expensive messages cost $0.000234 of the day's $0.007563, which is 3.1% of the cost. The most expensive of them, on the messages route, cost $0.000118. Both of the top two were resolved by the model, so the tail is an answer tail, not a fallback one.
The count is exact over one day, so it says what this day's messages cost and nothing about another day. How far another day would move the share needs a method this chapter does not use. The method is the bootstrap, which applies to any per-message statistic, and chapter 7 introduces it. Until then, a tail on one day is a count to report with its denominator, and not a rate to plan a budget on.
Working rule: Report the top 1% of messages as a count and as a share of the day's total, with the day named. Do not call a share small or large until a second day gives something to compare it with.
What goes wrong in production
A token total on a dashboard can double after a gateway or a rollup starts carrying the usage of the calls beneath it, and nothing else in the pipeline changed. The sum over spans counts those tokens twice. Read totals from the counters, or filter the spans by operation name, as the conventions' note says.
A dashboard total read from spans halves when the backend starts keeping half its traces, because the spans fall with the sample. The counters are unaffected. Keep the counters for totals, and keep the spans for questions the counters cannot answer, such as which route a message took. Chapter 11 scales a sampled total up, with its error.
The bill moves while the input count stays flat, because a release changed how much of the prompt was cached. A dashboard that tracks input tokens alone misses the change. Track cost beside input and cached input, and read the cached count against the release it belongs to.
A local model is priced at a hosted provider's rates when a cost tool takes the provider from the span, and the span says openai. The listing fails loudly on that lookup, so the danger is a tool that falls back to a default model or a fuzzy match. The book's table is keyed by model, and a listing is queried with its provider named. Any tool that prices a span should do the same.
A month's cost changes on the day a price changes, though no message did. Each row in the book's table carries a valid-from date, and each call is priced at its own timestamp. A cost stored on a span would keep the old price, so the book computes cost at query time.
A budget set in English tokens fails for Hindi users, and the difference lies in the vocabulary, not in the traffic. Measure each locale's ratio on the traffic that will run, and count with the tokenizer that serves the locale.
Working rule: Keep totals on the counters, cost on the table with its version, and each locale's count on its own tokenizer. When a release changes the prompt or the cache, read its cost next to its tokens, because the two can move apart.
What this chapter decided
- Tokens come first and money second. Every money figure names the price table's version,
book-2026-11-02, and its date. - Input tokens include the cached part. Cached input is derived from the runtime's counters, and it is never added to input.
- Totals come from the counters. A sum over spans is taken over inference spans only, filtered by operation name. An agent span's usage is that agent's total, and it is never added to the calls' usage.
- Cost is computed at query time from the table and each call's timestamp. It is not stored on spans.
- The cache-off release is called reset per call, because the pinned runtime has no switch for the cache.
- Locale counts use the tokenizer file, after NFC normalisation, and the chapter prints no GGUF count. Utterance text is not quoted, because no example prints it.
- The chapter uses no interval, because a one-day count is exact and needs none. Chapter 7 gives the method for another day's spread.
- The prices are the book's judgement: dated, versioned and not a quote. A reader who prefers another price changes the table and keeps the counts, and every sentence about tokens still holds. That split is why the chapter does the tokens first.
This chapter, in this edition
Edition 2026.11.2Examples passed Nov 23, 20268 of 8 examples in this chapter pass
This book is open to contributions, so anyone can check it or correct it. Found something wrong? Report it with the section's ID, the last part of the link beside each heading, or fix it yourself with a pull request.