Reference

Request ids

Every response carries one. What to log, where to find it after the fact, and what quoting it lets us do.

Every response from every endpoint carries x-request-id. Chat completions also return it in the body:

"dawnstack": { "cost_micros": 6, "cost_usd": 0.000006, "request_id": "req_8f2a1c" }

Both are the same value. The header is there for errors, where there may be no useful body; the body field is there so it lands in your own logs next to the thing it describes without you having to reach for response headers.

Log it

reply = client.chat.completions.with_raw_response.create(
    model="llama-3.1-8b",
    messages=messages,
)
print(reply.headers["x-request-id"])

parsed = reply.parse()
print(parsed.model_extra["dawnstack"]["request_id"])
const res = await client.chat.completions
  .create({ model: "llama-3.1-8b", messages })
  .withResponse();

console.log(res.response.headers.get("x-request-id"));
console.log(res.data.dawnstack.request_id);

On an error, the SDKs expose the headers on the exception, and a 500 also puts the id in the error body so there is something to quote even if headers were lost in transit. See Errors.

What it gets you

A request id resolves to one usage record: the model asked for, the model that actually served it, token counts, what it cost, how long it took, and whether the settle succeeded. Quoting one turns “a request failed this morning” into a lookup.

Without it we have your account and a time range, which is a search.

It is not a secret

It identifies a request, not you, and it carries no key material. Paste it into an issue.