openai 0.106.0 → 0.107.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -0
  3. data/README.md +1 -1
  4. data/lib/openai/helpers/live/websocket.rb +12 -141
  5. data/lib/openai/helpers/local_audio/process.rb +13 -3
  6. data/lib/openai/helpers/models/embedding.rb +42 -0
  7. data/lib/openai/helpers/realtime/connection.rb +22 -5
  8. data/lib/openai/helpers/realtime/recovery.rb +11 -5
  9. data/lib/openai/helpers/realtime/translation.rb +37 -169
  10. data/lib/openai/helpers/realtime/unknown_server_event.rb +5 -12
  11. data/lib/openai/helpers/responses_websocket/connection.rb +56 -35
  12. data/lib/openai/helpers/responses_websocket/unknown_server_event.rb +2 -14
  13. data/lib/openai/helpers/websocket/async_websocket_transport.rb +8 -6
  14. data/lib/openai/helpers/websocket/client_request.rb +1 -1
  15. data/lib/openai/helpers/websocket/connection.rb +21 -10
  16. data/lib/openai/helpers/websocket/connection_manager.rb +2 -1
  17. data/lib/openai/helpers/websocket/protocol.rb +160 -0
  18. data/lib/openai/helpers/websocket/typed_connection.rb +22 -16
  19. data/lib/openai/helpers/websocket/typed_resource.rb +15 -0
  20. data/lib/openai/internal/transport/base_client.rb +1 -1
  21. data/lib/openai/models/admin/organization/usage_audio_speeches_response.rb +12 -1
  22. data/lib/openai/models/admin/organization/usage_audio_transcriptions_response.rb +12 -1
  23. data/lib/openai/models/admin/organization/usage_code_interpreter_sessions_response.rb +12 -1
  24. data/lib/openai/models/admin/organization/usage_completions_response.rb +12 -1
  25. data/lib/openai/models/admin/organization/usage_costs_response.rb +12 -1
  26. data/lib/openai/models/admin/organization/usage_decisions_response.rb +12 -1
  27. data/lib/openai/models/admin/organization/usage_embeddings_response.rb +12 -1
  28. data/lib/openai/models/admin/organization/usage_file_search_calls_response.rb +12 -1
  29. data/lib/openai/models/admin/organization/usage_images_response.rb +12 -1
  30. data/lib/openai/models/admin/organization/usage_moderations_response.rb +12 -1
  31. data/lib/openai/models/admin/organization/usage_vector_stores_response.rb +12 -1
  32. data/lib/openai/models/admin/organization/usage_web_search_calls_response.rb +12 -1
  33. data/lib/openai/models/beta/beta_response_input_item.rb +10 -1
  34. data/lib/openai/models/responses/response_input_item.rb +10 -1
  35. data/lib/openai/version.rb +1 -1
  36. data/lib/openai.rb +1 -0
  37. data/rbi/openai/client.rbi +1 -8
  38. data/rbi/openai/helpers/realtime/translation.rbi +0 -5
  39. data/rbi/openai/helpers/realtime/unknown_server_event.rbi +6 -0
  40. data/rbi/openai/helpers/websocket.rbi +44 -6
  41. data/rbi/openai/internal/transport/base_client.rbi +2 -6
  42. data/rbi/openai/models/admin/organization/usage_audio_speeches_response.rbi +12 -0
  43. data/rbi/openai/models/admin/organization/usage_audio_transcriptions_response.rbi +12 -0
  44. data/rbi/openai/models/admin/organization/usage_code_interpreter_sessions_response.rbi +12 -0
  45. data/rbi/openai/models/admin/organization/usage_completions_response.rbi +12 -0
  46. data/rbi/openai/models/admin/organization/usage_costs_response.rbi +12 -0
  47. data/rbi/openai/models/admin/organization/usage_decisions_response.rbi +12 -0
  48. data/rbi/openai/models/admin/organization/usage_embeddings_response.rbi +12 -0
  49. data/rbi/openai/models/admin/organization/usage_file_search_calls_response.rbi +12 -0
  50. data/rbi/openai/models/admin/organization/usage_images_response.rbi +12 -0
  51. data/rbi/openai/models/admin/organization/usage_moderations_response.rbi +12 -0
  52. data/rbi/openai/models/admin/organization/usage_vector_stores_response.rbi +12 -0
  53. data/rbi/openai/models/admin/organization/usage_web_search_calls_response.rbi +12 -0
  54. data/rbi/openai/models/beta/beta_response_input_item.rbi +14 -1
  55. data/rbi/openai/models/responses/response_input_item.rbi +10 -1
  56. data/realtime.md +22 -3
  57. data/sig/openai/client.rbs +1 -1
  58. data/sig/openai/helpers/realtime/translation.rbs +0 -2
  59. data/sig/openai/helpers/realtime/unknown_server_event.rbs +2 -0
  60. data/sig/openai/helpers/websocket.rbs +23 -6
  61. data/sig/openai/models/admin/organization/usage_audio_speeches_response.rbs +10 -0
  62. data/sig/openai/models/admin/organization/usage_audio_transcriptions_response.rbs +10 -0
  63. data/sig/openai/models/admin/organization/usage_code_interpreter_sessions_response.rbs +10 -0
  64. data/sig/openai/models/admin/organization/usage_completions_response.rbs +10 -0
  65. data/sig/openai/models/admin/organization/usage_costs_response.rbs +10 -0
  66. data/sig/openai/models/admin/organization/usage_decisions_response.rbs +10 -0
  67. data/sig/openai/models/admin/organization/usage_embeddings_response.rbs +10 -0
  68. data/sig/openai/models/admin/organization/usage_file_search_calls_response.rbs +10 -0
  69. data/sig/openai/models/admin/organization/usage_images_response.rbs +10 -0
  70. data/sig/openai/models/admin/organization/usage_moderations_response.rbs +10 -0
  71. data/sig/openai/models/admin/organization/usage_vector_stores_response.rbs +10 -0
  72. data/sig/openai/models/admin/organization/usage_web_search_calls_response.rbs +10 -0
  73. data/sig/openai/models/beta/beta_response_input_item.rbs +8 -0
  74. data/sig/openai/models/responses/response_input_item.rbs +8 -3
  75. metadata +3 -1
