Class: OpenAI::Resources::Admin::Organization::Usage

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/admin/organization/usage.rb,
sig/openai/resources/admin/organization/usage.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Usage

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Usage.

Parameters:

API:

  • private



656
657
658
# File 'lib/openai/resources/admin/organization/usage.rb', line 656

def initialize(client:)
  @client = client
end

Instance Method Details

#audio_speeches(start_time:, api_key_ids: nil, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, models: nil, page: nil, project_ids: nil, user_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageAudioSpeechesResponse

Get audio speeches usage details for the organization.

Parameters:

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

  • Return only usage for these API keys.

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

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

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • Return only usage for these models.

  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

  • Return only usage for these users.

Returns:

See Also:



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/openai/resources/admin/organization/usage.rb', line 54

def audio_speeches(params)
  parsed, options = OpenAI::Admin::Organization::UsageAudioSpeechesParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/audio_speeches",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageAudioSpeechesResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#audio_transcriptions(start_time:, api_key_ids: nil, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, models: nil, page: nil, project_ids: nil, user_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageAudioTranscriptionsResponse

Get audio transcriptions usage details for the organization.

Parameters:

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

  • Return only usage for these API keys.

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

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

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • Return only usage for these models.

  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

  • Return only usage for these users.

Returns:

See Also:



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/openai/resources/admin/organization/usage.rb', line 113

def audio_transcriptions(params)
  parsed, options = OpenAI::Admin::Organization::UsageAudioTranscriptionsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/audio_transcriptions",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageAudioTranscriptionsResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#code_interpreter_sessions(start_time:, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, page: nil, project_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageCodeInterpreterSessionsResponse

Get code interpreter sessions usage details for the organization.

Parameters:

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

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

  • Group the usage data by the specified fields. Support fields include project_id.

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

Returns:

See Also:



163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/openai/resources/admin/organization/usage.rb', line 163

def code_interpreter_sessions(params)
  parsed, options = OpenAI::Admin::Organization::UsageCodeInterpreterSessionsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/code_interpreter_sessions",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageCodeInterpreterSessionsResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#completions(start_time:, api_key_ids: nil, batch: nil, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, models: nil, page: nil, project_ids: nil, user_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageCompletionsResponse

Get completions usage details for the organization.

Parameters:

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

  • Return only usage for these API keys.

  • If true, return batch jobs only. If false, return non-batch jobs only. By default, return both.

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

  • Group the usage data by the specified fields. Support fields include project_id, user_id, api_key_id, model, batch, service_tier or any combination of them.

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • Return only usage for these models.

  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

  • Return only usage for these users.

Returns:

See Also:



227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/openai/resources/admin/organization/usage.rb', line 227

def completions(params)
  parsed, options = OpenAI::Admin::Organization::UsageCompletionsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/completions",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageCompletionsResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#costs(start_time:, api_key_ids: nil, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, line_items: nil, page: nil, project_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageCostsResponse

Get costs details for the organization.

Parameters:

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

  • Return only costs for these API keys.

  • Width of each time bucket in response. Currently only 1d is supported, default to 1d.

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

  • Group the costs by the specified fields. Support fields include project_id, line_item, api_key_id and any combination of them.

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

  • Return only costs for these exact line item names. Each value must match the complete line_item value, for example gpt-6-astra, input_tokens.

  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only costs for these projects.

Returns:

See Also:



281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/openai/resources/admin/organization/usage.rb', line 281

def costs(params)
  parsed, options = OpenAI::Admin::Organization::UsageCostsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/costs",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageCostsResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#embeddings(start_time:, api_key_ids: nil, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, models: nil, page: nil, project_ids: nil, user_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageEmbeddingsResponse

Get embeddings usage details for the organization.

Parameters:

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

  • Return only usage for these API keys.

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

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

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • Return only usage for these models.

  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

  • Return only usage for these users.

Returns:

See Also:



340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/openai/resources/admin/organization/usage.rb', line 340

