Class: OpenAI::ResponseMetadata

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Parameters:

  • status (Integer)
  • headers (Hash{String=>String})
  • status: (Integer)
  • headers: (::Hash[String, String])


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

#headersHash{String=>String} (readonly)

Immutable response headers with lowercase String keys.

Returns:

  • (Hash{String=>String})


16
17
18
# File 'lib/openai/http_client.rb', line 16

def headers
  @headers
end

#request_idString? (readonly)

The request ID returned in the x-request-id response header.

Returns:

  • (String, nil)


21
22
23
# File 'lib/openai/http_client.rb', line 21

def request_id
  @request_id
end

#statusInteger (readonly)

The HTTP response status code.

Returns:

  • (Integer)


11
12
13
# File 'lib/openai/http_client.rb', line 11

def status
  @status
end