Estimate input size
Inspect Anthropic input token counts without generating a completion.
No current prepared translation is available. The English source is shown without machine translation.
Use POST /v1/messages/count_tokens when preparing an Anthropic Messages request. Supply the same model and relevant system/conversation/tool content that will be sent for inference. A token estimate is not an output token forecast or a settled monetary charge.
Request
curl https://api.b2b-llm.com/v1/messages/count_tokens \
-H "x-api-key: $B2B_API_KEY" -H 'anthropic-version: 2023-06-01' \
-H 'Content-Type: application/json' \
-d '{"model":"claude-sonnet-4.6","messages":[{"role":"user","content":"Check the purchase-order summary."}]}'
Response
{"input_tokens":14}
The count is an example. Capability and provider support are still required. Do not send async: true or streaming options to turn an estimation operation into an inference job. Use actual request history for final token categories and charges after executing a model request.
Count request budgets
This free estimation endpoint accepts at most one incoming request per rolling 1000 ms, 30 per rolling 60 seconds and 500 per rolling 24 hours per Principal User ID, shared across all of that user's API keys. Successful counts (200) and upstream invalid requests (400) are cached for 60 seconds; for 400, only the gateway-approved public error payload is stored and replayed with HTTP 400. Cache hits still consume the request budget. Authorization failures, upstream 429/5xx and local validation failures are not cached. HTTP 429 includes Retry-After; refused attempts neither consume quota nor extend the one-second interval. These budgets are separate from inference RPM and do not create charges.