@@ -6,6 +6,166 @@ module OpenAI
6
6
  #
7
7
  # @api private
8
8
  module Protocol
9
+ # JSON schemas and extension data do not have a transport-specific depth limit.
10
+ private def parse_json(data) = JSON.parse(data, symbolize_names: true, max_nesting: false)
11
+
12
+ private def generate_json(value) = JSON.generate(value, max_nesting: false)
13
+
14
+ private def freeze_json(value)
15
+ pending = [value]
16
+ visited = {}.compare_by_identity
17
+ until pending.empty?
18
+ item = pending.pop
19
+ next if visited.key?(item)
20
+ visited[item] = true
21
+ case item
22
+ when Hash
23
+ item.each { |key, val| pending.push(key, val) }
24
+ when Array
25
+ pending.concat(item)
26
+ end
27
+
28
+ item.freeze
29
+ end
30
+
31
+ value
32
+ end
33
+
34
+ # Unknown wire keys must not replace a selected model's renamed Ruby fields.
35
+ private def validate_wire_field_names!(event, payload)
36
+ pending = [[event, payload]]
37
+ until pending.empty?
38
+ value, raw = pending.pop
39
+ case value
40
+ when OpenAI::Internal::Type::BaseModel
41
+ value.class.fields.each do |name, field|
42
+ raise ArgumentError if name != field.fetch(:api_name) && raw.is_a?(Hash) && raw.key?(name)
43
+ end
44
+
45
+ value.to_h.each do |name, child|
46
+ field = value.class.fields[name]
47
+ key = field ? field.fetch(:api_name) : name
48
+ pending << [child, raw.is_a?(Hash) ? raw[key] : nil]
49
+ end
50
+
51
+ when Hash
52
+ value.each { |name, child| pending << [child, raw.is_a?(Hash) ? raw[name] : nil] }
53
+ when Array
54
+ value.each_with_index { |child, index| pending << [child, raw.is_a?(Array) ? raw[index] : nil] }
55
+ end
56
+ end
57
+
58
+ event
59
+ end
60
+
61
+ private def coerce_event(union, payload, outbound: false)
62
+ state = OpenAI::Internal::Type::Converter.new_coerce_state(request_only: outbound)
63
+ event = OpenAI::Internal::Type::Converter.coerce(union, payload, state: state)
64
+ raise ArgumentError if state[:error] || !state.fetch(:exactness).fetch(:no).zero?
65
+ ancestors = {}.compare_by_identity
66
+ pending = [[event, false]]
67
+ until pending.empty?
68
+ value, exiting = pending.pop
69
+ if exiting
70
+ ancestors.delete(value)
71
+ next
72
+ end
73
+
74
+ children = case value
75
+ when OpenAI::Internal::Type::BaseModel
76
+ data = value.to_h
77
+ validate_model_fields!(value)
78
+ value.class.fields.each do |name, field|
79
+ const = field.fetch(:const)
80
+ if field.fetch(:required) &&
81
+ field.fetch(:mode) != (outbound ? :coerce : :dump) &&
82
+ (!outbound || const == OpenAI::Internal::OMIT) &&
83
+ !data.key?(name)
84
+ raise ArgumentError
85
+ end
86
+ end
87
+
88
+ data.values
89
+ when Hash
90
+ value.values
91
+ when Array
92
+ value
93
+ else
94
+ next
95
+ end
96
+
97
+ raise ArgumentError if ancestors.key?(value)
98
+ ancestors[value] = true
99
+ pending << [value, true]
100
+ children.each { |child| pending << [child, false] }
101
+ end
102
+
103
+ event
104
+ end
105
+
106
+ private def validate_event_tree!(event, json_only: false, strict_keys: true)
107
+ ancestors = {}.compare_by_identity
108
+ pending = [[event, false]]
109
+ until pending.empty?
110
+ value, exiting = pending.pop
111
+ if exiting
112
+ ancestors.delete(value)
113
+ next
114
+ end
115
+
116
+ children = case value
117
+ when OpenAI::Internal::Type::BaseModel
118
+ raise ArgumentError if json_only
119
+ data = value.to_h
120
+ validate_model_fields!(value)
121
+ [data]
122
+ when Hash
123
+ if strict_keys
124
+ keys = {}
125
+ value.each_key do |key|
126
+ raise ArgumentError unless key.is_a?(String) || key.is_a?(Symbol)
127
+ name = key.to_s
128
+ raise ArgumentError if keys.key?(name)
129
+ keys[name] = true
130
+ end
131
+ end
132
+
133
+ value.values
134
+ when Array
135
+ value
136
+ when NilClass, TrueClass, FalseClass, String, Integer, Float, Symbol
137
+ next
138
+ else
139
+ raise ArgumentError if json_only
140
+ next
141
+ end
142
+
143
+ raise ArgumentError if ancestors.key?(value)
144
+ ancestors[value] = true
145
+ pending << [value, true]
146
+ children.each { |child| pending << [child, false] }
147
+ end
148
+ end
149
+
150
+ private def validate_model_fields!(model)
151
+ names = {}
152
+ model.to_h.each do |name, actual|
153
+ key = name.is_a?(String) ? name.to_sym : name
154
+ field = model.class.known_fields[key]
155
+ serialized_name = field ? field.fetch(:api_name).to_s : key.to_s
156
+ raise ArgumentError if names.key?(serialized_name)
157
+ names[serialized_name] = true
158
+ next unless field
159
+ const = field.fetch(:const)
160
+ next if const == OpenAI::Internal::OMIT
161
+ if const.is_a?(Symbol)
162
+ raise ArgumentError unless (actual.is_a?(String) || actual.is_a?(Symbol)) && actual.to_s == const.to_s
163
+ elsif actual != const
164
+ raise ArgumentError
165
+ end
166
+ end
167
+ end
168
+
9
169
  private def discriminator_values(union)
