SDK & Integration · 2 min · Updated 2026-10-20

LiteLLM cost tracking

Track every LiteLLM completion with one callback

Setup

Install with the LiteLLM extra (pip install "tokeven[litellm]"), set TOKEVEN_INGEST_TOKEN to your ingest token, then register the logger:

import litellm
from tokeven.integrations.litellm import TokevenLogger

litellm.callbacks = [TokevenLogger()]

What it captures

One event per successful completion or acompletion, sync and async, streaming included once LiteLLM assembles the final response. It also works on the LiteLLM proxy. The logger reads only response.usage, the response model and LiteLLM's resolved provider, never message text.

Responses LiteLLM serves from its own cache are not reported: no provider call was made, so there is no spend.

Budget guard

When a tokeven.guard budget is active, async calls (acompletion and the Router) are checked before the request goes out. A bare sync litellm.completion is not enforced; call tokeven.guard.check() yourself before it.

Track your real costs

Calculators estimate. The dashboard shows what you actually spend and where you can save.