AIToday
Large Language ModelsAI Business & IndustryZenn AI/MLPublished: Nov 19, 2026, 04:00 JST

AIO Helper blocks AI calls before they break its $50 budget

Send on LINE
AIO Helper blocks AI calls before they break its $50 budget

3 Key Points

  1. What happened

    On April 16, Uehara's team made AIO Helper estimate each request's AI cost and stop it before the external AI API is called when the site's remaining monthly budget falls short, returning HTTP 402 on two features and skipping over-budget pages on batch suggestions.

  2. Why it matters

    Checking the balance before the AI call rather than after means the monthly cap can actually function as a control, while the app's ledger stays a fast-stop estimate separate from the provider's final invoice.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, every morning.

Context & Analysis

The starting point was a test audit: AIO Helper's admin screen already displayed the month's AI usage, but zero tests enforced a cap. Without a stop before the external call, a retry loop or bug could keep invoking a usage-billed model. The team therefore separated pricing from the data model, keeping a static price table in code because the OpenAI API response includes only token counts and no cost figure. A deliberately high fallback price for unknown models guards against a new model slipping past the cap at zero cost.

The enforcement design puts the budget check inside a single INSERT statement rather than a separate SELECT, so aggregation and write happen in one statement. Even so, this structure alone does not guarantee order when two requests arrive near the cap at once, and a real-Postgres competition test was not completed. A test-environment gap also surfaced: pg-mem lacked date_trunc, and 12 of 18 tests in the integration file failed with 500 errors at the time. Registering date_trunc reduced failures to five, and explicit type casts resolved the rest.

The soft warning added on April 23 keeps a cap of zero as a deliberate stop setting, separate from a near-limit warning, because showing both as the same yellow alert would lead users to assume waiting will restore service. The ledger does not cover embedding calls and the rebuild API, which were outside the cap in April, with records added to the rebuild API in September 2026, and calls that fail after the AI responds can incur cost without a ledger entry. The budget mechanism applies only to AI API spend inside AIO Helper, not to fixed cloud costs such as always-on Elastic Container Service or NAT Gateway charges.

FAQ
What happens when a site runs out of budget?
Two single-page features return HTTP 402 Payment Required. The batch suggestion feature skips pages that lack remaining budget and returns HTTP 200 with a count of skipped pages.
Is the ledger the same as the provider's bill?
No. The app estimates cost from token counts and its own static price table, so the in-app ledger is a fast-stop number while the provider's invoice is the final amount paid.
Has strict enforcement under concurrent requests been verified?
No. Strict cap guarantees during simultaneous requests were not confirmed with a competition test on a real Postgres database.
Send on LINE

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleEx-ICU nurse who left in 2015 says AI risk now feels real