DEV Community

nRouter
nRouter

Posted on

Your gateway's best features are the ones you can't take with you

Start with the URL, because the URL is the tenancy model. On Cloudflare's AI gateway, the endpoint is gateway.ai.cloudflare.com/v1/{account_id}/{gateway_id} — which gateway you are talking to is a fact embedded in your deployment configuration. Separating staging from production means minting another gateway and threading another URL; one gateway per tenant runs into the per-account cap. A host-neutral gateway flips this: the base URL is constant, and tenancy is resolved from the API key at auth time. Rotations, environment splits and per-customer keys then touch no URL anywhere in your estate. Boring. Also the entire portability story.

The ceiling whose escape hatch is the chore

Cloudflare's Unified Billing exists so you can stop holding provider keys: prepaid credits, one bill. Its published ceiling — 200 requests per 60 seconds per gateway — applies to that managed path only. BYOK is exempt. Read the implication slowly: the documented way out of the managed path's ceiling is to go back to holding provider credentials yourself, which is the exact work the managed path was created to abolish. Credential precedence, while we are here: request-supplied keys, then stored BYOK, then Unified Billing.

Five

Custom metadata on the edge gateway caps at five entries per request. Tenant, environment, feature, end-user, request source — that is five, spent, before per-customer cost attribution asks for its first tag. Add a log pool shared across the account with hard ceilings (fill it and you choose between deleting the oldest records and refusing new ones), and observability on a platform gateway turns out to be tenancy in someone else's storage policy. The alternative makes attribution structural instead: usage and spend per key and per team, as scopes, not annotations.

The cache is exact-match, and your prompts are not

The edge cache is the feature most worth understanding, because the interface is genuinely good — per-request TTL, skip, key override, a HIT/MISS status header — and the semantics quietly undo it for most real traffic. The default key is a hash of the provider, endpoint, model, the provider authorization header, and the full request body. Any variation is a separate entry. A timestamp, a request id, a shuffled RAG context: a miss, every time. Most production prompts are templated with per-request data, so the byte-identical share of traffic is far smaller than the semantically identical share — and semantic matching is, per Cloudflare's own docs, a future enhancement. The auth header inside the key also means rotating a provider key cold-starts the cache, and a key-per-tenant fleet gets a cache per tenant. And two identical requests in flight at once can both miss — the stampede case, a deploy or a cron fan-out, being exactly where you wanted it.

The host-neutral side of this comparison exposes no per-request cache control at all, and the post calls that a real gap, not a flourish. What it puts one layer up instead: budgets and rate limits scoped to org, team and key, applied before the provider call. A guarantee about spend rather than hit rate.

Where the edge plainly wins

The comparison lists these itself, without throat-clearing. Workers AI invoked from inside a Worker: no network hop leaves the platform, and an external gateway cannot match that — migrating off the binding is a call-site rewrite, not a config change. Managed-path breadth: Unified Billing covers model families the nRouter catalog does not serve today; if one is on your shortlist, the post tells you that is disqualifying and to stop reading. Per-request cache control, as above. And a large paid log pool beside the rest of the platform — WAF, DDoS, storage — if your incident review already lives there.

Switching, honestly

For an OpenAI-compatible client it is two lines: base URL and key. Model strings, messages, tool calls and streaming do not change. The fallback array becomes routing configuration rather than a per-request payload; rate limits become per-key limits; analytics become per-key and per-team spend. What has no equivalent: the cache headers, the platform-hosted models, one-for-one metadata. One warning for the way out: an unknown cost is reported as unpriced with the cost header omitted rather than zeroed — if your dashboards sum a cost field and treat missing as zero, they will silently under-report; branch on the status header instead.

Full comparison: https://nrouter.ai/blog/product/cloudflare-ai-gateway-alternative

Top comments (0)