cleanup: unify request-id header to `x-aisix-request-id` across all endpoints
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 157
- Forks
- 32
- Avg merge
- 1h 25m
- Merged PRs (30d)
- 145
Description
Summary
Today the gateway emits two different response headers for the server-issued request id, depending on which endpoint handled the request:
- `x-aisix-request-id` — emitted by `/v1/messages`, `/v1/responses`, `/v1/rerank`, `/v1/audio/`, `/passthrough/`
- `x-aisix-call-id` — emitted only by `/v1/chat/completions` (single insert at `crates/aisix-proxy/src/chat.rs:122`)
- (no request-id header) — `/v1/completions`, `/v1/embeddings`, `/v1/images/generations`, `/v1/models`
The intent of the header is identical across endpoints — give the operator a UUID to echo when filing tickets — so the split header name is purely accidental drift.
Why this matters
- Operators grepping logs / dashboards / SDK error reports for one name miss requests served by the other endpoint.
- Customer SDKs that try to surface "which request did this trace?" can't do it uniformly.
- The split is documented as a known wart in docs/api-proxy.md §3 (added in #191), but the long-term fix is code-side convergence.
Proposed fix
- Change `crates/aisix-proxy/src/chat.rs:122` to insert `x-aisix-request-id` instead of `x-aisix-call-id`.
- Add the header to the four endpoints that emit nothing today: `/v1/completions`, `/v1/embeddings`, `/v1/images/generations`, `/v1/models`. Each handler already has a `request_id` UUID in scope; just `response.headers_mut().insert("x-aisix-request-id", hv)` before returning.
- Update `docs/api-proxy.md` §3 to drop the `x-aisix-call-id` row once the chat handler is converged.
- Backwards-compat: emit BOTH `x-aisix-call-id` and `x-aisix-request-id` from chat for one release if any internal tooling grep-matches the legacy name.
Severity
LOW: cosmetic / observability convergence. No functional impact on request handling.
Audit trail
Surfaced by the doc-vs-code audit on PR #191 (HIGH-3 finding: "9/10 endpoints" claim was wrong; real distribution is 5 / 1 / 4 / 0 across the four header states).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crates/aisix-proxy/src/chat.rs at line 122, then locate the handlers for /v1/completions, /v1/embeddings, /v1/images/generations, and /v1/models. Verify how each response is built and where its request_id is available. Done means all listed endpoints emit x-aisix-request-id, chat no longer relies only on x-aisix-call-id, and docs/api-proxy.md §3 reflects the unified behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, observability
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100