How to distinguish time to first token from stream duration

Record a request start, the first content token and the last content token on the same clock. If possible, capture queue entry and upstream send events separately to locate delays before generation.

Example

A trace shows 2.4 seconds to first content and then 0.9 seconds of streaming. A second trace shows 0.4 seconds to first content and a 2.9-second stream. Both take 3.3 seconds and have different bottlenecks.

What to do

  1. Start timing at the same boundary for every request and distinguish a protocol frame from the first visible token.
  2. Record queue and upstream timestamps when available. Compare the same model, request class and output length across batches.
  3. Plot time to first content and stream duration separately for normal and high-load windows. Treat errors and cancellations as their own groups.

How to verify

Use a test stream with known server delays before and between chunks. The measurements should reflect where you added delay.

Limits

A gateway-only trace may not expose provider scheduling time. Report unobserved intervals together instead of claiming a provider breakdown.

Spendplane for this workflow

Open the API gateway quickstart

Related reading