BrokeAF

Preview costs before making OpenAI calls.

Visit Website
February 17, 2023 Why and how did I build BrokeAF

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.

7 Comments

  1. 2

    love the name. You picked a good one

  2. 1

    Curious, are you thinking of incorporating image generation into BrokeAF?

    Evoke works splendidly as a backend for that.

    1. 1

      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

  3. 1

    Interesting. It didn't work for me though (on mobile), I just got some blank boxes.

    1. 1

      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...

      1. 2

        Works now, not sure what happened before

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.