litellm - 💡(How to fix) Fix [Feature]: Dynamic Cost Reconciliation for OpenRouter (Support for Service Tiers and Real-time Pricing) [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#27588Fetched 2026-05-11 03:13:57
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
labeled ×2
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

The Feature

Implement a Dynamic Billing Reconciliation mechanism for OpenRouter provider to sync the response_cost with the actual billed amount.

Specifically, I propose adding a feature where LiteLLM can optionally fetch the final cost from OpenRouter's /api/v1/generation?id={id} endpoint after a request is completed, instead of solely relying on local static price maps. This is crucial for supporting OpenRouter's dynamic features like Service Tiers (Flex) and provider-specific discounts.

Motivation, pitch

I am managing large-scale LLM infrastructure (Data Engineering at Digikala) and we use the /model/new endpoint to dynamically register hundreds of OpenRouter models.

The Problem: Currently, LiteLLM calculates costs locally based on static prices set at registration time. However, when we use extra_body={"service_tier": "flex"}, OpenRouter applies significant real-time discounts. Since LiteLLM is unaware of these dynamic billing changes, it logs the "standard" price in LiteLLM_SpendLogs, leading to a significant Cost Drift (e.g., LiteLLM logs $0.0000171 while OpenRouter actually bills $0.0000139).

This makes internal financial auditing and team-based billing based on virtual_keys highly inaccurate. We need the "Source of Truth" (OpenRouter) to be reflected in our LiteLLM Postgres database.

Related Issues: This is similar to the billing transparency issues reported for custom models (e.g., #10023), but specific to the OpenRouter aggregator logic.

What part of LiteLLM is this about?

Proxy

LiteLLM is hiring a founding backend engineer, are you interested in joining us and shipping to all our users?

No

Twitter / LinkedIn details

No response

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]: Dynamic Cost Reconciliation for OpenRouter (Support for Service Tiers and Real-time Pricing) [1 participants]