
BrokeAF
Preview costs before making OpenAI calls.
Like many developers out there, I was trying to piggyback on the generative AI trend to build something cool that can generate revenue.
However, while OpenAI made it easy to interface their models, it comes at a cost. Each call to their models cost money. Although it may seem negligible (the embedding pricing is only $0.0004 per one thousand tokens), it actually adds up really quick for large datasets.
Many ppl on Twitter are building "chat your data" kinda projects, while it's amazing to have a chat bot for the data, it comes at a significant cost if the underlying data is huge (talking about research papers, legal contracts, etc).
How did I build it
It was a one day worth of work completely in Python.
I was using streamlit to build the frontend that allows users to input their data (text, PDF file, URL, etc.), and behind the scene, I used OpenAI's tiktoken module to generate token count for the input data for each of OpenAI's models.
Then, I calculated the pricing based on OpenAI's pricing page by multiplying the unit price by the token count for each model.
The rest is just displaying that data on the UI.
I deployed the app on streamlit.
About
I was building another AI project using OpenAI. There wasn't any easy way to preview the costs, and my free credits were running out. So, I built BrokeAF to help developers preview the costs before making API calls.

7 Comments
love the name. You picked a good one
Nice!
Curious, are you thinking of incorporating image generation into BrokeAF?
Evoke works splendidly as a backend for that.
BrokeAF is a tool for previewing costs, not really an AI product. So, for OpenAI, I think their pricing for image generation has fixed pricing based on resolution: https://openai.com/api/pricing/#faq-token
Interesting. It didn't work for me though (on mobile), I just got some blank boxes.
Thanks. It works for me using Safari on a phone. You should be able to see a text area for pasting some text in, and preview the cost of that text...
Works now, not sure what happened before