openai / openai/openai-java

Expose x-request-id in SSE streaming responses for Java SDK

Open
#593 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement sdk
Dominant language
Kotlin
Stars
1.5k
Forks
264
Avg merge
9h 46m
Merged PRs (30d)
96

Description

Description

We need access to the x-request-id header to debug API requests with the OpenAI team, as described in the official docs:
👉 https://platform.openai.com/docs/api-reference/debugging-requests

Although x-request-id can be obtained when using:

OpenAIClientAsync.withRawResponse()

We are using SSE streaming in our project, below is example code:

OpenAIClientAsync currentClient = OpenAIOkHttpClientAsync.builder().build();

currentClient.responses().createStreaming(params)
    .subscribe(event -> {
        // business logic
    })
    .onCompleteFuture()
    .thenAccept(result -> {
        // handle completion
    })
    .exceptionally(ex -> {
        // handle error
        return null;
    });
Feature request

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().

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names OpenAIClientAsync and responses().createStreaming, but no implementation files or tests. Start by tracing createStreaming through SSE response handling and compare it with withRawResponse() header access. Done means callers can reliably read x-request-id from streaming responses, with tests covering the exposed access path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.