Expand description
Pure token estimation for LLM requests
Estimation layer built on top of TokenEstimator: counts messages,
tools, and multimodal content. Transport-level counting (provider
count-tokens API first, estimation as fallback) lives in
client::LlmClientImpl::count_tokens_inner; this module never touches
HTTP clients or codecs.
Functionsยง
- default_
estimator - Estimator used by counting helpers.
- estimate_
image_ tokens - Estimate tokens for an image reference.
- estimate_
message_ tokens - Estimate tokens for a single message: content (text / rich blocks), thinking, tool calls, plus a fixed metadata overhead per message.
- estimate_
messages - Estimate the token count of the current conversation messages.
- estimate_
request_ tokens - Estimate tokens for a full LLM request: messages + tool declarations.
- estimate_
tool_ declarations - Estimate tokens for tool declarations alone (the per-request dynamic overhead that never accumulates into a message-array ledger).