10
170
  union.variants.to_h do |variant|
11
171
  value = variant.fields.fetch(:type).fetch(:const)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OpenAI
4
4
  module WebSocket
5
- # Generic event codec for APIs with generated bindings and no specialized helper.
5
+ # Shared event codec for generated bindings and specialized product facades.
6
6
  #
7
7
  # @api private
8
8
  class TypedConnection < Connection
@@ -30,36 +30,36 @@ module OpenAI
30
30
  end
31
31
 
32
32
  private def encode_client_event(event)
33
- event_type(event, message: "Invalid WebSocket client event.") if event.is_a?(Hash)
33
+ validate_event_tree!(event)
34
+ event_type(event, message: client_event_error_message) if event.is_a?(Hash)
34
35
  payload = @client_event ? OpenAI::Internal::Type::Converter.dump(@client_event, event) : event
35
- type = event_type(payload, message: "Invalid WebSocket client event.")
36
+ type = event_type(payload, message: client_event_error_message)
36
37
  if @client_event && !@client_event_types.any? { _1.nil? || _1 === type.to_sym || _1 === type.to_s }
37
- raise ArgumentError, "Invalid WebSocket client event."
38
+ raise ArgumentError, client_event_error_message
38
39
  end
39
40
 
40
- payload = coerce(@client_event, payload) if @client_event
41
+ payload = coerce_client_event(payload) if @client_event
41
42
  payload = OpenAI::Internal::Type::Converter.dump(@client_event, payload) if @client_event
