#26324 [Bug] acount_tokens: Anthropic count path skips chat-completions → native translation; standard chat-format payloads rejected with 400
## Environment - litellm `1.83.4` and `1.83.12` - Provider: `anthropic` - Python 3.13
## What breaks
`litellm.acount_tokens(model='anthropic/…', messages=…, tools=…, system=…)` is documented as taking "standard chat format" (chat-completions / OpenAI-shape). For any realistic agent payload — tool-role messages, function-typed tools, system-role messages — Anthropic returns 400 and `acount_tokens` silently falls back to the local tiktoken counter.
Sample errors:
- `messages: Unexpected role "tool". Allowed roles are "user" or "assistant".` - `messages: Unexpected role "system". The Messages API accepts a top-level system parameter, not "system" as an input message role.` - `tools.0: Input tag 'function' found using 'type' does not match any of the expected tags: 'custom', 'bash_20250124', …`
Meanwhile the regular chat-completion path (`litellm.acompletion(...)`) handles these inputs fine because it runs them through `AnthropicConfig.transform_request` which does the chat-completions → Anthropic Messages translation (fold tool-role into user content blocks, strip the `function` wrapper off tools, lift system to top-level, etc.).
## Root cause
`AnthropicCountTokensHandler.handl…