Class: OpenAI::ResponseMetadata
- Inherits:
-
Object
- Object
- OpenAI::ResponseMetadata
- Defined in:
- lib/openai/http_client.rb,
sig/openai/http_client.rbs
Overview
Metadata from the HTTP response backing a top-level SDK value.
Instance Attribute Summary collapse
-
#headers ⇒ Hash{String=>String}
readonly
Immutable response headers with lowercase String keys.
-
#request_id ⇒ String?
readonly
The request ID returned in the
x-request-idresponse header. -
#status ⇒ Integer
readonly
The HTTP response status code.
Instance Method Summary collapse
-
#initialize(status:, headers:) ⇒ ResponseMetadata
constructor
private
A new instance of ResponseMetadata.
Constructor Details
#initialize(status:, headers:) ⇒ ResponseMetadata
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ResponseMetadata.
27 28 29 30 31 32 33 34 35 |
# File 'lib/openai/http_client.rb', line 27 def initialize(status:, headers:) @status = Integer(status) @headers = headers.to_h do |name, value| [name.to_s.downcase.freeze, value.to_s.dup.freeze] end.freeze @request_id = @headers["x-request-id"] freeze end |
Instance Attribute Details
#headers ⇒ Hash{String=>String} (readonly)
Immutable response headers with lowercase String keys.
16 17 18 |
# File 'lib/openai/http_client.rb', line 16 def headers @headers end |
#request_id ⇒ String? (readonly)
The request ID returned in the x-request-id response header.
21 22 23 |
# File 'lib/openai/http_client.rb', line 21 def request_id @request_id end |
#status ⇒ Integer (readonly)
The HTTP response status code.
11 12 13 |
# File 'lib/openai/http_client.rb', line 11 def status @status end |