Token problems: 7 of 20

By Prof. Tom Yeh

Published: 2026-05-28

URL: https://www.byhand.ai/p/library-agents-tokens-two-kinds-of-token


Token problems: the workbook

  1. Count the Tokens
  1. Subword Splitting
  1. Punctuation Counts
  1. Tokens per Word
  1. Will It Fit?
  1. The Price of a Call
  1. Two Kinds of Token
  1. Input or Output?
  1. The Two-Part Bill
  1. End-to-End Call Cost
  1. Comparing Three Calls
  1. The Average Call
  1. The System Prompt
  1. The System Prompt Tax
  1. Calls in a Budget
  1. Tokens on a Budget
  1. How Long Will It Take?
  1. The Split Matters
  1. Pricing per Million Tokens
  1. Tokens from the Bill

Are all tokens the same? No. There are two kinds: input tokens (what you send) and output tokens (what the model generates, one at a time). Both are counted the same way, but output tokens cost more. Every agent call produces both: the prompt is input, the reply is output.

Problem

An AI agent is sent the input why do cats purr? and returns the output a cat purrs when it feels happy!. Tokenize the input and the output, then count the tokens of each kind.

Tokenize the input

Tokenize the output

Count the tokens of each kind

Practice 1

An AI agent is sent the input how many moons does the planet Jupiter have? and returns the output the planet Jupiter has ninety five moons!. Tokenize the input and the output, then count the tokens of each kind.

Tokenize the input

Tokenize the output

Count the tokens of each kind

Practice 2

An AI agent is sent the input is the sun a star? and returns the output yes, the sun is a star.. Tokenize the input and the output, then count the tokens of each kind.

Tokenize the input

Tokenize the output

Count the tokens of each kind


Next: 8. Input or Output?