42
- JSON.generate(payload, max_nesting: false)
43
+ validate_event_tree!(payload, json_only: true)
44
+ generate_json(payload)
43
45
  rescue StandardError, SystemStackError
44
- raise ArgumentError, "Invalid WebSocket client event.", cause: nil
46
+ raise ArgumentError, client_event_error_message, cause: nil
45
47
  end
46
48
 
47
49
  def parse_event(data)
48
- parsed = JSON.parse(data, symbolize_names: true, max_nesting: false)
50
+ parsed = parse_json(data)
49
51
  type = event_type(parsed, message: "WebSocket server event must be an object with a string type")
50
52
  _, model = @server_event_types.find { |event_type,| event_type === type.to_sym }
51
- return parsed unless model
53
+ return unknown_server_event(parsed) unless model
52
54
 
53
- # Unknown wire fields must not overwrite a known field's Ruby name.
54
- model.fields.each do |name, field|
55
- raise ArgumentError if name != field.fetch(:api_name) && parsed.key?(name)
56
- end
57
-
58
- coerce(@server_event, parsed)
55
+ event = coerce(@server_event, parsed)
56
+ validate_wire_field_names!(event, parsed)
59
57
  rescue StandardError, SystemStackError
60
- raise OpenAI::Errors::WebSocketProtocolError, "Invalid WebSocket server event.", cause: nil
58
+ raise protocol_error, cause: nil
61
59
  end
62
60
 
61
+ private def coerce_client_event(payload) = coerce(@client_event, payload)
62
+
63
63
  private def coerce(type, value)
64
64
  state = OpenAI::Internal::Type::Converter.new_coerce_state
65
65
  result = OpenAI::Internal::Type::Converter.coerce(type, value, state: state)
@@ -70,6 +70,12 @@ module OpenAI
70
70
  result
71
71
  end
72
72
 
73
+ private def client_event_error_message = "Invalid WebSocket client event."
74
+
75
+ private def unknown_server_event(payload) = payload
76
+
77
+ private def protocol_error = OpenAI::Errors::WebSocketProtocolError.new("Invalid WebSocket server event.")
78
+
73
79
  private def connection_error(message) = BindingConnectionError.new(url: @url, message: message)
74
80
 
75
81
  private def transport_error = connection_error("WebSocket transport failed.")
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "resource"
4
+
5
+ module OpenAI
6
+ module WebSocket
7
+ # Supplies the generic signature contract for generated event bindings.
8
+ # Connection lifecycle and event handling are implemented by Resource.
9
+ #
10
+ # @api private
11
+ module TypedResource
12
+ include Resource
13
+ end
14
+ end
15
+ end
@@ -1012,7 +1012,7 @@ module OpenAI
1012
1012
  T::Class[OpenAI::Internal::Type::BaseStream[T.anything, OpenAI::Internal::Type::BaseModel]]
