Skip to content

feat: expose raw HTTP responses - #262

Open
ktamulonis wants to merge 3 commits into
openai:mainfrom
ktamulonis:add-response-header-observability
Open

feat: expose raw HTTP responses#262
ktamulonis wants to merge 3 commits into
openai:mainfrom
ktamulonis:add-response-header-observability

Conversation

@ktamulonis

@ktamulonis ktamulonis commented Mar 27, 2026

Copy link
Copy Markdown

Summary

Adds an explicit raw-response modifier for generated HTTP operations:

raw = openai.models.with_raw_response.retrieve("gpt-5.2")

puts(raw.status)
puts(raw.headers["openai-processing-ms"])
puts(raw.request_id)
puts(raw.read)

model = raw.parse

OpenAI::RawResponse[T] exposes the HTTP status, normalized immutable headers,
request ID, buffered body, and a lazy cached parsed value without changing the
operation's arguments or normal error behavior.

API contract

  • Ordinary top-level models and pages retain the _request_id convenience
    introduced by feat: expose request IDs #352.
  • raw.request_id and raw.parse._request_id are the same value when the
    parsed result is a model or page.
  • Raw responses provide metadata for model, page, primitive, binary, and nil
    results.
  • Full response headers are not attached to models, pages, nested values, or
    helper-assembled streaming snapshots.
  • Higher-level streaming helpers continue to expose status and headers
    directly on their stream objects.
  • Generated resource navigation and HTTP method signatures are preserved in
    Ruby, RBI, and RBS.

This follows the explicit raw-response pattern used by the other OpenAI SDKs
while keeping transport metadata separate from API-schema models.

Generator ownership

The generated resource wrappers and type signatures are owned by the Castiron
source change in openai/openai#1272460. That companion PR prevents future SDK
generation from overwriting this API.

Validation

  • Ruby 4.0.6: 567 tests, 2,903 assertions
  • Ruby 3.3.12: 567 tests, 2,903 assertions
  • Raw-response contract: 9 tests, 1,001 assertions
  • RuboCop: 2,608 files, no offenses
  • Sorbet: no errors
  • RBS: 1,214 files validated
  • Gem build and package-content inspection
  • Thermo-nuclear code-quality review

@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
@jbeckwith-oai jbeckwith-oai added the generator Touches generated SDK files label Jul 16, 2026
@jbeckwith-oai
jbeckwith-oai force-pushed the add-response-header-observability branch from eaef87f to 4571067 Compare August 10, 2026 21:56
@jbeckwith-oai jbeckwith-oai changed the title Expose response header metadata on SDK responses feat: expose response header metadata on SDK responses Aug 10, 2026

@HAYDEN-OAI HAYDEN-OAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. I left one low-priority serialization-boundary comment inline.

Comment thread lib/openai/internal/type/base_model.rb
@jbeckwith-oai jbeckwith-oai changed the title feat: expose response header metadata on SDK responses feat: expose raw HTTP responses Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

generator Touches generated SDK files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants