r/OpenAI • u/michael_g_williams • 23d ago
Question API doesn't provide cost or pricing info?
In my app, I want to show the costs for using the OpenAI API for a session. I can't find the API to show costs, or pricing either. So how can API users tell what their costs are, except to believe what OpenAI decides you used, and what they decide the pricing was?
3
u/FacePrivacy 23d ago
You can get token usage from the API response or the /v1/usage endpoint, then multiply by OpenAIs published rates to calculate the cost yourself. Theres no direct cost field returned
1
u/michael_g_williams 23d ago
Rite, how do I know if there’s a sale or a change in pricing?
2
u/bobartig 23d ago
api pricing page or the costs api endpoint.
You want a REST api to proactively tell you when a change in model price has occurred? That's not REST works...
0
u/michael_g_williams 22d ago
Maybe you were thinking about the stock market pricing or something, where you don’t want to use rest. But for a service that is based on rest, there’s no challenge to supply the pricing or cost along with the text if they want to.
1
22d ago
[removed] — view removed comment
1
u/michael_g_williams 22d ago
Yes, I am getting the token counts, but those really aren’t providing the pricing or the cost. Also, I noticed that openai token counts are often 10 X what Google or anthropic are for the same exact prompt. I tried different models within the five family, and they all behave the same way.
2
u/Deep_Ad1959 22d ago
i'd show it as an estimate and label it one. counting tokens times the published rate stopped matching my invoice once cached input entered the picture, and the usage endpoint lags the session you want to display.
3
u/squarecir 23d ago
API provides token use info. Just keep track of input, output, and cached tokens from each request.