Skip to content
v0.8.4stable

Token counting

POST /v1/messages/count_tokens  compatible  semantic operation generate  contract revision 1

State semantics: stateless; served natively against one direct Anthropic connection

Raw contract deviations

These statements are source-contract evidence. Use the examples, field table, and Profile coverage matrix for ordinary integration, and expand this list when investigating a compatibility boundary.

  • only the direct Anthropic Messages provider profile serves this endpoint; Bedrock Mantle shares the Messages wire format but its count_tokens surface is not established
  • the request body reaches the provider verbatim with only the upstream model identifier substituted, so there is no portable execution mode to select
  • count_tokens has no input/output token billing span, so Halro settles zero under ordinary per-token prices; a configured fixed per-request fee is still charged — it is a real provider call on the operator’s credential, so it takes a ledger attempt and appears in the audit trail like any other
  • the reported count is Anthropic’s, for the upstream model behind the alias; it is not re-derived by Halro

Count tokens before generation. This endpoint does not stream and rejects Halro-Route-Mode: portable.

Terminal window
curl https://halro.example.com/v1/messages/count_tokens \
-H "x-api-key: $HALRO_GATEWAY_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{ "model": "claude",
"messages": [{"role": "user", "content": "Hello"}] }'
  • x-api-key or Authorization
  • anthropic-version
  • anthropic-beta
  • Content-Type
Request fields
FieldProvider Profiles that do not support itCombination-level constraints
model
messages
messages[].role
messages[].content
system
tools
tool_choice
thinking
output_config

Halro rejects these fields before any Provider I/O:

  • stream
  • Halro-Route-Mode: portable
  • unknown top-level fields

input_tokens

Provider Profile contract coverage and current availability

Section titled “Provider Profile contract coverage and current availability”
Provider Profile contract coverage and current availability
Provider ProfileMaturityCurrent buildUnsupported request fields
anthropic.messages.2023-06-01compatiblecreatableundeclared
anthropic.messages.2023-06-01
  • only the model identifier is substituted; every other member is forwarded unchanged

Verified evidence: gateway_contract, provider_transport_fixture, sdk_blackbox

anthropic-go, anthropic-typescript, anthropic-python

See Anthropic native features and Token Count.


Fields, coverage, transformations, and deviations are generated from Halro 8f185de7674c (scripts/generate-api-pages-en.mjs; synchronized manifest digest 8e5e7a0a794721aa…). The synchronized copy contains 1 recorded accuracy correction(s); source manifest digest b321ee18ad2e38f3…. The contract currently carries field names, not complete types, required relationships, or value semantics.