You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose x-request-id in SSE streaming responses for Java SDK聽#593
Please provide a way to access the x-request-id header in SSE streaming responses (e.g., via callback, metadata, or event property).
This would make debugging and support much easier without requiring a full switch to withRawResponse().
Plan: capture the initial OkHttp Response during SSE start, expose x-request-id via a new optional accessor on the stream/event surface, and add MockWebServer tests (header present/absent). This will be an additive, non-breaking change.
If this scope/layer is acceptable, I鈥檒l open a PR with tests and docs.
I think you won't want to start at the OkHttp layer. We expose the method for this here so you should be able to grab it from that.
I think it'd probably make sense to include the requestId method on the StreamResponse and AsyncStreamResponse interfaces (the event object seems wrong because the request ID is associated with the response, not each event)
So then people could do this:
OpenAIClientAsynccurrentClient = OpenAIOkHttpClientAsync.builder().build();
AsyncStreamResponse<...> response = currentClient.responses().createStreaming(params);
response
.subscribe(event -> {
// use response.requestId()
})
.onCompleteFuture()
.thenAccept(result -> {
// use response.requestId()
})
.exceptionally(ex -> {
// use response.requestId()returnnull;
});
If that all sounds good, then feel free to work on!
Activity
bhawnapannu2701 commentedon Sep 3, 2025
Hi! I鈥檇 like to pick this up.
Plan: capture the initial OkHttp Response during SSE start, expose
x-request-idvia a new optional accessor on the stream/event surface, and add MockWebServer tests (header present/absent). This will be an additive, non-breaking change.If this scope/layer is acceptable, I鈥檒l open a PR with tests and docs.
TomerAberbach commentedon Sep 3, 2025
I think you won't want to start at the OkHttp layer. We expose the method for this here so you should be able to grab it from that.
I think it'd probably make sense to include the
requestIdmethod on theStreamResponseandAsyncStreamResponseinterfaces (the event object seems wrong because the request ID is associated with the response, not each event)So then people could do this:
If that all sounds good, then feel free to work on!