Hakolkal
Start a Project

Article · Published December 3, 2026

How I limit what an AI feature can spend before any paid call is made

Every call to an AI model costs money, and a public product is open to anyone. So the question of how to control AI API costs has to be answered before launch, not after the first invoice. Lalibook is my web app that turns one photo of a child into a personalised picture book. Here is how it limits what an AI feature can spend before any paid call is made, and what to decide for your own product.

The Lalibook home page: Once upon a time, your child became the hero, with a button to make a first book

One picture book is dozens of paid AI calls

Lalibook starts from one photo. Claude, the AI model made by Anthropic, writes the story in French, English or Hebrew. Image models hosted by fal draw four portraits of the child, then every page of a 12 or 24 page book. ElevenLabs reads each page aloud.

That makes dozens of calls to three paid services for a single book, and the first book is free. The app is live at lalibook.com, with sign-in open to everyone, so a stranger or a script could ask for books all day. That is why the limits come first.

Daily caps are checked before any paid call

Each account has a daily counter for every action that costs me money: new books, AI story ideas, redraws the parent does not pay for, and narration recorded again. The counter is checked first. When it is full, the request stops and no model is called. A form with a missing age or an unreadable photo is refused even earlier.

The counters live in the database and are updated in a transaction, so two requests arriving together cannot both take the last place. Books also cost credits: they are taken first, then the cap is checked, and they come back automatically if the cap refuses or the book cannot be created.

A limit on new accounts per day

The first book is free, so every new account is a small gift of AI spending. Only a limited number of new accounts are approved automatically each day, and a check per visitor comes first, so one person cannot use up the day's places.

Past that number, nobody is turned away. The account is put on hold, the person reads that it is waiting for approval, and I receive an email. I approve it by hand from a small admin page, and the welcome credits are added at that moment.

What the user sees at the cap, and what happens to photos

A cap that answers with an error code looks like a bug. Each one has its own plain sentence. For books: "That is the most books for today. Come back tomorrow." For ideas: "That is the most ideas for today. Pick a story instead." The second points to the 13 ready-made outlines, which need no AI call to browse.

The photo is handled with the same care as the money. Before it is stored, it is resized, turned upright and stripped of its metadata, location included. It sits in private storage and is deleted automatically after 30 days. Deleting a book removes everything at once.

Where these spending limits stop

The caps count calls, not money, and they are set per account. There is no single counter for what the whole site spends in a day: the ceiling is the number of approved accounts multiplied by what each may do.

So I also watch the providers. The app emails me when one refuses a call because of the key or the billing, and when the balance of the drawing service runs low. That is an alarm, not a brake. And approving accounts by hand costs my time: it suits a young product, not a large one.

What to decide before you launch an AI feature

Three decisions, and none of them is technical. First, a daily budget: what you accept to lose on a bad day, turned into a number of calls. Second, what happens when it is reached: a clear message, a waiting list, a cheaper path that still works. Third, who gets served first when capacity is short.

In Lalibook the answer to the third is the paying parent: someone who still has redraws on a book, included or bought, is never told to come back tomorrow. Only the redraws that cost them nothing are capped per day. With those three answers, the rest is counters and honest messages. If you are planning an AI feature, tell me about it.

Want something like this?

Tell me what you are building, or what you are still doing by hand, and I will tell you how I would approach it. No commitment.