Skip to main content

Set up

LiteLLM Proxy can be self-hosted or cloud-hosted by LiteLLM. Either way, each proxy has its own address, so the SDK cannot recognize it automatically. Pass the LiteLLM recipe with your proxy’s base URL:
To change how cost is counted, set unitsPerDollar on the recipe. See Gateways for the options.

What is reported

LiteLLM Proxy is a gateway, self-hosted or cloud-hosted: one API in OpenAI’s format in front of many model providers. Every response includes a usage object in OpenAI’s format with the token counts. LiteLLM also prices each call itself and returns that price in the x-litellm-response-cost response header. The wrapper reads both and reports them to Stigg as the metrics below. For details, see LiteLLM’s cost tracking and response headers docs. Chat Completions Responses Cached tokens are counted inside prompt_tokens and input_tokens. If you price both the input metric and cached_tokens, cached tokens are billed twice. total_tokens includes all the token counts above, so price the total or the parts, never both. Each event also carries:
Response headers are sent before the model generates anything, so a streamed LiteLLM call cannot carry a cost. Streamed calls report tokens only. If you bill on cost, use non-streaming calls or also price the token metrics.
Every usage field the vendor returns is also included, with a raw. prefix. See How usage is reported.