Eric AlmarazDirector of Operations, Central Texas

Five systems, case study 4 of 5, automation and AI

My automations' AI calls go through one gateway, and none to a pay-per-use service.

My automations all need an AI model, under two rules: no metered spend, and no single provider that can stop everything. I had the routing layer built to my rules. In seven weeks it handled 14,639 calls (8,448 of them from one batch job) and answered 97.9% of them.

The situation

I had a standing rule of no pay-per-use AI spend: a flat-rate subscription or a model I run myself, nothing metered. Then I looked at how much of my work depended on one provider and did not like the answer.

The fix was to own the routing. Every task should have two live ways to get an answer, and I should be able to see afterwards which one was used.

My part, and the agents' part

I set the no-metered-spend rule and the two-live-lanes principle, and I approved each step. AI agents built the gateway, the routing table and its test suite.

A weekly job proposes routing changes. Nothing changes until I approve it from my phone.

What I built

Any script or appasks for "smart", "cheap" or "fast" and gives its own name
Gatewaywalks the lanes in order, skips any that are off or near their limit, falls back on failure
The answerstamped with the lane, the model and how far it fell back
Usage logone line per call, and a status page
No lane in the routing table can reach a pay-per-use service, and a request that names such a model is rejected.

Put a lane at its limit, then send a request.

  1. Flat-rate subscriptionTried first.
  2. Second subscription accountUsed when the first is at its limit.
  3. Local model on a GPU workstationRuns on my own hardware. Tried last.

An illustration of the order the gateway tries. Each kind of request has its own ordered list of lanes.

The result

  • 14,639calls from 31 callers in seven weeks (8,448 from one batch job), 97.9% answered
  • 0 meteredno pay-per-use lane appears anywhere in the log
  • 1,129calls fell back to another lane automatically

How this was counted. By reading the gateway's own usage log, 28 September to 16 November 2026. One caveat matters: a single batch job made 8,448 of those calls, almost all on the local model. Without it there were 6,191 calls, 96.6% answered, and most ran on the subscription lanes.

Not measured. Dollars saved. The zero is what the log shows, and I have not audited it against a bill.

Limits and what is next

The gateway's own test suite is currently reported as failing, so I do not quote its test counts. The next job is to fix or retire those checks.

The no-metered-spend claim rests on the routing design and the call log. A check from the billing side would make it stronger, and that is the step after.

Built with Python, FastAPI, Ollama for local models, a command-line Claude subscription and a JSONL log.