Nearby lessons

39 of 49

Prompt Engineering - Tokens and Cost

Tokens — Cost and Performance

A token is a small piece of text that AI reads — AI processes your prompt token by token, roughly word by word.

  • More tokens → more processing → more cost.
  • Short prompts = low tokens = low cost.
In simple words: Less tokens = more efficiency. Smart engineers optimize, not just create.
Long PromptOptimized Prompt
High tokensLow tokens
ExpensiveCheap
SlowFaster
ClutteredEfficient

The bus-ticket example:

  • Short distance → low cost.
  • Long distance → high cost.

In AI: short prompt = low tokens = low cost. In real projects every API call costs money — minimize tokens without losing meaning.

Example01
Prompt PreviewChatGPT-style
LONG: Can you please explain in detail how Python loops work for beginners with examples? ~ 15 tokens SHORT: Explain Python loops with simple examples for beginners ~ 8 tokens Same meaning, nearly half the tokens.
Copy the prompt and paste it into ChatGPT, Gemini, or Claude to try it.
📝 Key Takeaways
  • A token is a small piece of text that AI reads — roughly word by word.
  • More tokens means more processing and more cost.
  • Short prompts = low tokens = low cost.
  • The bus-ticket example: short distance = low cost, long distance = high cost.
  • Every API call costs money — minimize tokens without losing meaning.
  • Smart engineers optimize, not just create.

🧠 Test Your Knowledge

2 Questions
Progress: 0 / 2