1013
1013
  ),
1014
1014
  model: T.nilable(OpenAI::Internal::Type::Converter::Input),
1015
- security: T.nilable({bearer_auth?: T::Boolean, admin_api_key_auth?: T::Boolean}),
1015
+ security: T.nilable(T::Hash[Symbol, T::Boolean]),
1016
1016
  options: T.nilable(OpenAI::RequestOptions::OrHash)
1017
1017
  }
1018
1018
  end
@@ -235,6 +235,13 @@ module OpenAI
235
235
  # @return [Integer, nil]
236
236
  optional :input_cache_write_12h_tokens, Integer
237
237
 
238
+ # @!attribute input_cache_write_30m_tokens
239
+ # The aggregated number of input tokens written to the cache with a 30-minute
240
+ # retention period. May be absent or null for older responses.
241
+ #
242
+ # @return [Integer, nil]
243
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
244
+
238
245
  # @!attribute input_cache_write_tokens
239
246
  # The aggregated number of input tokens written to the cache with a 30-minute
240
247
  # retention period.
@@ -333,7 +340,7 @@ module OpenAI
333
340
  # @return [String, nil]
334
341
  optional :user_id, String, nil?: true
335
342
 
336
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
343
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
337
344
  # The aggregated completions usage details of the specific time bucket.
338
345
  #
339
346
  # @param input_tokens [Integer]
@@ -370,6 +377,10 @@ module OpenAI
370
377
  # The aggregated number of input tokens written to the cache with a 12-hour
371
378
  # retention period.
372
379
  #
380
+ # @param input_cache_write_30m_tokens [Integer, nil]
381
+ # The aggregated number of input tokens written to the cache with a 30-minute
382
+ # retention period. May be absent or null for older responses.
383
+ #
373
384
  # @param input_cache_write_tokens [Integer]
374
385
  # The aggregated number of input tokens written to the cache with a 30-minute
375
386
  # retention period.
@@ -237,6 +237,13 @@ module OpenAI
237
237
  # @return [Integer, nil]
238
238
  optional :input_cache_write_12h_tokens, Integer
239
239
 
240
+ # @!attribute input_cache_write_30m_tokens
241
+ # The aggregated number of input tokens written to the cache with a 30-minute
242
+ # retention period. May be absent or null for older responses.
243
+ #
244
+ # @return [Integer, nil]
245
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
246
+
240
247
  # @!attribute input_cache_write_tokens
241
248
  # The aggregated number of input tokens written to the cache with a 30-minute
242
249
  # retention period.
@@ -335,7 +342,7 @@ module OpenAI
335
342
  # @return [String, nil]
336
343
  optional :user_id, String, nil?: true
337
344
 
338
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
345
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
339
346
  # The aggregated completions usage details of the specific time bucket.
340
347
  #
341
348
  # @param input_tokens [Integer]
@@ -372,6 +379,10 @@ module OpenAI
372
379
  # The aggregated number of input tokens written to the cache with a 12-hour
373
380
  # retention period.
374
381
  #
382
+ # @param input_cache_write_30m_tokens [Integer, nil]
383
+ # The aggregated number of input tokens written to the cache with a 30-minute
384
+ # retention period. May be absent or null for older responses.
385
+ #
375
386
  # @param input_cache_write_tokens [Integer]
376
387
  # The aggregated number of input tokens written to the cache with a 30-minute
377
388
  # retention period.
@@ -237,6 +237,13 @@ module OpenAI
237
237
  # @return [Integer, nil]
238
238
  optional :input_cache_write_12h_tokens, Integer
239
239
 
240
+ # @!attribute input_cache_write_30m_tokens
241
+ # The aggregated number of input tokens written to the cache with a 30-minute
242
+ # retention period. May be absent or null for older responses.
243
+ #
244
+ # @return [Integer, nil]
245
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
246
+
240
247
  # @!attribute input_cache_write_tokens
