liveBook · Manning

Token count

Also called token usage, token consumption

A token count is a measure of the number of tokens present in text or processed or generated during a model or corpus operation.

How 6 Manning books explain it

Build AI-Enhanced Web Apps

Token usage is the quantity of input and output tokens consumed by a language-model interaction.

How it is used
Tracks model-call usage for cost management and conversation-history size for token-limit management.
How deep it goes
Shows callback-based usage tracking and describes history counting, while leaving unsupported models to custom solutions.
Examples
Uses a TokenTracker callback for a Gemini model and conversation-history monitoring with js-tiktoken.
What you can do after
Apply it via LangChain.js callbacks and js-tiktoken to monitor call usage and conversation history.

Read how Build AI-Enhanced Web Apps explains token count →

Designing AI Systems

Token usage is the quantity of language-model input and output tokens consumed by an AI operation.

How it is used
Supports per-request cost attribution and aggregated spending analysis across AI workflows.
How deep it goes
Defines prompt, completion, total, and cache-related metrics and specifies request-level recording and aggregation.
Examples
Shows a chat response with 847 prompt tokens and 156 completion tokens and a request-metrics dataclass.
What you can do after
Diagnose spending drivers and prompt bloat using token metrics grouped by workflow, model, user, and time.

Read how Designing AI Systems explains token count →

Spring AI in Action

Token usage is the measured quantity of input and output tokens consumed during a language-model interaction.

How it is used
Tracks language-model consumption to estimate billing, control prompt costs, and observe Spring AI operations.
How deep it goes
Explains input, output, and total counts, metric tags, Java logging, and Actuator queries, but not tokenization internals.
Examples
Demonstrates board-game prompts, ChatResponse logging, and filtered Actuator measurements for input, output, total, model, and operation.
What you can do after
Diagnose token spending by logging ChatResponse metadata and querying gen_ai.client.token.usage with filtering tags.

Read how Spring AI in Action explains token count →

Machine Learning Platform Engineering

Token usage is the quantity of language-model input and output tokens consumed during an interaction or application operation.

How it is used
Monitors LLM resource consumption for efficiency, observability, performance analysis, and operational cost control.
How deep it goes
Explains input/output ratios, reasoning-step allocation, prompt reduction, tracing, alerts, and budgets without specifying tokenizer internals.
Examples
Uses verbose and concise prompts, Langfuse traces, RAG pipelines, token ratios, cost dashboards, alerts, and budget thresholds.
What you can do after
Diagnose/debug with Langfuse by tracing token usage, locating expensive operations, and validating prompt reductions against quality and safety.

Read how Machine Learning Platform Engineering explains token count →

Vibe Engineering

Token consumption is the quantity of language-model input and output tokens used by an AI system or user over a defined period.

How it is used
Uses token consumption to monitor AI-agent pipelines, surface anomalous spend, and investigate bottlenecks.
How deep it goes
Explains metric misuse, rebound effects, cost arithmetic, and dashboard monitoring without descending into model internals.
Examples
Uses token leaderboards, cost comparisons, interaction growth, and an agent-pipeline dashboard as concrete examples.
What you can do after
Diagnose/debug with it by correlating token spikes, agent failures, queue delays, costs, and remaining work.

Read how Vibe Engineering explains token count →

How Large Language Models Work

The quantity of tokens consumed as input to or produced as output by a language model.

How it is used
Tracks model input and output to explain cost, latency, capacity, and language representation.
How deep it goes
Explains BPE-driven counting with a worked comparison, but stops short of formal tokenizer algorithms.
Examples
Uses GPT-3 tokenizations of “I’m running” and “I’m runnin,” plus cross-language cost comparisons.
What you can do after
Evaluate tokenization-related cost, latency, language disparities, and software differences before deploying or upgrading systems.

Read how How Large Language Models Work explains token count →

Also covered in

What to know first

Related concepts

Questions about token count

What is token count?

A token count is a measure of the number of tokens present in text or processed or generated during a model or corpus operation.

Which Manning books explain token count?

Build AI-Enhanced Web Apps, Designing AI Systems, Spring AI in Action, Machine Learning Platform Engineering, Vibe Engineering and How Large Language Models Work.

What should I know before learning token count?

Manning books that teach token count usually introduce language model, context window, token and prompt first.

What is token count also called?

Token count is also called token usage or token consumption.

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.