#31149 [Bug]: Anthropic `/v1/messages/count_tokens` ignores custom `api_base` despite repeated production reports
## Summary
`/v1/messages/count_tokens` still does not consistently respect a custom `api_base` for Anthropic compatible deployments.
This has already been reported multiple times.
Related issues:
1. #26323 2. #29764 3. #30217
They all point to the same core problem.
## Problem
When `custom_llm_provider: anthropic` is configured with a custom `api_base`, every Anthropic native subrequest should use that same resolved backend.
That is not happening.
`/v1/messages` can route to the configured backend, while `/v1/messages/count_tokens` can still fall back to `api.anthropic.com`.
This is not a tokenizer issue. It is a proxy routing bug.
## Production impact
This breaks real production deployments using LiteLLM with self hosted Anthropic compatible backends.
This includes setups such as:
1. vLLM Anthropic compatible endpoints 2. Claude Code routed through LiteLLM 3. internal enterprise gateways 4. isolated or restricted network environments
Production users should not have to keep patching around the same `api_base` propagation bug.
## What is frustrating
This has been reported more than once with clear details.
The expected behavior is simple. If a deployment has a cus…