Class: OpenApiOpenAIClient::UsageApi

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_openai/api/usage_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ UsageApi

Returns a new instance of UsageApi.



19
20
21
# File 'lib/openapi_openai/api/usage_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/openapi_openai/api/usage_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#usage_audio_speeches(start_time, opts = {}) ⇒ UsageResponse

Get audio speeches usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently `1m`, `1h` and `1d` are supported, default to `1d`. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



35
36
37
38
# File 'lib/openapi_openai/api/usage_api.rb', line 35

def usage_audio_speeches(start_time, opts = {})
  data, _status_code, _headers = usage_audio_speeches_with_http_info(start_time, opts)
  data
end

#usage_audio_speeches_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get audio speeches usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/openapi_openai/api/usage_api.rb', line 53

def usage_audio_speeches_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_audio_speeches ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_audio_speeches"
  end
  allowable_values = ["1m", "1h", "1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["project_id", "user_id", "api_key_id", "model"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/usage/audio_speeches'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'user_ids'] = @api_client.build_collection_param(opts[:'user_ids'], :multi) if !opts[:'user_ids'].nil?
  query_params[:'api_key_ids'] = @api_client.build_collection_param(opts[:'api_key_ids'], :multi) if !opts[:'api_key_ids'].nil?
  query_params[:'models'] = @api_client.build_collection_param(opts[:'models'], :multi) if !opts[:'models'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_audio_speeches",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_audio_speeches\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#usage_audio_transcriptions(start_time, opts = {}) ⇒ UsageResponse

Get audio transcriptions usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



132
133
134
135
# File 'lib/openapi_openai/api/usage_api.rb', line 132

def usage_audio_transcriptions(start_time, opts = {})
  data, _status_code, _headers = usage_audio_transcriptions_with_http_info(start_time, opts)
  data
end

#usage_audio_transcriptions_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get audio transcriptions usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/openapi_openai/api/usage_api.rb', line 150

def usage_audio_transcriptions_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_audio_transcriptions ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_audio_transcriptions"
  end
  allowable_values = ["1m", "1h", "1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["project_id", "user_id", "api_key_id", "model"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/usage/audio_transcriptions'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'user_ids'] = @api_client.build_collection_param(opts[:'user_ids'], :multi) if !opts[:'user_ids'].nil?
  query_params[:'api_key_ids'] = @api_client.build_collection_param(opts[:'api_key_ids'], :multi) if !opts[:'api_key_ids'].nil?
  query_params[:'models'] = @api_client.build_collection_param(opts[:'models'], :multi) if !opts[:'models'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_audio_transcriptions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_audio_transcriptions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#usage_code_interpreter_sessions(start_time, opts = {}) ⇒ UsageResponse

Get code interpreter sessions usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



226
227
228
229
# File 'lib/openapi_openai/api/usage_api.rb', line 226

def usage_code_interpreter_sessions(start_time, opts = {})
  data, _status_code, _headers = usage_code_interpreter_sessions_with_http_info(start_time, opts)
  data
end

#usage_code_interpreter_sessions_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get code interpreter sessions usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/openapi_openai/api/usage_api.rb', line 241

def usage_code_interpreter_sessions_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_code_interpreter_sessions ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_code_interpreter_sessions"
  end
  allowable_values = ["1m", "1h", "1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["project_id"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/usage/code_interpreter_sessions'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_code_interpreter_sessions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_code_interpreter_sessions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#usage_completions(start_time, opts = {}) ⇒ UsageResponse

Get completions usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :batch (Boolean)

    If &#x60;true&#x60;, return batch jobs only. If &#x60;false&#x60;, return non-batch jobs only. By default, return both.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60;, &#x60;batch&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



318
319
320
321
# File 'lib/openapi_openai/api/usage_api.rb', line 318

def usage_completions(start_time, opts = {})
  data, _status_code, _headers = usage_completions_with_http_info(start_time, opts)
  data
end

#usage_completions_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get completions usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :batch (Boolean)

    If &#x60;true&#x60;, return batch jobs only. If &#x60;false&#x60;, return non-batch jobs only. By default, return both.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60;, &#x60;batch&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/openapi_openai/api/usage_api.rb', line 337

def usage_completions_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_completions ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_completions"
  end
  allowable_values = ["1m", "1h", "1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["project_id", "user_id", "api_key_id", "model", "batch"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/usage/completions'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'user_ids'] = @api_client.build_collection_param(opts[:'user_ids'], :multi) if !opts[:'user_ids'].nil?
  query_params[:'api_key_ids'] = @api_client.build_collection_param(opts[:'api_key_ids'], :multi) if !opts[:'api_key_ids'].nil?
  query_params[:'models'] = @api_client.build_collection_param(opts[:'models'], :multi) if !opts[:'models'].nil?
  query_params[:'batch'] = opts[:'batch'] if !opts[:'batch'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_completions",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_completions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#usage_costs(start_time, opts = {}) ⇒ UsageResponse

Get costs details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently only &#x60;1d&#x60; is supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only costs for these projects.

  • :group_by (Array<String>)

    Group the costs by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;line_item&#x60; and any combination of them.

  • :limit (Integer)

    A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7. (default to 7)

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



414
415
416
417
# File 'lib/openapi_openai/api/usage_api.rb', line 414

def usage_costs(start_time, opts = {})
  data, _status_code, _headers = usage_costs_with_http_info(start_time, opts)
  data
end

#usage_costs_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get costs details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently only &#x60;1d&#x60; is supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only costs for these projects.

  • :group_by (Array<String>)

    Group the costs by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;line_item&#x60; and any combination of them.

  • :limit (Integer)

    A limit on the number of buckets to be returned. Limit can range between 1 and 180, and the default is 7. (default to 7)

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
# File 'lib/openapi_openai/api/usage_api.rb', line 429

def usage_costs_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_costs ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_costs"
  end
  allowable_values = ["1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["project_id", "line_item"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/costs'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_costs",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_costs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#usage_embeddings(start_time, opts = {}) ⇒ UsageResponse

Get embeddings usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



505
506
507
508
# File 'lib/openapi_openai/api/usage_api.rb', line 505

def usage_embeddings(start_time, opts = {})
  data, _status_code, _headers = usage_embeddings_with_http_info(start_time, opts)
  data
end

#usage_embeddings_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get embeddings usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
# File 'lib/openapi_openai/api/usage_api.rb', line 523

def usage_embeddings_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_embeddings ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_embeddings"
  end
  allowable_values = ["1m", "1h", "1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["project_id", "user_id", "api_key_id", "model"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/usage/embeddings'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'user_ids'] = @api_client.build_collection_param(opts[:'user_ids'], :multi) if !opts[:'user_ids'].nil?
  query_params[:'api_key_ids'] = @api_client.build_collection_param(opts[:'api_key_ids'], :multi) if !opts[:'api_key_ids'].nil?
  query_params[:'models'] = @api_client.build_collection_param(opts[:'models'], :multi) if !opts[:'models'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_embeddings",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_embeddings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#usage_images(start_time, opts = {}) ⇒ UsageResponse

Get images usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :sources (Array<String>)

    Return only usages for these sources. Possible values are &#x60;image.generation&#x60;, &#x60;image.edit&#x60;, &#x60;image.variation&#x60; or any combination of them.

  • :sizes (Array<String>)

    Return only usages for these image sizes. Possible values are &#x60;256x256&#x60;, &#x60;512x512&#x60;, &#x60;1024x1024&#x60;, &#x60;1792x1792&#x60;, &#x60;1024x1792&#x60; or any combination of them.

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60;, &#x60;size&#x60;, &#x60;source&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



604
605
606
607
# File 'lib/openapi_openai/api/usage_api.rb', line 604

def usage_images(start_time, opts = {})
  data, _status_code, _headers = usage_images_with_http_info(start_time, opts)
  data
end

#usage_images_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get images usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :sources (Array<String>)

    Return only usages for these sources. Possible values are &#x60;image.generation&#x60;, &#x60;image.edit&#x60;, &#x60;image.variation&#x60; or any combination of them.

  • :sizes (Array<String>)

    Return only usages for these image sizes. Possible values are &#x60;256x256&#x60;, &#x60;512x512&#x60;, &#x60;1024x1024&#x60;, &#x60;1792x1792&#x60;, &#x60;1024x1792&#x60; or any combination of them.

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60;, &#x60;size&#x60;, &#x60;source&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
# File 'lib/openapi_openai/api/usage_api.rb', line 624

def usage_images_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_images ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_images"
  end
  allowable_values = ["1m", "1h", "1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["image.generation", "image.edit", "image.variation"]
  if @api_client.config.client_side_validation && opts[:'sources'] && !opts[:'sources'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"sources\", must include one of #{allowable_values}"
  end
  allowable_values = ["256x256", "512x512", "1024x1024", "1792x1792", "1024x1792"]
  if @api_client.config.client_side_validation && opts[:'sizes'] && !opts[:'sizes'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"sizes\", must include one of #{allowable_values}"
  end
  allowable_values = ["project_id", "user_id", "api_key_id", "model", "size", "source"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/usage/images'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'sources'] = @api_client.build_collection_param(opts[:'sources'], :multi) if !opts[:'sources'].nil?
  query_params[:'sizes'] = @api_client.build_collection_param(opts[:'sizes'], :multi) if !opts[:'sizes'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'user_ids'] = @api_client.build_collection_param(opts[:'user_ids'], :multi) if !opts[:'user_ids'].nil?
  query_params[:'api_key_ids'] = @api_client.build_collection_param(opts[:'api_key_ids'], :multi) if !opts[:'api_key_ids'].nil?
  query_params[:'models'] = @api_client.build_collection_param(opts[:'models'], :multi) if !opts[:'models'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_images",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_images\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#usage_moderations(start_time, opts = {}) ⇒ UsageResponse

Get moderations usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



713
714
715
716
# File 'lib/openapi_openai/api/usage_api.rb', line 713

def usage_moderations(start_time, opts = {})
  data, _status_code, _headers = usage_moderations_with_http_info(start_time, opts)
  data
end

#usage_moderations_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get moderations usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :user_ids (Array<String>)

    Return only usage for these users.

  • :api_key_ids (Array<String>)

    Return only usage for these API keys.

  • :models (Array<String>)

    Return only usage for these models.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;, &#x60;user_id&#x60;, &#x60;api_key_id&#x60;, &#x60;model&#x60; or any combination of them.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
# File 'lib/openapi_openai/api/usage_api.rb', line 731

def usage_moderations_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_moderations ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_moderations"
  end
  allowable_values = ["1m", "1h", "1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["project_id", "user_id", "api_key_id", "model"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/usage/moderations'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'user_ids'] = @api_client.build_collection_param(opts[:'user_ids'], :multi) if !opts[:'user_ids'].nil?
  query_params[:'api_key_ids'] = @api_client.build_collection_param(opts[:'api_key_ids'], :multi) if !opts[:'api_key_ids'].nil?
  query_params[:'models'] = @api_client.build_collection_param(opts[:'models'], :multi) if !opts[:'models'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_moderations",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_moderations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#usage_vector_stores(start_time, opts = {}) ⇒ UsageResponse

Get vector stores usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:



807
808
809
810
# File 'lib/openapi_openai/api/usage_api.rb', line 807

def usage_vector_stores(start_time, opts = {})
  data, _status_code, _headers = usage_vector_stores_with_http_info(start_time, opts)
  data
end

#usage_vector_stores_with_http_info(start_time, opts = {}) ⇒ Array<(UsageResponse, Integer, Hash)>

Get vector stores usage details for the organization.

Parameters:

  • start_time (Integer)

    Start time (Unix seconds) of the query time range, inclusive.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :end_time (Integer)

    End time (Unix seconds) of the query time range, exclusive.

  • :bucket_width (String)

    Width of each time bucket in response. Currently &#x60;1m&#x60;, &#x60;1h&#x60; and &#x60;1d&#x60; are supported, default to &#x60;1d&#x60;. (default to ‘1d’)

  • :project_ids (Array<String>)

    Return only usage for these projects.

  • :group_by (Array<String>)

    Group the usage data by the specified fields. Support fields include &#x60;project_id&#x60;.

  • :limit (Integer)

    Specifies the number of buckets to return. - &#x60;bucket_width&#x3D;1d&#x60;: default: 7, max: 31 - &#x60;bucket_width&#x3D;1h&#x60;: default: 24, max: 168 - &#x60;bucket_width&#x3D;1m&#x60;: default: 60, max: 1440

  • :page (String)

    A cursor for use in pagination. Corresponding to the &#x60;next_page&#x60; field from the previous response.

Returns:

  • (Array<(UsageResponse, Integer, Hash)>)

    UsageResponse data, response status code and response headers



822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
# File 'lib/openapi_openai/api/usage_api.rb', line 822

def usage_vector_stores_with_http_info(start_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageApi.usage_vector_stores ...'
  end
  # verify the required parameter 'start_time' is set
  if @api_client.config.client_side_validation && start_time.nil?
    fail ArgumentError, "Missing the required parameter 'start_time' when calling UsageApi.usage_vector_stores"
  end
  allowable_values = ["1m", "1h", "1d"]
  if @api_client.config.client_side_validation && opts[:'bucket_width'] && !allowable_values.include?(opts[:'bucket_width'])
    fail ArgumentError, "invalid value for \"bucket_width\", must be one of #{allowable_values}"
  end
  allowable_values = ["project_id"]
  if @api_client.config.client_side_validation && opts[:'group_by'] && !opts[:'group_by'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"group_by\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/organization/usage/vector_stores'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_time'] = start_time
  query_params[:'end_time'] = opts[:'end_time'] if !opts[:'end_time'].nil?
  query_params[:'bucket_width'] = opts[:'bucket_width'] if !opts[:'bucket_width'].nil?
  query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil?
  query_params[:'group_by'] = @api_client.build_collection_param(opts[:'group_by'], :multi) if !opts[:'group_by'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'UsageResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"UsageApi.usage_vector_stores",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: UsageApi#usage_vector_stores\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end