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-4-5-20251001" # 60x cheaper
elif task_type in ["implement", "fix_bug"]:
return "claude-sonnet-4-6"
else:
return "claude-opus-4-6" # only for complex stuff
That's it. About 60% of my API calls are simple tasks. Routing them to Haiku instead of Opus cuts my bill in half with zero quality difference on those tasks.
The expensive model is for when you need it. Not for renaming a variable.
Top comments (0)