Drop-in cost map URL with daily-refreshed pricing (~340 models missing from the community map) #32191
Replies: 5 comments
|
Hey, thanks for sharing this! This is very interesting. :)
Hmm... I think this might not be a bad idea. However, I want to see what the community thinks and gauge interest from there. If folks who are interested in this could reply to this thread. If there's enough traction, I'll implement it. I was planning to set up an automatic provider ingestion pipeline as part of the product. However, with the current backlog of issues, would you be interested in being a vendor we can use to automatically update our JSON daily? |
|
Jumping in here as well! Automating this is the right move. Whenever there is manual work - there will be staleness. From my point of view the big issue with the JSON is that it's quick to catch merge conflicts. I know the maintainers have a big chunk of contributions to review. If it's not happening in time, even the updates go stale. I'm developing over at narev.ai, and we'd love to step up as the official data vendor for this. We build the pricing engine that powers usage-based billing for AI (directly integrating with Stripe, Polar, Lago, OpenMeter).
This will work for providers that do give pricing in their endpoint. Many providers don't (see
Would love to do it! |
Yep, we’d be happy to serve as a provider for this data. We’ve been providing pricing data for the past eight years with ~40k users per month, starting with cloud instances, and we already have a comprehensive, actively monitored data pipeline in place. I think there should be an option to configure multiple providers in litellm's admin console. The default setup could use cloudprice.net as the primary source with the most fresh data and litellm_model_prices.json from GitHub as a fallback. We currently fetch data dynamically from the following providers, in priority order: SOURCE_PRIORITY = ( As you can see, we also use the LiteLLM file to cover the long tail of smaller providers. Let me know how we can help here. |
|
Hey @mateo-berri, before committing to new UI dependencies, you can actually solve the staleness issue right now with minimal effort. 1. Fix the existing GitHub Action (and run it daily)You already have a pipeline set up: Right now, it’s scheduled weekly, but it's failing (link). Example traceback: The issue: It fails on models that have no output pricing (e.g., embeddings or video models like The fix: I fixed the script and tested it:
2. Pull directly from providers that expose pricingFor providers that ship pricing in their curl --request GET \
--url https://api.novita.ai/openai/v1/modelsHere is a PR implementing the direct pull pattern for Novita: oskarkocol#3 3. Use a data vendor for the restFor providers that hide pricing (OpenAI) or require API keys (Cloudflare), Narev can fill the gaps. I implemented Cerebras as a test case here (they have a simple offering of 3 models so it’s easy to cross-check). Here is the draft PR: oskarkocol#4 On aggregatorsRelying on generic aggregators (like what's proposed above) creates a circular dependency. For example, Cerebras charges for prompt caching (source). The initial models.dev data missed this (I opened a PR to fix it here), and aggregator APIs end up serving that incorrect pricing:
To be fair to everyone in this thread, tracking LLM pricing is just a genuinely hard problem right now. Gateways frequently get it wrong, edge cases like caching are a mess and prices change daily. It takes real, active care to keep it all in sync. |
|
Hey @mateo-berri we can try to create PR with ability to add multiple sources and fall back to .json file from our side. What do you think? |
Uh oh!
There was an error while loading. Please reload this page.
LiteLLM can pull
model_prices_and_context_window.jsonlive from GitHub, which is great, but that file is community-maintained. So prices lag, new models take a while to show up (or never do), and sometimes the numbers are just wrong until someone opens a PR.We ended up building our own drop-in replacement. Same schema, same env var, so it works for both the Python SDK and the gateway proxy:
export LITELLM_MODEL_COST_MAP_URL="https://cloudprice.net/api/v2/ai/litellm_model_prices.json"What's different:
The thing I actually wanted to ask the maintainers/community: would it make sense for LiteLLM to support multiple cost map sources with fallback, right in the gateway UI? A primary URL plus fallbacks, if one is missing a model, it falls through to the next. That'd fix the whole stale/missing problem regardless of whose map you use.
Here is more details: https://cloudprice.net/models/api?litellm=1
All reactions