Nivå 3 — Advanced

Streaming and tokens

Streaming gives instant response in the user interface. Tokens are the currency you pay with. Learn both concepts thoroughly.
📅 21.05.2026 👁 63 views 🇳🇴 Les på norsk

What is streaming?

Without streaming the user waits until Claude has finished the entire answer before anything is shown. With streaming words appear one by one — just like when you see Claude write in claude.ai. This gives a dramatically better user experience.

Without streaming — the user stares at an empty screen for 5–30 seconds, then the entire answer appears at once.
With streaming — first word appears after 0.5–1 second. The user sees Claude "thinking" in real time. Perceived waiting time is reduced dramatically.

What are tokens?

Tokens are the basic units Claude processes text in. Not words, not characters — but something in between. Understanding tokens is important because you pay per token and because the context window is measured in tokens.

💡 Token examples:
"Hello" = 1 token
"artificial intelligence" = 3 tokens
Long compound words use more tokens than short simple words.

Control costs with max_tokens

✅ Rules of thumb for max_tokens:
Simple question/answer → 256–512 tokens
Article or report → 2,000–4,000 tokens
Long code generation → 4,000–8,000 tokens
⚠️ Common mistake:
Setting max_tokens too low so Claude cuts the answer mid-sentence. Always check stop_reason in the response — if it is "max_tokens" instead of "end_turn" the answer was cut off.
"Tokens are not just currency — they are attention. Use them on what matters." — On conscious token budgeting
Nothing is too great or too small to bring before God.
— Florence Scovel Shinn

🎯 Test your knowledge

Test yourself — completely optional, but fun! 🎯

Question 1 of 3

Question 1 of 3

What is the most important user experience benefit of streaming?

Streaming shows the first word after 0.5–1 second — the user sees Claude thinking in real time and perceived waiting time is reduced dramatically.

Question 2 of 3

Question 2 of 3

What does it mean if stop_reason in the API response is "max_tokens"?

The answer was cut off because it reached the max_tokens limit — Claude has not finished the answer. Increase max_tokens to get the full answer.

Question 3 of 3

Question 3 of 3

Why do output tokens cost more than input tokens?

Output tokens require more computation to generate than to read — Claude must actively produce each token, not just process them.
Share:

Read also