241
248
  # The aggregated number of input tokens written to the cache with a 30-minute
242
249
  # retention period.
@@ -335,7 +342,7 @@ module OpenAI
335
342
  # @return [String, nil]
336
343
  optional :user_id, String, nil?: true
337
344
 
338
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
345
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
339
346
  # The aggregated completions usage details of the specific time bucket.
340
347
  #
341
348
  # @param input_tokens [Integer]
@@ -372,6 +379,10 @@ module OpenAI
372
379
  # The aggregated number of input tokens written to the cache with a 12-hour
373
380
  # retention period.
374
381
  #
382
+ # @param input_cache_write_30m_tokens [Integer, nil]
383
+ # The aggregated number of input tokens written to the cache with a 30-minute
384
+ # retention period. May be absent or null for older responses.
385
+ #
375
386
  # @param input_cache_write_tokens [Integer]
376
387
  # The aggregated number of input tokens written to the cache with a 30-minute
377
388
  # retention period.
@@ -233,6 +233,13 @@ module OpenAI
233
233
  # @return [Integer, nil]
234
234
  optional :input_cache_write_12h_tokens, Integer
235
235
 
236
+ # @!attribute input_cache_write_30m_tokens
237
+ # The aggregated number of input tokens written to the cache with a 30-minute
238
+ # retention period. May be absent or null for older responses.
239
+ #
240
+ # @return [Integer, nil]
241
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
242
+
236
243
  # @!attribute input_cache_write_tokens
237
244
  # The aggregated number of input tokens written to the cache with a 30-minute
238
245
  # retention period.
@@ -331,7 +338,7 @@ module OpenAI
331
338
  # @return [String, nil]
332
339
  optional :user_id, String, nil?: true
333
340
 
334
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
341
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
335
342
  # The aggregated completions usage details of the specific time bucket.
336
343
  #
337
344
  # @param input_tokens [Integer]
@@ -368,6 +375,10 @@ module OpenAI
368
375
  # The aggregated number of input tokens written to the cache with a 12-hour
369
376
  # retention period.
370
377
  #
378
+ # @param input_cache_write_30m_tokens [Integer, nil]
379
+ # The aggregated number of input tokens written to the cache with a 30-minute
380
+ # retention period. May be absent or null for older responses.
381
+ #
371
382
  # @param input_cache_write_tokens [Integer]
372
383
  # The aggregated number of input tokens written to the cache with a 30-minute
373
384
  # retention period.
@@ -231,6 +231,13 @@ module OpenAI
231
231
  # @return [Integer, nil]
232
232
  optional :input_cache_write_12h_tokens, Integer
233
233
 
234
+ # @!attribute input_cache_write_30m_tokens
235
+ # The aggregated number of input tokens written to the cache with a 30-minute
236
+ # retention period. May be absent or null for older responses.
237
+ #
238
+ # @return [Integer, nil]
239
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
240
+
234
241
  # @!attribute input_cache_write_tokens
235
242
  # The aggregated number of input tokens written to the cache with a 30-minute
236
243
  # retention period.
@@ -329,7 +336,7 @@ module OpenAI
329
336
  # @return [String, nil]
330
337
  optional :user_id, String, nil?: true
331
338
 
332
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
339
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
333
340
  # The aggregated completions usage details of the specific time bucket.
334
341
  #
335
342
  # @param input_tokens [Integer]
@@ -366,6 +373,10 @@ module OpenAI
366
373
  # The aggregated number of input tokens written to the cache with a 12-hour
367
374
  # retention period.
368
375
  #
376
+ # @param input_cache_write_30m_tokens [Integer, nil]
377
+ # The aggregated number of input tokens written to the cache with a 30-minute
378
+ # retention period. May be absent or null for older responses.
379
+ #
369
380
  # @param input_cache_write_tokens [Integer]
370
381
  # The aggregated number of input tokens written to the cache with a 30-minute
371
382
  # retention period.