def embeddings(params)
  parsed, options = OpenAI::Admin::Organization::UsageEmbeddingsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/embeddings",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageEmbeddingsResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#file_search_calls(start_time:, api_key_ids: nil, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, page: nil, project_ids: nil, user_ids: nil, vector_store_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageFileSearchCallsResponse

Get file search calls usage details for the organization.

Parameters:

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

  • Return only usage for these API keys.

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

  • Group the usage data by the specified fields. Support fields include project_id, user_id, api_key_id, vector_store_id or any combination of them.

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

  • Return only usage for these users.

  • Return only usage for these vector stores.

Returns:

See Also:



400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/openai/resources/admin/organization/usage.rb', line 400

def file_search_calls(params)
  parsed, options = OpenAI::Admin::Organization::UsageFileSearchCallsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/file_search_calls",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageFileSearchCallsResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#images(start_time:, api_key_ids: nil, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, models: nil, page: nil, project_ids: nil, sizes: nil, sources: nil, user_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageImagesResponse

Get images usage details for the organization.

Parameters:

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

  • Return only usage for these API keys.

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

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

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • Return only usage for these models.

  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

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

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

  • Return only usage for these users.

Returns:

See Also:



468
469
470
471
472
473
474
475
476
477
478
479
# File 'lib/openai/resources/admin/organization/usage.rb', line 468

def images(params)
  parsed, options = OpenAI::Admin::Organization::UsageImagesParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/images",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageImagesResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#moderations(start_time:, api_key_ids: nil, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, models: nil, page: nil, project_ids: nil, user_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageModerationsResponse

Get moderations usage details for the organization.

Parameters:

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

  • Return only usage for these API keys.

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

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

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • Return only usage for these models.

  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

  • Return only usage for these users.

Returns:

See Also:



527
528
529
530
531
532
533
534
535
536
537
538
# File 'lib/openai/resources/admin/organization/usage.rb', line 527

def moderations(params)
  parsed, options = OpenAI::Admin::Organization::UsageModerationsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/moderations",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageModerationsResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#vector_stores(start_time:, bucket_width: nil, end_time: nil, group_by: nil, limit: nil, page: nil, project_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageVectorStoresResponse

Get vector stores usage details for the organization.

Parameters:

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

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

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

  • Group the usage data by the specified fields. Support fields include project_id.

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

Returns:

See Also:



577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/openai/resources/admin/organization/usage.rb', line 577

def vector_stores(params)
  parsed, options = OpenAI::Admin::Organization::UsageVectorStoresParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/vector_stores",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageVectorStoresResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end

#web_search_calls(start_time:, api_key_ids: nil, bucket_width: nil, context_levels: nil, end_time: nil, group_by: nil, limit: nil, models: nil, page: nil, project_ids: nil, user_ids: nil, request_options: {}) ⇒ OpenAI::Models::Admin::Organization::UsageWebSearchCallsResponse

Get web search calls usage details for the organization.

Parameters:

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

  • Return only usage for these API keys.

  • Width of each time bucket in response. Currently 1m, 1h and 1d are supported, default to 1d.

  • Return only web search usage for these context levels.

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

  • Group the usage data by the specified fields. Support fields include project_id, user_id, api_key_id, model, context_level or any combination of them.

  • Specifies the number of buckets to return.

    • bucket_width=1d: default: 7, max: 31
    • bucket_width=1h: default: 24, max: 168
    • bucket_width=1m: default: 60, max: 1440
  • Return only usage for these models.

  • A cursor for use in pagination. Corresponding to the next_page field from the previous response.

  • Return only usage for these projects.

  • Return only usage for these users.

Returns:

See Also:



640
641
642
643
644
645
646
647
648
649
650
651
# File 'lib/openai/resources/admin/organization/usage.rb', line 640

def web_search_calls(params)
  parsed, options = OpenAI::Admin::Organization::UsageWebSearchCallsParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "organization/usage/web_search_calls",
    query: query,
    model: OpenAI::Models::Admin::Organization::UsageWebSearchCallsResponse,
    security: {admin_api_key_auth: true},
    options: options
  )
end