Skip to content

Expose rawResponse in OrchestrationStreamResponse for request tracing and debugging #1433

Description

@jerome-benoit

Describe the Problem

OrchestrationStreamResponse does not expose the underlying HTTP response headers, specifically x-request-id, which is available in non-streaming mode via response.rawResponse.headers["x-request-id"].

This prevents:

  • Correlating client requests with SAP AI Core backend logs
  • Providing request IDs to SAP support for debugging
  • Building proper observability and auditing systems
  • Consistent metadata in downstream integrations (e.g., Vercel AI SDK providers)

Propose a Solution

Add readonly rawResponse?: HttpResponse to OrchestrationStreamResponse, matching the non-streaming API design:

export class OrchestrationStreamResponse<T> {
  readonly rawResponse?: HttpResponse; // NEW
  // ... existing properties
}

Usage:

const streamResponse = await client.stream(requestBody, signal);
const requestId = streamResponse.rawResponse?.headers["x-request-id"];

This is fully backward compatible (optional property) and provides consistent developer experience across streaming/non-streaming modes.

Describe Alternatives

Current workaround: Generate client-side UUID instead of using backend request ID (loses correlation with backend logs).

Alternative considered: Add getRequestMetadata() method, but direct property access is simpler and consistent with non-streaming API.

Affected Development Phase

Development

Impact

Inconvenience

Timeline

Non-blocking, but increasingly important as streaming becomes standard for production applications requiring observability.

Additional Context

  • Downstream package: @mymediset/sap-ai-provider (Vercel AI SDK integration)
  • Current workaround: Using client-generated UUIDs instead of backend x-request-id
  • Similar implementations: OpenAI, Anthropic, and Google AI SDKs expose request IDs in both streaming and non-streaming modes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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