litellm - 💡(How to fix) Fix [Feature]: Exclude BYOK models from team billing data [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#24235Fetched 2026-04-08 01:09:05
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
1
Author
Participants
Timeline (top)
labeled ×1subscribed ×1

Root Cause

  1. Manage keys and usage for models that we provide access to, where we then bill each team at the end of the month for the usage accumulated. This is working for our purposes.
  2. Users bring their own keys and then use LiteLLM for enforcing member-level budgeting on them. They pay for the usage of these directly. As a result, we do not want to include these models’ usage when we bill them. Zeroing out the input and output costs doesn’t work because that defeats the purpose of using it to put budgets on member use.
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

Add the ability to exclude billing data for models marked as BYOK when pulling usage from the API.

Motivation, pitch

We have two separate uses for LiteLLM.

  1. Manage keys and usage for models that we provide access to, where we then bill each team at the end of the month for the usage accumulated. This is working for our purposes.
  2. Users bring their own keys and then use LiteLLM for enforcing member-level budgeting on them. They pay for the usage of these directly. As a result, we do not want to include these models’ usage when we bill them. Zeroing out the input and output costs doesn’t work because that defeats the purpose of using it to put budgets on member use.

We want the ability to exclude BYOK accounting records so that they aren't charged twice (once using their own API key and once by us). We currently pull monthly usage using the /global/spend/report API.

What part of LiteLLM is this about?

Other

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

extent analysis

Fix Plan

To exclude billing data for models marked as BYOK, we need to modify the API request to filter out these models.

Step-by-Step Solution

  • Modify the /global/spend/report API to accept an additional query parameter exclude_byok which defaults to false.
  • Update the API endpoint to filter out models marked as BYOK when exclude_byok is true.
  • Example code snippet in Python:
from flask import request

@app.route('/global/spend/report', methods=['GET'])
def get_spend_report():
    exclude_byok = request.args.get('exclude_byok', default=False, type=bool)
    if exclude_byok:
        # Filter out BYOK models from the report
        report = [item for item in report if not item['is_byok']]
    return report
  • When calling the API, pass exclude_byok=true as a query parameter to exclude BYOK models:
GET /global/spend/report?exclude_byok=true

Verification

To verify the fix, test the API endpoint with and without the exclude_byok query parameter. Check that the report includes BYOK models when exclude_byok is false and excludes them when exclude_byok is true.

Extra Tips

  • Make sure to update the API documentation to reflect the new query parameter.
  • Consider adding a test case to ensure the filtering works correctly.

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