PulseAugur
EN
LIVE 19:14:13

Developer finds OpenAI's tiktoken library miscounts Claude tokens by up to 38%

A developer discovered that OpenAI's `tiktoken` library significantly underestimates token counts for Anthropic's Claude models, leading to unexpected API errors and budget overruns. Across 4,200 requests, `tiktoken` estimates were a median of 17.4% lower than the actual billed tokens, with code-heavy prompts being as much as 38% underestimated. The developer also found that crucial components like tool definitions and system prompts were often omitted from manual token estimations. The recommended solution is to use the `/v1/messages/count_tokens` endpoint for accurate, real-time token counts, despite the added latency of an extra API call. AI

IMPACT Highlights the need for accurate token counting in LLM applications, impacting cost management and reliability.

RANK_REASON Developer discovers a practical issue with a common tool (tiktoken) when used with a specific AI model (Claude), leading to a recommended workaround.

Read on dev.to — LLM tag →

AI-generated summary · Google Gemini · from 1 sources. How we write summaries →

Developer finds OpenAI's tiktoken library miscounts Claude tokens by up to 38%

How we ranked this

Signal score
28 / 100
Composite score across the factors below. Higher = stronger signal that this story matters right now.
Newsworthiness bucket
Tool
Developer discovers a practical issue with a common tool (tiktoken) when used with a specific AI model (Claude), leading to a recommended workaround.
Source corroboration
Single-source cluster
Only one publisher covered this so far. Single-source stories can still rank when the publisher is high-authority, but they lack cross-source corroboration.
Topics
infra
Editorial topic classification. Feeds into how the story surfaces on /topic/<slug> hub pages and into the per-entity coverage mix.
AI-industry relevance
High
Clearly on-topic for AI-industry coverage.
Story freshness
Breaking (< 6h)
Fresh story with cross-source coverage still developing. Ranking may shift as more sources report.

Full methodology in our editorial standards.

COVERAGE [1]

  1. dev.to — LLM tag TIER_1 Nederlands(NL) · jidonglab ·

    tiktoken vs count_tokens: My Claude Budget Was 17% Off

    <p>My budget guard said the prompt was 171,000 tokens. Haiku 4.5's context window is 200,000. Plenty of room. The API returned a 400 anyway: prompt too long.</p> <p>That was run 1,102 of a pipeline I'd been babysitting for three weeks, and it was the first time I seriously questi…