DEV Community
•
2026-04-19 15:14
The Opus 4.7 Tokenizer Ate Your Budget (30-Second Fix)
Opus 4.7 uses a new tokenizer. Same code, same prompt, 25-35% more tokens. If your Claude bill jumped this week, that's why.
The Fix
# Before: everything goes through Opus
response = client.messages.create(model="claude-opus-4-6", ...)
# After: match the model to the task
def pick_model(task_type):
if task_type in ["rename", "format", "docstring"]:
return "claude-haiku-...