class

Autobot::Logging::TokenTracker

Inherits Reference < Object

Tracks cumulative token usage across LLM calls.

Thread-safe via Mutex. Call record after each LLM response and summary to get a human-readable overview.

Constants

Log = ::Log.for("tokens")

Instance methods

record(prompt_tokens : Int32, completion_tokens : Int32, model : String = "") : Nil

Record token usage from a single LLM response.

Source
reset
Source
summary

Human-readable summary.

Source
total_completion_tokens
Source
total_prompt_tokens
Source
total_requests
Source
total_tokens

Total tokens used across all requests.

Source