Reference
Request ids
Each response has a request id. Where to find it, what to log, and what we can find in our records when you send it to us.
Each response from each endpoint has an x-request-id header. A response without a stream also has
the id in its body:
"kontinent": { "request_id": "req_8f2a1c", "cost_micros": 13, "cost_usd": 0.000013, "list_price_usd": 0.000061, "saved_usd": 0.000048 }
The header and the body field have the same value. The header is also on errors, where the body can be short. The body field puts the id in your own logs, beside the answer.
Log it
reply = client.chat.completions.with_raw_response.create(
model="claude-haiku-4-5-20251001",
messages=messages,
)
print(reply.headers["x-request-id"])
parsed = reply.parse()
print(parsed.model_extra["kontinent"]["request_id"])const res = await client.chat.completions
.create({ model: "claude-haiku-4-5-20251001", messages })
.withResponse();
console.log(res.response.headers.get("x-request-id"));
console.log(res.data.kontinent.request_id);On an error, the SDKs give the headers on the exception. A 500 error and each error from
/v1/messages also have the id in the body. See Errors.
What the id gives us
A request id finds one usage record: the model, the token counts, the cost, the time, and the route that served the request. With the id, we can find your request immediately. Without the id, we must search your account in a time range.
It is not a secret
The id identifies a request, not you, and it contains no part of your key. You can put it in an issue or a message.