You benchmark a relay. It reports 400ms median. The agent still feels slow. Both numbers are correct — they measure different things.
For a short answer, they are close. For a 2000-token code generation they diverge by an order of magnitude. A relay with a great total latency can still have a bad TTFT, and TTFT is what a human perceives as "slow".
Hitting /v1/models measures connection setup plus routing: TLS, auth, upstream selection. Useful for availability, useless for perceived speed.
Hitting /chat/completions without stream: true measures total latency only. You get one number that hides everything that matters.
import json, time, urllib.request
def ttft(url, key, model, prompt="count to 50"):
body = json.dumps({
"model": model, "stream": True, "max_tokens": 200,
"messages": [{"role": "user", "content": prompt}],
}).encode()
req = urllib.request.Request(url, data=body, headers={
"Authorization": "Bearer " + key, "content-type": "application/json"})
t0 = time.perf_counter()
first = None
with urllib.request.urlopen(req, timeout=60) as r:
for raw in r:
if raw.startswith(b"data:") and not first:
first = time.perf_counter() - t0
# keep reading to also get total
total = time.perf_counter() - t0
return round(first * 1000), round(total * 1000)
Run it three times. Typical shapes:
TTFT Total Reading
--- --- ---
300ms 400ms Short answer, healthy
300ms 9000ms Healthy start, slow generation — model-bound
3000ms 3500ms Slow start, fast generation — routing or queueing
The third row is the one that makes people blame the model. It is almost always the relay or the network path.
If TTFT is high and total is low, you have a queueing problem — try a different routing group or a less congested tier. If TTFT is fine and total is huge, the model is doing real work; no relay change will fix that.
*Script that does both: api-relay-benchmark · Docs: kuku-momo.github.io/ai-relay*