Skip to content

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

@lxyyukiko0206-cloud

Description

@lxyyukiko0206-cloud

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions