Engineering answer

Does an AI gateway add latency?

Yes. An AI gateway adds at least a network and processing hop, so its own overhead cannot be zero. Whether users notice it depends on geography, connection reuse, request size, gateway work, provider time to first token, output length, retries and streaming. Measure the full request path with the same payload and report gateway overhead separately from provider generation time.

Last reviewed 2026-08-15 · Editorial review: KeepRouter Editorial

Latency has several clocks

MeasurementStartsStopsWhat it reveals
Client round tripBefore the client sendsAfter the client receives the terminal responseTotal user-visible time
Time to first byteBefore the requestFirst response byteNetwork, admission and upstream start
Time to first tokenBefore the requestFirst usable model outputRouting plus provider queue and generation start
Stream durationFirst tokenTerminal eventOutput generation and delivery
Gateway processingGateway receiveUpstream send, then upstream receive to client sendWork attributable to the gateway

Do not compare one product's internal processing metric with another product's public round trip. They measure different intervals. Vendor latency claims may also use different regions, payloads, connection states and percentile windows.

A fair measurement design

Run direct and gateway paths from the same client region with the same model revision, provider, prompt, output cap and streaming mode. Reuse connections for warm tests, but also record cold starts if your application creates new connections. Capture at least p50, p95 and p99 over enough requests to see queueing and rate-limit behavior.

Separate successful first attempts from retries. A fallback that rescues a failed call can improve task completion while making that individual request slower. Blending rescued calls into a single average hides the trade-off. The failover answer explains how to bound those attempts.

Gateway work that can add time

Authentication, quota checks, request transformation, policy evaluation, logging, cache lookup, provider selection and response normalization all consume time. Large synchronous log writes or a remote policy database can become part of the critical path. Streaming transformations can also delay the first usable event if the gateway buffers too much data.

Some gateway features can reduce total time. A nearby edge entrypoint can improve connection setup. A valid cache hit can avoid generation. Provider health routing can bypass a degraded path. These are workload-dependent outcomes, not reasons to describe gateway overhead as zero.

Set a product budget

Define an acceptable increase for time to first token and total completion time based on the user interaction. A coding agent, autocomplete field and background batch have different budgets. Monitor the same metrics after deployment because route selection and upstream behavior change.

Keep the test script, raw timestamps, model ID, endpoint and gateway configuration with the result. Re-run after changing routing, logging or retry policy. The observability feature lists the request evidence available in KeepRouter; use the evaluation framework to compare it with another product.

Frequently asked questions

How much latency does a gateway add?

There is no universal number. Region, connection reuse, policy work, logging, payload size and upstream routing all affect the result.

Should I measure time to first token or total time?

Measure both. Time to first token describes responsiveness, while total time includes output generation and delivery.

Can failover improve latency?

It can avoid a degraded route, but a failed first attempt usually makes the rescued request slower. Report those cases separately.

Does streaming remove gateway overhead?

No. Streaming changes when output becomes visible, but routing and processing still happen before and during the stream.

Can caching make the gateway faster than direct generation?

A valid cache hit can, but only for cacheable requests under the configured policy. Compare hit and miss paths separately.

Sources reviewed

  1. [1] Cloudflare AI Gateway analytics
  2. [2] Vercel AI Gateway observability
  3. [3] OpenTelemetry trace semantic conventions

Related guides

Test the contract with a real model

Create a narrowly scoped key, select a model from the live catalog, and run the exact request shape your application depends on.

Create a free key · View live models and pricing · Read as Markdown