Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 4 min read

Your AI feature isn't slow, it just looks slow

A user clicks "Generate summary" and stares at a spinner for eight seconds. They call your AI feature slow. The model did take eight seconds, but that is not the number they are complaining about. They are complaining ab

Your AI feature isn't slow, it just looks slow

A user clicks "Generate summary" and stares at a spinner for eight seconds. They call your AI feature slow. The model did take eight seconds, but that is not the number they are complaining about. They are complaining about the blank screen during them.

That difference is the most useful thing to understand about AI latency, because it splits one problem into two, and the two have completely different fixes.

Diagram titled Two clocks, one request, comparing the same eight-second AI request with and without streaming. A timeline runs left to right. Top row, No streaming: a spinner runs from the click to second 8, then the full answer appears at once; the user waits the whole bar. Bottom row, Streaming: the first token arrives at about second 1.5 and text keeps appearing until second 8; the user starts reading at the first-token mark. A note reads: same total time, different experience. Real speedups are a separate job: smaller model, fewer output tokens, prompt caching.

There are two clocks, not one

OpenAI's latency optimization guide defines both. Time to first token (TTFT) measures how long a request takes to start returning content. End-to-end latency measures how long the user waits for the complete result, from their action through retrieval, model calls, retries, and rendering.

Users judge the first clock. Your monitoring probably tracks the second.

This is why a feature can test fine and still get "it's slow" complaints. The p95 looks acceptable in a dashboard while every single user spends the whole wait looking at nothing.

And the wait is not harmless. Google's web.dev performance guide rounds up the research: fast experiences retain users better than sluggish ones, and in one cited finding the BBC lost an additional 10% of users for every extra second their site took to load. Those numbers come from page loads, not chatbots, but the mechanism is the same. A blank screen is a blank screen.

Streaming fixes the clock users judge

Both major providers ship the same mechanism: set stream: true and the response arrives incrementally over server-sent events instead of in one block at the end. The model does not get faster. The total time is the same, and sometimes a little longer. What changes is when the user sees the first word.

For anything a person reads as it is produced, that is the entire game. Someone reading your summary's first sentence at second 1.5 does not experience an eight-second wait. They experience a fast feature that keeps going while they read. People read far slower than models generate, so once text starts appearing, the reader rarely catches up to the cursor. The wait effectively ends at the first word.

In practice the change is small. The server keeps the HTTP connection open and sends each chunk as it is generated; the client appends text as it arrives instead of waiting for the full body. Both providers' SDKs ship helpers that accumulate the streamed events into the final message, so you still get the complete response for logging and storage. The work is in the display layer: render partial text, and decide what a failure halfway through the stream looks like, because an error can arrive after you have already shown the user three paragraphs.

Streaming also has a shape it fits. Reading-shaped outputs (summaries, drafts, answers) benefit. Structured outputs that feed a chart or a form do not, because nobody reads JSON as it streams. Match the mechanism to the output.

When it actually is slow

Streaming changes perception. It does not change the clock underneath, and sometimes that clock is the real problem. The same OpenAI guide lists the levers that genuinely cut time, and none of them are exotic:

  • Process tokens faster. A smaller or faster model tier for routine tasks. Keep the slowest configuration only where the quality target needs it.
  • Generate fewer tokens. Ask for the amount of detail the user needs. "Give the next step in one sentence" finishes sooner than an essay.
  • Use fewer input tokens. Trim the context you resend every call.
  • Cache repeated prefixes. Anthropic's prompt caching docs say resuming from cached prefixes significantly reduces processing time and cost for prompts with consistent elements. A system prompt plus a document template is exactly that.
  • Make fewer requests, and parallelize the ones you keep. Three sequential calls for retrieval, draft, and polish is a design choice, not a law.

One more trap the guide calls out directly: if TTFT looks good but users still see a blank screen, time the work before the model call. Retrieval queries, tool calls, auth checks, and rendering all sit on the user's clock too. A fast model behind a slow pipeline is a slow feature.

The habit that covers both

Measure both clocks separately, on representative traffic, at the median and the p95, the way the guide suggests. Then fix the one that is actually hurting: stream when the wait is the problem, cut tokens and calls when the time is.

The user who called your feature slow was giving you a bug report about a spinner, not a benchmark. Treat it that way and most of the fix is cheaper than a faster model.

I write about startups and AI at StartupWiki.

Cover photo: Wilhelm Gunkel on Unsplash.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.