brainax

Money and limits

Lesson 24 of 26 in the course “Vibe coding”. Free, with animations and a quiz.

What a project costs money for

Example: you built a bot that helps your class prep for exams and answers with AI. While you're only building it, you pay for the AI tool at most. Once real people use it, more costs appear. The figure shows five typical ones: domain (paid once a year), AI subscription, API paid per token, hosting above the free tier, and database. No amounts on purpose: prices change, check them on each service's site.

API: you pay per token

The least predictable row: API per token. An API is the way your server talks to someone else's service, like an AI model. A token is a small piece of text, roughly part of a word. The service counts tokens in the question and in the answer, so the bill grows with every request. One student asks a question: pennies. The whole class asks hundreds the night before the exam: now you notice it. More about tokens in the AI course.

Spending limit and the bell

On the right of the figure: a spending limit gauge and a bell. A spending limit is a ceiling after which the service stops paid requests or warns you. A billing alert is an email when your spending reaches an amount you picked yourself. Not every service has both, so open the billing settings and turn on whatever exists. Think of it as a seatbelt: while everything's fine, you don't even notice it.

Leaked key: you pay for strangers

Remember the lesson on keys? An API key is the password that tells the service a request is yours, so the bill goes to you. If the key ends up in the frontend (code the browser downloads) or in a public repository, bots will find it. Then someone else runs AI on your money. The key lives only on the server. Spotted a leak? Delete the key in the service's dashboard right away and create a new one.

Rate limits and good habits

Even with the key on the server, someone's script can flood your bot with thousands of requests, and you pay for them. A rate limit caps how many requests one person can make per minute or per day. In the figure: no limits ✗ → rate limit ✓. Plus a few habits: start on free tiers, read the pricing page yourself, cancel trials you don't use. Check whether the service and payments are available in your country.

Check yourself

  1. Why can an AI API bill suddenly grow?
    Correct answer: You pay for tokens in every request, and requests piled up. The API counts tokens in questions and answers, so many requests mean a big bill. The yearly payment is for the domain, not the API.
  2. You notice your API key leaked. What do you do right away?
    Correct answer: Delete the key in the service dashboard and create a new one. As long as the old key works, anyone can use it. A deleted key is useless to strangers, and the new one goes only on the server.
  3. What is a rate limit for?
    Correct answer: To cap how many requests one person makes in a period. A rate limit doesn't change price or speed. It stops one script from making thousands of paid requests on your money.

← Agent helpers: skills and AI review Launch: people, analytics, SEO →