Menu

Prompting techniques and their token cost: system prompts, few-shot, chain-of-thought and injection
📰

Prompting techniques and their token cost: system prompts, few-shot, chain-of-thought and injection

DEV Community: ai·Gary Walkers·5 days ago
#KWrsG7tO
#devtoai#devto#dev#prompt#tokens
Reading 0:00
15s threshold

Every word in a prompt is billed, so each technique has a token cost. Here is what the vendors and papers say, with counts I measured using OpenAI's o200k_base tokenizer.

System prompts are billed on every request

My 225-word support-bot prompt is 275 tokens. At 1,000 requests a day that is 8.25M input tokens a month: $16.50 on Claude Sonnet 5.5 or GPT-6.1 Sol, $0.825 on Haiku 5.5. It will not cache on its own: Anthropic's minimum cacheable prompt for Sonnet 5.5 is 512 tokens and OpenAI's is 1,024 ( Anthropic prompt caching , OpenAI prompt caching ). To count your own prompts, a browser token counter works without uploading anything.

Few-shot: about 18 tokens per example

In a five-category email classifier, zero-shot is 44 tokens and each example adds about 18, so 10 examples add 181 tokens to every request, or $36.20 per 100,000 requests on Sonnet 5.5. Anthropic recommends 3 to 5 diverse examples ( prompting best practices ); the original result is Brown et al. (2020) .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.