LiteLLM

Record LiteLLM inference cost by customer and feature without sending model content.

Use one recording path per request: the existing function callback, VeqenLogger, or the hosted logging endpoint. Combining them records the same request twice.

Python and proxy CustomLogger

Install the SDK with LiteLLM support:

pip install 'veqen[litellm]>=1.1.0'

Create veqen_callback.py beside the proxy configuration:

import veqen
from veqen.integrations.litellm_logger import VeqenLogger

veqen.init()  # reads VEQEN_API_KEY; use an ingest-only key
veqen_logger = VeqenLogger()

Register the instance in the proxy:

litellm_settings:
  callbacks: [veqen_callback.veqen_logger]

For a Python application, set litellm.callbacks = [VeqenLogger()] after veqen.init(). The logger handles synchronous and asynchronous terminal callbacks. Intermediate streaming chunks and deployment-attempt hooks do not record additional calls. It queues only allowlisted model, usage, timing and attribution fields; prompts, responses, exception text and request headers are not copied.

Pass attribution in metadata={"veqen": {"customer": "acme", "feature": "chat"}}. Use pseudonymous identifiers, not customer contact details. CustomLogger observes completed calls; it cannot stop a call that has already run. Use Veqen's wrapper and budget checks for pre-call enforcement.

Hosted logging endpoint

POST https://veqen-app.com/v1/integrations/litellm accepts a JSON array of LiteLLM StandardLoggingPayload records, or one record. Authenticate with Authorization: Bearer <ingest-key>. It shares the normal ingest rate and plan limits and accepts at most 1,000 records per request. Responses report accepted, duplicates, dropped and per-record rejected errors. Retries use LiteLLM's request identifier and completion timestamp, so an identical export is recorded once per organization.

The endpoint discards raw content, headers and arbitrary metadata. Configure redaction at the sender too: a generic HTTP logger can otherwise transmit model content before Veqen discards it. LiteLLM's turn_off_message_logging: true removes model content from its logging payload, but does not remove every metadata field. Prefer VeqenLogger when only cost metadata may leave your process. The built-in callback submission is separate from availability in a released LiteLLM version; do not configure a callback name your installed version does not recognize. Generic custom-endpoint logging may require a LiteLLM Enterprise license.

Normalized cache tokens come from the payload's hidden_params.usage_object or metadata.usage_object. If those details are absent, only the exported aggregate token counts are available. Known models are priced by Veqen's current price book or your custom prices; unknown models retain LiteLLM's reported cost, labeled reported. Neither calculation is proof of agreement with an invoice—use provider reconciliation. Proxy cache hits have no new provider charge and are recorded at zero cost.

See the LiteLLM callback documentation, logging specification and redaction controls.