An AI gateway sits between coding agents and everything they call, and a new test of four of them shows it controls access well but doesn’t guarantee accurate costs, hard budgets or data residency. Testers put three coding agents through four gateways. Of 61 recorded runs, nine ended in errors, a few deliberately.
The agents were Claude Code 2.1.318, Codex 0.164.0 and OpenCode 2.2.1; Bifrost 2.4.0, agentgateway 1.7.0, Cloudflare AI Gateway and Vercel AI Gateway as gateways. The sample is small and the pairings uneven, so read the results as signals.
A budget is a stop, not a ceiling
Each gateway looked at spend already logged before a request and added the new cost after. That lets the request that crosses the limit run anyway. Cloudflare’s and Vercel’s documentation describes the same pattern. The alternative is to hold the worst-case amount first, like a hotel deposit, at the price of refusing calls a nearly-full key could have paid for.
Parallel agents compound this, since each clears the check before any of them completes. Clients also react to a refusal differently:
- Claude Code quit immediately on both gateways.
- Codex hit Bifrost’s 402 refusal, tried five more times in roughly seven seconds and stopped.
- Against agentgateway’s 429, Codex hung until a five-minute timeout, twice.
Tool access through an MCP gateway
Model calls cost money when they go wrong. Tool calls can erase a project. To test tool control, two keys with different rights were pointed at a mock Jira service behind each gateway, with the real Jira token held only by the gateway.
It worked on Bifrost and agentgateway. The developer key never saw the delete tool, and a direct call to it was refused inside an HTTP 200 response. The admin key could delete. Claude Code on the developer key couldn’t see the tool either. One caution for self-hosting: one gateway’s admin interface in this test answered with no login and listed the agents’ keys. Keep that port private.
Cost numbers don’t agree
Three figures get confused: what the agent reports, what the gateway calculates and the invoice. They needn’t match, and the testers didn’t check against an invoice.
- Claude Code charged for a free model. It estimated one run at $0.044 though the model cost nothing, and the three runs checked all used $5 per million input tokens, $25 output and $0.50 for cache reads, likely a fallback rate for unrecognized models.
- The hosted gateway probably skipped the cache discount: billing cached tokens as normal input explains roughly 3.9x of its 4.7x overshoot.
- Codex reports tokens but no dollars, so a gateway can fill that gap across a mixed set of agents.
- Field names also mislead. One call showed 2 input tokens in Claude Code and 17,268 at the gateway, because Anthropic’s input_tokens excludes cache reads.
Prompt caching lives at the model provider, but the client decides whether a request hits it. Pointing Claude Code at a gateway instead of the provider produced a cold first call, since the client alters its request when the base URL changes. Codex began each session cold because it generates a fresh prompt_cache_key every time. Once a proxy fixed that key, the following two runs read 10,594 cached tokens on call one.
Tracing one ticket
Gateways log each call separately, while teams want a cost per ticket. Passing a run ID and the traceparent header was enough to display a whole run as one trace.
Data residency is set hop by hop
Hosting a gateway in Frankfurt doesn’t keep prompts in Europe. Every hop counts: the gateway, the model host, the telemetry collector and any backend that stores prompt text. One gateway exported full prompts and responses unless told otherwise, and tool arguments got past a filter, so an allowlist is the safer route. Vendor regional options were checked on 5 November 2026 and change often.
Switching is easy, though. Adding two Scaleway models to agentgateway as aliases let OpenCode finish the job on each with no changes. That proves the routing works. It says nothing about where the model ran.
What to do before relying on a gateway
Verify cost against invoices, test how each client handles budget refusals, set cache behavior deliberately, and filter prompts out of telemetry. LiteLLM, Portkey, Kong and others weren’t tested and may behave differently. As agent tools keep changing, the gateway is the part you want to stay put.
Source: LogicStar