← All posts

Why did my AI bill just triple?

One gateway, one hard cap, and the two leaks that cause most surprise bills.

Most surprise AI bills come from a few predictable places. A single gateway with logging, model routing and a hard monthly limit closes all of them.

An AI feature that costs a little per call can still cost a lot per month. The model price is rarely the problem. The problem is calls nobody meant to make.

Put every call through one door

Nothing in the app should talk to a model directly. Every call goes through one gateway function, and that function does three things: it logs the call with its cost, it picks the model, and it refuses once a monthly budget is spent.

The log tells you what each feature really costs. The budget turns a bug into an error message instead of an invoice.

Route to the cheapest model that does the job

Most work does not need the biggest model. Sorting, short summaries and first drafts run well on an everyday tier. Keep the expensive model for the few jobs that need it, and make that a choice per task, not a default.

Two places costs leak

The first is the page load: a model call hidden in a page that renders every time someone opens it. The second is the loop: a retry or a batch that runs one call per item with no limit. A simple rule covers both. Never call a model while rendering a page, and never call one in an unbounded loop. Store results and show what is stored.

Keep reading

  • Architecture

One codebase, a hundred brands

How white-label SaaS adds a new customer with configuration, not a new project.

A new customer should be a row of configuration, not a new project. What changes per brand, what never does, and how to keep tenants apart.

  • Backend
  • Architecture

Why your microservices should stop shouting JSON

gRPC and Protocol Buffers in plain words, and where REST still wins.

Why services inside a system often talk gRPC instead of JSON over HTTP, what a .proto file gives you, and where REST still fits.

  • Email & DNS
  • Backend

Have you ever thought how email works?

One click on Send, six hops, five DNS records and a handshake in plain text.

You press Send and a second later it lands on the other side of the world. Here is the whole journey: SMTP, the servers it passes through, and the DNS records (MX, SPF, DKIM, DMARC) that decide whether it reaches the inbox or the spam folder.

Have a process worth automating?

Tell me what eats your team's week. I'll tell you what I'd automate first.

Start a project Remote · PrimeX Meta, Dubai · teams across time zones