B2BB2B LLM

Estimate input size

Inspect Anthropic input token counts without generating a completion.

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.