litellm - 💡(How to fix) Fix [Feature] Token-level cost attribution for multi-model routing [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#26021Fetched 2026-04-19 15:06:13
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

When routing across multiple LLM providers, it would be helpful to have built-in token-level cost attribution that tracks spending per model, per endpoint, and per user/team.

Root Cause

When routing across multiple LLM providers, it would be helpful to have built-in token-level cost attribution that tracks spending per model, per endpoint, and per user/team.

RAW_BUFFERClick to expand / collapse

Description

When routing across multiple LLM providers, it would be helpful to have built-in token-level cost attribution that tracks spending per model, per endpoint, and per user/team.

Use Case

  • Budget management across teams using different models
  • Cost optimization by identifying expensive query patterns
  • Chargeback reporting for internal platform teams

Currently we track this manually via middleware — native support would be cleaner.

extent analysis

TL;DR

Implementing built-in token-level cost attribution for tracking spending across multiple LLM providers and models is likely the most effective solution.

Guidance

  • Identify the key cost factors to track, such as model type, endpoint, and user/team, to inform the attribution system design.
  • Consider integrating a cost tracking mechanism within the existing routing logic to accurately attribute costs at the token level.
  • Develop a data storage and reporting system to manage and provide insights on the tracked cost data for budget management and optimization.
  • Evaluate the feasibility of incorporating native support for cost attribution within the current middleware or exploring alternative solutions that can seamlessly integrate with the existing infrastructure.

Example

No specific code example can be provided without more details on the implementation, but a potential approach could involve modifying the routing logic to include cost tracking metadata.

Notes

The implementation details may vary depending on the specific requirements and constraints of the LLM providers and the existing middleware. Native support for cost attribution might require significant changes to the underlying infrastructure.

Recommendation

Apply a workaround by enhancing the existing middleware to more accurately and efficiently track token-level costs until native support can be implemented, as this allows for immediate improvement in cost management and optimization.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - 💡(How to fix) Fix [Feature] Token-level cost attribution for multi-model routing [1 participants]