The TotalTokens property returns the total number of tokens
used by the most recent request and response. This value includes
both the input tokens associated with the prompt and conversation
history, and the output tokens generated by the model.
This property is updated after a successful call to the
Ask or SendMessage method. If token usage information
is not available, this property will return zero. The value returned
by this property is equivalent to the sum of the InputTokens
and OutputTokens properties.
Token usage is reported by the provider when available. Some
providers or locally hosted models may not return precise token usage
information, particularly when using older models or third-party
inference servers. In those cases, the values returned by this
property may be estimated or unavailable.
Tokens do not directly correspond to characters or words,
but as a general approximation, one token represents about 3-4
English characters. The exact number of tokens depends on the
language, formatting, and content being processed.
Applications can use token usage information to estimate usage
costs, monitor context usage, or help determine appropriate
MaxTokens and HistorySize settings for a session.