n4nAI

How chain-of-thought length predicts response latency

Analysis of how chain-of-thought length drives LLM response latency in reasoning models, with measurement code and latency budgeting tradeoffs.

n4n Team4 min read887 words

Audio narration

Coming soon — every post will get a voice note here.

Chain-of-thought length latency is the single most useful predictor of end-to-end response time when you call a reasoning model. Model parameter count and GPU flops matter far less than how many intermediate tokens the model writes before emitting its final answer. If you benchmark reasoning models without isolating CoT token count, you are measuring the wrong variable.

Why decoding is serial and CoT is the multiplier

Autoregressive transformers generate one token at a time. The GPU computes a forward pass per token, and although continuous batching hides some cost across concurrent requests, a single user request waits for the full sequence to unfold serially.

A reasoning model explicitly emits hidden or visible reasoning steps. Those steps are just completion tokens. If a model thinks for 500 tokens before answering, you pay 500 decode steps of latency on top of the answer itself.

Consider a trivial arithmetic query. A standard chat model might answer in 10 tokens. A reasoning model forced to show chain-of-thought could emit 200 tokens of scratchwork. The chain-of-thought length latency gap is 20x, independent of model size.

The prefill phase (processing your prompt) scales with input length, but for interactive queries it is often milliseconds. Decode dominates because it cannot be parallelized for a single sequence.

Measuring chain-of-thought length latency in practice

You cannot optimize what you do not measure. Most OpenAI-compatible endpoints return token counts in the usage object. Pair that with wall-clock time to get a direct signal.

import time, openai

client = openai.OpenAI(base_url="https://api.example.com/v1", api_key="sk-...")

start = time.perf_counter()
resp = client.chat.completions.create(
    model="reasoning-model",
    messages=[{"role": "user", "content": "Prove sqrt(2) is irrational."}],
)
elapsed = time.perf_counter() - start

print(f"Latency: {elapsed:.2f}s")
print(f"Completion tokens: {resp.usage.completion_tokens}")

The completion_tokens field includes the chain-of-thought unless the provider strips it from the response. Some reasoning APIs hide CoT and only count the visible answer; in that case you must infer length from latency or use a debug flag that exposes the raw trace.

Fitting the linear model

A linear model fits observed data well:

latency ≈ prefill_ms + decode_ms_per_token * completion_tokens

If you collect samples across tasks, fit the slope with ordinary least squares. The slope is your chain-of-thought length latency coefficient for that model and hardware path.

{
  "task": "math-proof",
  "model": "reasoning-model",
  "latency_ms": 4200,
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 380,
    "total_tokens": 404
  }
}

Plot latency versus completion_tokens. The intercept tells you fixed overhead; the slope tells you cost per reasoning token. A 70B model may have a similar slope to a 7B model on the same accelerator if both decode at comparable token rates, but the 70B model may choose longer CoT.

Task complexity drives CoT variance, not model size

Engineers often assume a bigger model is slower. For reasoning models, the bigger driver is how hard the model thinks the problem is.

A 7B reasoning distill might write 600 tokens on a coding puzzle. A 70B frontier reasoning model might write 900 tokens on the same puzzle but get it right. The latency difference is 50% because of chain-of-thought length, not because of 10x parameters.

We can see this in qualitative behavior: reasoning models dynamically allocate tokens. Easy queries get short CoT; hard ones trigger long explorations. Your p95 latency is therefore determined by your hardest queries, not your average.

This makes chain-of-thought length latency a moving target. A prompt change that nudges the model to “think step by step” can double tokens and double wait time. A slight rephrase that makes the intent unambiguous can halve the reasoning trace.

Tradeoffs: accuracy vs latency budget

Longer chain-of-thought improves accuracy on benchmarks like GSM8K or MATH. But users abandon interfaces that take >2s for simple questions. You are trading correctness for responsiveness.

You have three levers:

  1. Cap completion tokens.
  2. Route easy tasks to non-reasoning models.
  3. Prompt for concise reasoning.

Capping is simplest. Set max_tokens to bound worst-case decode.

resp = client.chat.completions.create(
    model="reasoning-model",
    messages=[{"role": "user", "content": "What is 12*12?"}],
    max_tokens=150  # forces model to finish answer within budget
)

If the model hits the cap mid-reasoning, you get truncated output. That is a hard tradeoff: predictability over completeness.

Routing requires knowing task difficulty upfront. A heuristic classifier or a cheap model can decide. For example, send only queries containing “prove” or “debug” to the reasoning model. Everything else goes to a fast instruct model.

Prompt design matters. Adding “Answer in under 50 words and skip detailed reasoning unless necessary” can shrink CoT dramatically. Test it; some models ignore the instruction and reason anyway.

Streaming does not reduce total chain-of-thought length latency, but it improves perceived latency. The first token still waits for prefill plus the initial reasoning tokens. If your CoT is 400 tokens, the user sees nothing until that thinking completes unless the API streams intermediate steps.

Routing and fallback implications

When you serve traffic across multiple providers, chain-of-thought length latency becomes a cross-vendor metric. A gateway that meters per-token usage lets you compare effective decode speed normalized by reasoning tokens.

n4n.ai exposes one OpenAI-compatible endpoint for 240+ models and records completion tokens per call, so you can plot latency against CoT length across providers without writing custom instrumentation. Automatic fallback also prevents a degraded provider from silently inflating latency while your model stalls.

Client routing directives let you pin to models known for shorter reasoning traces. Forwarding provider cache-control hints can reduce prefill, but decode remains the bottleneck because CoT length is the multiplier.

A decisive takeaway

Treat chain-of-thought length latency as your primary latency SLI for any reasoning model integration. Measure completion tokens on every call, fit a per-model decode slope, and set token budgets aligned to user patience.

Do not pay for reasoning where a smaller model suffices. Use routing, caps, and prompt constraints to keep CoT bounded. The model that thinks least on your task is the fastest—and often good enough.

Tagschain-of-thoughtreasoning-modellatency-overheadlatency-benchmark

Written by

n4n Team

The team building n4n — a single OpenAI-compatible API in front of 240+ models, with automatic fallback, load balancing and pay-per-token metering.

More from n4n Team →

All reasoning model latency overhead posts →