Get model pricing using the API

Looking for a way to get the list of models along with the up-to-date prices using the API.
From my understanding, this is not possible currently, can someone confirm?
For my application, I need to store the prices of different prompts in my DB. Although I can get the number of input and output tokens, I also need to store the actual price - it will be much more convenient if we could get the prices of different models using the API. For now, I need to manually visit the pricing page every now to update prices.

1 Like

Welcome to the community!

This has been an oft requested feature.

From experience, the prices of model calls haven’t ever gone up, or even changed (apart from generic endpoints, which IMO you shouldn’t use in the first place). So writing the prices into your db every time you change the model is probably the best thing you can do at the moment.

2 Likes

Thanks - The prices may not have changed but I still need to manually update the price of new models such as the newly released gpt4o.

I actually built a chatgpt pricing calculator and list of all model pricings at one place

How big of a problem is this? I might consider just opening up the API for this as the JSON is already ready.

2 Likes

That would be awesome. How do you get pricing, scraping websites?

Not from the API, you would have to scrape the site.

Prices dont change that often, i just lookup manually for now

I know this is an old thread but looking for the very same thing. Seems like a pity to have to resort to scraping such important data!

More broadly, it would be very useful to have an API that provided pricing not only for the OpenAI models but also for all LLM APIs generally.

No chance anyone has thought of such an idea?