New Tool Radar

Local Model Setup

How to Track a vLLM Request With the X-Request-Id Header

Enable --enable-request-id-headers in vLLM and send X-Request-Id so each request can be traced through logs and replies.

Schematic diagram with four steps: enable request-id headers on the server, send X-Request-Id with the request, read the echoed ID from the reply, then match it in the server log.

When a vLLM server handles many requests at once, matching a slow or failed reply to the log lines that produced it is guesswork — unless each request carries its own ID. vLLM supports the X-Request-Id header for exactly that, once you enable it.

Enable the header and send an ID per request

Start the server with --enable-request-id-headers. Then send a chat completion with the X-Request-Id header set to your own ID, for example sentiment-classification-00001. The OpenAI client sends it through extra_headers, and the reply object carries the same ID back in completion._request_id, so your code can log the pair together.

vllm serve Qwen/Qwen2.5-1.5B-Instruct --enable-request-id-headers
completion = client.chat.completions.create(
    model="Qwen/Qwen2.5-1.5B-Instruct",
    messages=[{"role": "user", "content": "Hello!"}],
    extra_headers={"x-request-id": "sentiment-classification-00001"},
)
print(completion._request_id)

The same header works on the plain completions endpoint. vLLM also supports an X-Vllm-Priority header for request priority, but that is a different feature — priority changes scheduling order, while the request ID only labels the request for tracing.

Try it: four checks

Check What you should see If you do not see it
Flag on The server starts with –enable-request-id-headers Check the flag spelling on your version
Header sent The request carries X-Request-Id Use extra_headers in the OpenAI client
ID echoed completion._request_id matches what you sent Compare the sent and returned values
Logs match The server log shows the same ID Search the log for your ID string

Expected result. We checked the vLLM OpenAI-Compatible Server docs, which say the X-Request-Id header is enabled with –enable-request-id-headers and show the extra_headers example with completion._request_id. We did not run vLLM on this machine.

Limits

This guide covers request tracing only. Request priority is a separate header with its own rules, and non-zero priorities need priority scheduling. We did not test any of this ourselves.

Sources

See all