View Source OpenAi.Usage (OpenAI REST API Client v1.0.0)

Provides API endpoints related to usage

Summary

Functions

Get audio speeches usage details for the organization.

Get audio transcriptions usage details for the organization.

Get code interpreter sessions usage details for the organization.

Get completions usage details for the organization.

Get costs details for the organization.

Get embeddings usage details for the organization.

Get images usage details for the organization.

Get moderations usage details for the organization.

Get vector stores usage details for the organization.

Functions

Link to this function

usage_audio_speeches(opts \\ [])

View Source
@spec usage_audio_speeches(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get audio speeches usage details for the organization.

Options

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

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

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

  • project_ids: Return only usage for these projects.

  • user_ids: Return only usage for these users.

  • api_key_ids: Return only usage for these API keys.

  • models: Return only usage for these models.

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

  • limit: 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
  • page: A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Link to this function

usage_audio_transcriptions(opts \\ [])

View Source
@spec usage_audio_transcriptions(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get audio transcriptions usage details for the organization.

Options

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

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

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

  • project_ids: Return only usage for these projects.

  • user_ids: Return only usage for these users.

  • api_key_ids: Return only usage for these API keys.

  • models: Return only usage for these models.

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

  • limit: 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
  • page: A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Link to this function

usage_code_interpreter_sessions(opts \\ [])

View Source
@spec usage_code_interpreter_sessions(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get code interpreter sessions usage details for the organization.

Options

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

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

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

  • project_ids: Return only usage for these projects.

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

  • limit: 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
  • page: A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Link to this function

usage_completions(opts \\ [])

View Source
@spec usage_completions(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get completions usage details for the organization.

Options

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

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

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

  • project_ids: Return only usage for these projects.

  • user_ids: Return only usage for these users.

  • api_key_ids: Return only usage for these API keys.

  • models: Return only usage for these models.

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

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

  • limit: 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
  • page: A cursor for use in pagination. Corresponding to the next_page field from the previous response.

@spec usage_costs(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get costs details for the organization.

Options

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

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

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

  • project_ids: Return only costs for these projects.

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

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

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

Link to this function

usage_embeddings(opts \\ [])

View Source
@spec usage_embeddings(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get embeddings usage details for the organization.

Options

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

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

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

  • project_ids: Return only usage for these projects.

  • user_ids: Return only usage for these users.

  • api_key_ids: Return only usage for these API keys.

  • models: Return only usage for these models.

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

  • limit: 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
  • page: A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Link to this function

usage_images(opts \\ [])

View Source
@spec usage_images(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get images usage details for the organization.

Options

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

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

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

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

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

  • project_ids: Return only usage for these projects.

  • user_ids: Return only usage for these users.

  • api_key_ids: Return only usage for these API keys.

  • models: Return only usage for these models.

  • group_by: 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.

  • limit: 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
  • page: A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Link to this function

usage_moderations(opts \\ [])

View Source
@spec usage_moderations(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get moderations usage details for the organization.

Options

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

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

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

  • project_ids: Return only usage for these projects.

  • user_ids: Return only usage for these users.

  • api_key_ids: Return only usage for these API keys.

  • models: Return only usage for these models.

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

  • limit: 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
  • page: A cursor for use in pagination. Corresponding to the next_page field from the previous response.

Link to this function

usage_vector_stores(opts \\ [])

View Source
@spec usage_vector_stores(opts :: keyword()) ::
  {:ok, OpenAi.Usage.Response.t()} | {:error, OpenAi.Error.error()}

Get vector stores usage details for the organization.

Options

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

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

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

  • project_ids: Return only usage for these projects.

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

  • limit: 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
  • page: A cursor for use in pagination. Corresponding to the next_page field from the previous response.