@@ -137,6 +137,13 @@ module OpenAI
137
137
  # @return [Integer, nil]
138
138
  optional :input_cache_write_12h_tokens, Integer, nil?: true
139
139
 
140
+ # @!attribute input_cache_write_30m_tokens
141
+ # The aggregated number of input tokens written to the cache with a 30-minute
142
+ # retention period.
143
+ #
144
+ # @return [Integer, nil]
145
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
146
+
140
147
  # @!attribute input_cache_write_tokens
141
148
  # The aggregated number of input tokens written to the cache with a 30-minute
142
149
  # retention period.
@@ -235,7 +242,7 @@ module OpenAI
235
242
  # @return [String, nil]
236
243
  optional :user_id, String, nil?: true
237
244
 
238
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.decisions.result")
245
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.decisions.result")
239
246
  # The aggregated Decisions API usage details of the specific time bucket.
240
247
  #
241
248
  # @param input_tokens [Integer]
@@ -272,6 +279,10 @@ module OpenAI
272
279
  # The aggregated number of input tokens written to the cache with a 12-hour
273
280
  # retention period.
274
281
  #
282
+ # @param input_cache_write_30m_tokens [Integer, nil]
283
+ # The aggregated number of input tokens written to the cache with a 30-minute
284
+ # retention period.
285
+ #
275
286
  # @param input_cache_write_tokens [Integer, nil]
276
287
  # The aggregated number of input tokens written to the cache with a 30-minute
277
288
  # retention period.
@@ -233,6 +233,13 @@ module OpenAI
233
233
  # @return [Integer, nil]
234
234
  optional :input_cache_write_12h_tokens, Integer
235
235
 
236
+ # @!attribute input_cache_write_30m_tokens
237
+ # The aggregated number of input tokens written to the cache with a 30-minute
238
+ # retention period. May be absent or null for older responses.
239
+ #
240
+ # @return [Integer, nil]
241
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
242
+
236
243
  # @!attribute input_cache_write_tokens
237
244
  # The aggregated number of input tokens written to the cache with a 30-minute
238
245
  # retention period.
@@ -331,7 +338,7 @@ module OpenAI
331
338
  # @return [String, nil]
332
339
  optional :user_id, String, nil?: true
333
340
 
334
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
341
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
335
342
  # The aggregated completions usage details of the specific time bucket.
336
343
  #
337
344
  # @param input_tokens [Integer]
@@ -368,6 +375,10 @@ module OpenAI
368
375
  # The aggregated number of input tokens written to the cache with a 12-hour
369
376
  # retention period.
370
377
  #
378
+ # @param input_cache_write_30m_tokens [Integer, nil]
379
+ # The aggregated number of input tokens written to the cache with a 30-minute
380
+ # retention period. May be absent or null for older responses.
381
+ #
371
382
  # @param input_cache_write_tokens [Integer]
372
383
  # The aggregated number of input tokens written to the cache with a 30-minute
373
384
  # retention period.
@@ -235,6 +235,13 @@ module OpenAI
235
235
  # @return [Integer, nil]
236
236
  optional :input_cache_write_12h_tokens, Integer
237
237
 
238
+ # @!attribute input_cache_write_30m_tokens
239
+ # The aggregated number of input tokens written to the cache with a 30-minute
240
+ # retention period. May be absent or null for older responses.
241
+ #
242
+ # @return [Integer, nil]
243
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
244
+
238
245
  # @!attribute input_cache_write_tokens
239
246
  # The aggregated number of input tokens written to the cache with a 30-minute
240
247
  # retention period.
@@ -333,7 +340,7 @@ module OpenAI
333
340
  # @return [String, nil]
334
341
  optional :user_id, String, nil?: true
335
342
 
336
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
343
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
337
344
  # The aggregated completions usage details of the specific time bucket.
338
345
  #
339
346
  # @param input_tokens [Integer]
@@ -370,6 +377,10 @@ module OpenAI
370
377
  # The aggregated number of input tokens written to the cache with a 12-hour
371
378
  # retention period.
372
379
  #
