pub struct TokenUsage {
pub prompt_tokens: u32,
pub cached_input_tokens: Option<u32>,
pub cache_write_tokens: Option<u32>,
pub completion_tokens: u32,
pub total_tokens: u32,
pub tool_call_count: Option<u32>,
pub prompt_eval_nanos: u64,
pub eval_nanos: u64,
pub total_nanos: u64,
pub load_nanos: u64,
pub advisor: Option<AdvisorTokenUsage>,
}Expand description
Token usage statistics from the LLM.
Fields§
§prompt_tokens: u32Number of tokens in the prompt (input).
cached_input_tokens: Option<u32>Input tokens served from cache, when the provider reports them.
cache_write_tokens: Option<u32>Input tokens written to the provider’s prompt cache, when the provider
reports them. Written input is priced apart from fresh input and from
cache reads, so a spend figure needs it. These tokens are part of
prompt_tokens.
completion_tokens: u32Number of tokens generated by the model (output).
total_tokens: u32Total tokens consumed (prompt + completion).
tool_call_count: Option<u32>Tool/function calls consumed during the request, when reported.
prompt_eval_nanos: u64Time to evaluate the prompt (nanoseconds). Ollama: prompt_eval_duration.
eval_nanos: u64Time to generate completion tokens (nanoseconds). Ollama: eval_duration.
total_nanos: u64Total wall-clock time for the request (nanoseconds). Ollama: total_duration.
load_nanos: u64Time spent loading the model (nanoseconds). Ollama: load_duration.
advisor: Option<AdvisorTokenUsage>What a second model, offered to the answering one as an advisor, spent
on this request. It is billed at the advisor’s rates, so it is not in
the counts above. None where no advisor was offered or the provider
has none.