Skip to content

Introduce provider and key cost optimization strategy #12780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mcowger
Copy link

@mcowger mcowger commented Jul 19, 2025

Title

Introduce provider and key cost optimization strategy

Relevant issues

NA

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
    • Author Note: All added tests pass, as do tests for any touched files. The repo's test passing rate is not currently healthy on the unmodified main branch - if you check out the branch on a net new machine and run make test-unit, they do not all (or even mostly) pass.
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
    • Yes, this is as small as I could make it, while keeping it revert-able as a unit.

Type

🆕 New Feature
📖 Documentation
✅ Test

Changes

  • Implement hierarchical cost lookup: litellm_params > model_info > global_cost_map > token_usage_fallback
  • Add support for explicit zero costs in model_info for free models
  • Add comprehensive logging for deployment selection decisions including cost sources and calculations
  • Update documentation with cost configuration examples and troubleshooting guide
  • Add test coverage for new cost lookup priority system

Passing Tests:

Screenshot 2025-07-19 at 4 24 07 PM

mcowger added 2 commits July 19, 2025 16:17
…free/cheap API key usage

- Implement hierarchical cost lookup: litellm_params > model_info > global_cost_map > token_usage_fallback
- Add support for explicit zero costs in model_info for free models
- Add comprehensive logging for deployment selection decisions including cost sources and calculations
- Update documentation with cost configuration examples and troubleshooting guide
- Add test coverage for new cost lookup priority system
Copy link

vercel bot commented Jul 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 19, 2025 11:47pm

@mcowger mcowger force-pushed the mcowger/free-key-optimization-cost-lookup branch from dd3f361 to c0693bc Compare July 19, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant