Building an AI gateway that routes four CLIs
The hard part of an AI gateway is not the HTTP shape — it's keeping dozens of OAuth sessions alive across four vendors that all expire differently.
Three lessons
- Treat accounts as a pool, not a config value. Inventory, score, and rotate. A request should pick the healthiest live session at call time.
- Re-login must be automatic. Detect dead/suspect tokens and re-auth in the background; a human babysitting logins doesn't scale past a handful.
- Probe before you route. A 200 from the gateway should mean a real backend answered, not that a request was queued behind a dead session.