Skip to content

Expose response header metadata on SDK responses#262

Open
ktamulonis wants to merge 1 commit intoopenai:mainfrom
ktamulonis:add-response-header-observability
Open

Expose response header metadata on SDK responses#262
ktamulonis wants to merge 1 commit intoopenai:mainfrom
ktamulonis:add-response-header-observability

Conversation

@ktamulonis
Copy link
Copy Markdown

@ktamulonis ktamulonis commented Mar 27, 2026

This change exposes response headers on successful SDK responses so callers can access values like openai-processing-ms and x-request-id for observability and
logging.

What this adds:

  • response_headers on standard model responses
  • response_headers on page responses
  • response_headers on stream objects

Implementation notes:

  • response headers were already captured internally in the transport layer
  • this change attaches them to successful non-streaming response objects and page objects
  • stream objects already held response headers internally; this surfaces them through a public method
  • this PR intentionally keeps the API narrow and does not add convenience accessors for individual headers
  • this does not change request behavior or retry behavior

Tests run:

  • bundle exec ruby -Itest test/openai/client_test.rb
  • bundle exec ruby -Itest test/openai/resources/responses/streaming_test.rb
  • bundle exec ruby -Itest test/openai/resources/chat/completions/streaming_test.rb
  • bundle exec rake test

@ktamulonis ktamulonis requested a review from a team as a code owner March 27, 2026 23:48
@ktamulonis ktamulonis force-pushed the add-response-header-observability branch from 5db14bc to eaef87f Compare March 31, 2026 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant