1. Tokens, not characters
Models read text as tokens — roughly four characters each — not as raw characters.
// text is split into tokens (~4 chars each)Typorithm · easy
Step 1 of 8 · intro card
Context & Tokens
Models process tokens, not characters — about four characters per token. The context window caps input and output tokens together, so very long prompts cost more and can bury the details that matter. Count tokens before sending to stay within limits and budget.
Claude reads text as tokens, each roughly four characters. A short English word is often one token; code and non-English text tokenize into more. The model never sees raw characters — token counts are what drive cost and limits.
The context window is a hard ceiling on input plus output tokens combined. A prompt that nearly fills the window leaves little room for the response, and very long prompts can bury the key details among less relevant text.
Call client.messages.countTokens with the same model and messages you plan to send. It returns input_tokens so you can budget cost and confirm the request fits before you ever pay for the full call.
Tokens, not characters: ~4 characters per token.
The context window caps input + output together.
countTokens estimates a request before you send it.
// text is split into tokens (~4 chars each)
const count = await client.messages.countTokens({
model: "claude-opus-4-8",
messages,
});
// the context window caps input + output tokensConnect each part of the code to the concept before you type.
Models read text as tokens — roughly four characters each — not as raw characters.
// text is split into tokens (~4 chars each)countTokens measures a request's token usage before you send it, so you can budget and stay within limits.
const count = await client.messages.countTokens({Token counts are model-specific, so countTokens takes the same model id you will run inference with.
model: "claude-opus-4-8",You count the exact messages you plan to send — the count reflects that real payload.
messages,The context window bounds input plus output together, so long prompts cost more and can crowd out key details.
// the context window caps input + output tokensRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.