380
+ # @param input_cache_write_30m_tokens [Integer, nil]
381
+ # The aggregated number of input tokens written to the cache with a 30-minute
382
+ # retention period. May be absent or null for older responses.
383
+ #
373
384
  # @param input_cache_write_tokens [Integer]
374
385
  # The aggregated number of input tokens written to the cache with a 30-minute
375
386
  # retention period.
@@ -231,6 +231,13 @@ module OpenAI
231
231
  # @return [Integer, nil]
232
232
  optional :input_cache_write_12h_tokens, Integer
233
233
 
234
+ # @!attribute input_cache_write_30m_tokens
235
+ # The aggregated number of input tokens written to the cache with a 30-minute
236
+ # retention period. May be absent or null for older responses.
237
+ #
238
+ # @return [Integer, nil]
239
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
240
+
234
241
  # @!attribute input_cache_write_tokens
235
242
  # The aggregated number of input tokens written to the cache with a 30-minute
236
243
  # retention period.
@@ -329,7 +336,7 @@ module OpenAI
329
336
  # @return [String, nil]
330
337
  optional :user_id, String, nil?: true
331
338
 
332
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
339
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
333
340
  # The aggregated completions usage details of the specific time bucket.
334
341
  #
335
342
  # @param input_tokens [Integer]
@@ -366,6 +373,10 @@ module OpenAI
366
373
  # The aggregated number of input tokens written to the cache with a 12-hour
367
374
  # retention period.
368
375
  #
376
+ # @param input_cache_write_30m_tokens [Integer, nil]
377
+ # The aggregated number of input tokens written to the cache with a 30-minute
378
+ # retention period. May be absent or null for older responses.
379
+ #
369
380
  # @param input_cache_write_tokens [Integer]
370
381
  # The aggregated number of input tokens written to the cache with a 30-minute
371
382
  # retention period.
@@ -233,6 +233,13 @@ module OpenAI
233
233
  # @return [Integer, nil]
234
234
  optional :input_cache_write_12h_tokens, Integer
235
235
 
236
+ # @!attribute input_cache_write_30m_tokens
237
+ # The aggregated number of input tokens written to the cache with a 30-minute
238
+ # retention period. May be absent or null for older responses.
239
+ #
240
+ # @return [Integer, nil]
241
+ optional :input_cache_write_30m_tokens, Integer, nil?: true
242
+
236
243
  # @!attribute input_cache_write_tokens
237
244
  # The aggregated number of input tokens written to the cache with a 30-minute
238
245
  # retention period.
@@ -331,7 +338,7 @@ module OpenAI
331
338
  # @return [String, nil]
332
339
  optional :user_id, String, nil?: true
333
340
 
334
- # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
341
+ # @!method initialize(input_tokens:, num_model_requests:, output_tokens:, api_key_id: nil, api_source: nil, batch: nil, input_audio_tokens: nil, input_cache_write_12h_tokens: nil, input_cache_write_30m_tokens: nil, input_cache_write_tokens: nil, input_cached_audio_tokens: nil, input_cached_image_tokens: nil, input_cached_text_tokens: nil, input_cached_tokens: nil, input_image_tokens: nil, input_text_tokens: nil, input_uncached_tokens: nil, model: nil, output_audio_tokens: nil, output_image_tokens: nil, output_text_tokens: nil, project_id: nil, service_tier: nil, user_id: nil, object: :"organization.usage.completions.result")
335
342
  # The aggregated completions usage details of the specific time bucket.
336
343
  #
337
344
  # @param input_tokens [Integer]
@@ -368,6 +375,10 @@ module OpenAI
368
375
  # The aggregated number of input tokens written to the cache with a 12-hour
369
376
  # retention period.
370
377
  #
378
+ # @param input_cache_write_30m_tokens [Integer, nil]
379
+ # The aggregated number of input tokens written to the cache with a 30-minute
380
+ # retention period. May be absent or null for older responses.
381
+ #
371
382
  # @param input_cache_write_tokens [Integer]
372
383
  # The aggregated number of input tokens written to the cache with a 30-minute
373
384
  # retention period.