Documentation/Usage based billing

Usage based billing

Understand usage, rates and historical charges.

Charge calculation

Cost equals measured quantity times the USD rate per base unit. Input, output and cache use applicable rates. Images, seconds and queries use their own units. Example: 1,000 input tokens × $0.000002 + 500 output tokens × $0.000008 = $0.006.

Rates and windows

Deployment rates take precedence over catalog rates. Missing prices do not mean free usage. Peak and off-peak rates use call start time in Asia/Shanghai.

Logs and reconciliation

Request logs show usage, charges and price snapshots. Snapshots preserve applied rates; rate changes do not rewrite history. Reconcile local costs with provider bills. Paginated logs and scan-limited reports are not complete invoices.

Units and price sources

Dimension Measured usage Price unit
Text Input/output/cache tokens USD per token
Images Image count USD per picture
Audio/video Duration USD per second
Queries Query count USD per query

Deployment prices are tried before catalog prices. Missing prices do not mean free. Resolution, audio, reasoning variants and time windows select applicable rate rows; inspect price snapshots instead of assuming a universal multiplier.

Worked examples

These are illustrative rates, not fixed offers. At $2 per million input tokens and $8 per million output tokens, 1,000 input + 500 output costs $0.006.

At $0.50 per million cached input tokens, 1,000 total input including 600 cached plus 500 output costs (400 × 2 + 600 × 0.5 + 500 × 8) / 1,000,000 = $0.0051. Cached input is a subset of input and must not be counted twice.

At $0.04 per image, 3 measured images cost $0.12. At $0.10 per second, 8 measured video seconds cost $0.80. Requested duration is not completed usage.

Display and storage units

The rate usd is already per base unit: charge = quantity × usd. unit_size describes the original quote; do not divide again. $2 / 1,000 tokens is stored as usd=0.002; 1,500 tokens cost $3. Display prices per million tokens require conversion once.

Tokens and multimodal input

Tokens are model-specific pieces, not character counts. Instructions, history and tool schemas contribute input. Output limits are not measured usage. Reasoning and image/audio input follow actual provider usage and applicable rates; do not count a breakdown twice. Explicit zero remains zero; missing usage may be estimated. Seconds and pictures must not be invented as tokens.

Cache, failures and retries

Provider prompt caching still uses cached rates. XHub complete response cache is separate: a local hit has zero new generation cost even if returned usage retains the earlier result. Failed calls have zero local new charge; suppliers may bill attempts or partial outputs. There is no complete per-attempt supplier ledger; reconcile retries and interrupted streams with the provider.

Peak and offpeak

Call start time in Asia/Shanghai selects the window. Normal workdays use [09:00,12:00) and [14:00,18:00); weekends and maintained Chinese holiday overrides are offpeak. A crossing call keeps its start window. Inspect fallback markers for missing exact variants.

Async settlement and reconciliation

Creation and pending polls do not infer generation fees. Successful terminal task results with positive measured usage settle once per caller, transport, task and deployment; repeated completed polls do not duplicate generation charges.

Find x-litellm-call-id in request logs; inspect usage, price_snapshot and applied quantities. x-litellm-response-cost is local USD cost, not a database commit receipt. Changed prices do not rewrite saved snapshots; older logs may show source=recomputed. Logs are paginated; activity reports scan at most 5,000 events. A single page is not a full invoice. Currency conversion, tax, refunds and prepaid payments are not supplied by this usage accounting.

Search full documentation: budgets, routing, Docker…