SpyBara
Go Premium

ruby/resources/admin/subresources/organization/index.md 2026-07-07 08:02 UTC to 2026-07-09 20:58 UTC

112 added, 134 removed.

2026
Wed 15 02:58 Tue 14 06:58 Mon 13 15:59 Sun 12 06:58 Fri 10 23:02 Thu 9 20:58 Tue 7 08:02

Organization

Audit Logs

List audit logs

admin.organization.audit_logs.list(**kwargs) -> ConversationCursorPage<AuditLogListResponse>

get /organization/audit_logs

List audit logs

Parameters

  • actor_emails: Array[String]

    Return only events performed by users with these emails.

  • actor_ids: Array[String]

    Return only events performed by these actors. Can be a user ID, a service account ID, or an api key tracking ID.

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before: String

    A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, starting with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

  • effective_at: EffectiveAt{ gt, gte, lt, lte}

    Return only events whose effective_at (Unix seconds) is in this range.

    • gt: Integer

      Return only events whose effective_at (Unix seconds) is greater than this value.

    • gte: Integer

      Return only events whose effective_at (Unix seconds) is greater than or equal to this value.

    • lt: Integer

      Return only events whose effective_at (Unix seconds) is less than this value.

    • lte: Integer

      Return only events whose effective_at (Unix seconds) is less than or equal to this value.

  • event_types: Array[:"api_key.created" | :"api_key.updated" | :"api_key.deleted" | 56 more]

    Return only events with a type in one of these values. For example, project.created. For all options, see the documentation for the audit log object.

    • :"api_key.created"

    • :"api_key.updated"

    • :"api_key.deleted"

    • :"certificate.created"

    • :"certificate.updated"

    • :"certificate.deleted"

    • :"certificates.activated"

    • :"certificates.deactivated"

    • :"checkpoint.permission.created"

    • :"checkpoint.permission.deleted"

    • :"external_key.registered"

    • :"external_key.removed"

    • :"group.created"

    • :"group.updated"

    • :"group.deleted"

    • :"invite.sent"

    • :"invite.accepted"

    • :"invite.deleted"

    • :"ip_allowlist.created"

    • :"ip_allowlist.updated"

    • :"ip_allowlist.deleted"

    • :"ip_allowlist.config.activated"

    • :"ip_allowlist.config.deactivated"

    • :"login.succeeded"

    • :"login.failed"

    • :"logout.succeeded"

    • :"logout.failed"

    • :"organization.updated"

    • :"project.created"

    • :"project.updated"

    • :"project.archived"

    • :"project.deleted"

    • :"rate_limit.updated"

    • :"rate_limit.deleted"

    • :"resource.deleted"

    • :"tunnel.created"

    • :"tunnel.updated"

    • :"tunnel.deleted"

    • :"workload_identity_provider.created"

    • :"workload_identity_provider.updated"

    • :"workload_identity_provider.deleted"

    • :"workload_identity_provider_mapping.created"

    • :"workload_identity_provider_mapping.updated"

    • :"workload_identity_provider_mapping.deleted"

    • :"role.created"

    • :"role.updated"

    • :"role.deleted"

    • :"role.assignment.created"

    • :"role.assignment.deleted"

    • :"role.bound_to_resource"

    • :"role.unbound_from_resource"

    • :"scim.enabled"

    • :"scim.disabled"

    • :"service_account.created"

    • :"service_account.updated"

    • :"service_account.deleted"

    • :"user.added"

    • :"user.updated"

    • :"user.deleted"

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

  • project_ids: Array[String]

    Return only events for these projects.

  • resource_ids: Array[String]

    Return only events performed on these targets. For example, a project ID updated. For ChatGPT connector role events, use the workspace connector resource ID shown in details.id, such as <workspace_id>__<connector_id>.

  • tenant_only: bool

    Return only tenant-scoped events associated with this organization. Required for tenant-scoped events such as role.bound_to_resource and role.unbound_from_resource. When true, all supplied event types must be tenant-scoped.

Returns

  • class AuditLogListResponse

    A log of a user action or configuration change within this organization.

    • id: String

      The ID of this log.

    • effective_at: Integer

      The Unix timestamp (in seconds) of the event.

    • type: :"api_key.created" | :"api_key.updated" | :"api_key.deleted" | 56 more

      The event type.

      • :"api_key.created"

      • :"api_key.updated"

      • :"api_key.deleted"

      • :"certificate.created"

      • :"certificate.updated"

      • :"certificate.deleted"

      • :"certificates.activated"

      • :"certificates.deactivated"

      • :"checkpoint.permission.created"

      • :"checkpoint.permission.deleted"

      • :"external_key.registered"

      • :"external_key.removed"

      • :"group.created"

      • :"group.updated"

      • :"group.deleted"

      • :"invite.sent"

      • :"invite.accepted"

      • :"invite.deleted"

      • :"ip_allowlist.created"

      • :"ip_allowlist.updated"

      • :"ip_allowlist.deleted"

      • :"ip_allowlist.config.activated"

      • :"ip_allowlist.config.deactivated"

      • :"login.succeeded"

      • :"login.failed"

      • :"logout.succeeded"

      • :"logout.failed"

      • :"organization.updated"

      • :"project.created"

      • :"project.updated"

      • :"project.archived"

      • :"project.deleted"

      • :"rate_limit.updated"

      • :"rate_limit.deleted"

      • :"resource.deleted"

      • :"tunnel.created"

      • :"tunnel.updated"

      • :"tunnel.deleted"

      • :"workload_identity_provider.created"

      • :"workload_identity_provider.updated"

      • :"workload_identity_provider.deleted"

      • :"workload_identity_provider_mapping.created"

      • :"workload_identity_provider_mapping.updated"

      • :"workload_identity_provider_mapping.deleted"

      • :"role.created"

      • :"role.updated"

      • :"role.deleted"

      • :"role.assignment.created"

      • :"role.assignment.deleted"

      • :"role.bound_to_resource"

      • :"role.unbound_from_resource"

      • :"scim.enabled"

      • :"scim.disabled"

      • :"service_account.created"

      • :"service_account.updated"

      • :"service_account.deleted"

      • :"user.added"

      • :"user.updated"

      • :"user.deleted"

    • actor: Actor{ api_key, session, type}

      The actor who performed the audit logged action.

      • api_key: APIKey{ id, service_account, type, user}

        The API Key used to perform the audit logged action.

        • id: String

          The tracking id of the API key.

        • service_account: ServiceAccount{ id}

          The service account that performed the audit logged action.

          • id: String

            The service account id.

        • type: :user | :service_account

          The type of API key. Can be either user or service_account.

          • :user

          • :service_account

        • user: User{ id, email}

          The user who performed the audit logged action.

          • id: String

            The user id.

          • email: String

            The user email.

      • session: Session{ ip_address, user}

        The session in which the audit logged action was performed.

        • ip_address: String

          The IP address from which the action was performed.

        • user: User{ id, email}

          The user who performed the audit logged action.

          • id: String

            The user id.

          • email: String

            The user email.

      • type: :session | :api_key

        The type of actor. Is either session or api_key.

        • :session

        • :api_key

    • api_key_created: APIKeyCreated{ id, data}

      The details for events with this type.

      • id: String

        The tracking ID of the API key.

      • data: Data{ scopes}

        The payload used to create the API key.

        • scopes: Array[String]

          A list of scopes allowed for the API key, e.g. ["api.model.request"]

    • api_key_deleted: APIKeyDeleted{ id}

      The details for events with this type.

      • id: String

        The tracking ID of the API key.

    • api_key_updated: APIKeyUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The tracking ID of the API key.

      • changes_requested: ChangesRequested{ scopes}

        The payload used to update the API key.

        • scopes: Array[String]

          A list of scopes allowed for the API key, e.g. ["api.model.request"]

    • certificate_created: CertificateCreated{ id, name}

      The details for events with this type.

      • id: String

        The certificate ID.

      • name: String

        The name of the certificate.

    • certificate_deleted: CertificateDeleted{ id, certificate, name}

      The details for events with this type.

      • id: String

        The certificate ID.

      • certificate: String

        The certificate content in PEM format.

      • name: String

        The name of the certificate.

    • certificate_updated: CertificateUpdated{ id, name}

      The details for events with this type.

      • id: String

        The certificate ID.

      • name: String

        The name of the certificate.

    • certificates_activated: CertificatesActivated{ certificates}

      The details for events with this type.

      • certificates: Array[Certificate{ id, name}]

        • id: String

          The certificate ID.

        • name: String

          The name of the certificate.

    • certificates_deactivated: CertificatesDeactivated{ certificates}

      The details for events with this type.

      • certificates: Array[Certificate{ id, name}]

        • id: String

          The certificate ID.

        • name: String

          The name of the certificate.

    • checkpoint_permission_created: CheckpointPermissionCreated{ id, data}

      The project and fine-tuned model checkpoint that the checkpoint permission was created for.

      • id: String

        The ID of the checkpoint permission.

      • data: Data{ fine_tuned_model_checkpoint, project_id}

        The payload used to create the checkpoint permission.

        • fine_tuned_model_checkpoint: String

          The ID of the fine-tuned model checkpoint.

        • project_id: String

          The ID of the project that the checkpoint permission was created for.

    • checkpoint_permission_deleted: CheckpointPermissionDeleted{ id}

      The details for events with this type.

      • id: String

        The ID of the checkpoint permission.

    • external_key_registered: ExternalKeyRegistered{ id, data}

      The details for events with this type.

      • id: String

        The ID of the external key configuration.

      • data: untyped

        The configuration for the external key.

    • external_key_removed: ExternalKeyRemoved{ id}

      The details for events with this type.

      • id: String

        The ID of the external key configuration.

    • group_created: GroupCreated{ id, data}

      The details for events with this type.

      • id: String

        The ID of the group.

      • data: Data{ group_name}

        Information about the created group.

        • group_name: String

          The group name.

    • group_deleted: GroupDeleted{ id}

      The details for events with this type.

      • id: String

        The ID of the group.

    • group_updated: GroupUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The ID of the group.

      • changes_requested: ChangesRequested{ group_name}

        The payload used to update the group.

        • group_name: String

          The updated group name.

    • invite_accepted: InviteAccepted{ id}

      The details for events with this type.

      • id: String

        The ID of the invite.

    • invite_deleted: InviteDeleted{ id}

      The details for events with this type.

      • id: String

        The ID of the invite.

    • invite_sent: InviteSent{ id, data}

      The details for events with this type.

      • id: String

        The ID of the invite.

      • data: Data{ email, role}

        The payload used to create the invite.

        • email: String

          The email invited to the organization.

        • role: String

          The role the email was invited to be. Is either owner or member.

    • ip_allowlist_config_activated: IPAllowlistConfigActivated{ configs}

      The details for events with this type.

      • configs: Array[Config{ id, name}]

        The configurations that were activated.

        • id: String

          The ID of the IP allowlist configuration.

        • name: String

          The name of the IP allowlist configuration.

    • ip_allowlist_config_deactivated: IPAllowlistConfigDeactivated{ configs}

      The details for events with this type.

      • configs: Array[Config{ id, name}]

        The configurations that were deactivated.

        • id: String

          The ID of the IP allowlist configuration.

        • name: String

          The name of the IP allowlist configuration.

    • ip_allowlist_created: IPAllowlistCreated{ id, allowed_ips, name}

      The details for events with this type.

      • id: String

        The ID of the IP allowlist configuration.

      • allowed_ips: Array[String]

        The IP addresses or CIDR ranges included in the configuration.

      • name: String

        The name of the IP allowlist configuration.

    • ip_allowlist_deleted: IPAllowlistDeleted{ id, allowed_ips, name}

      The details for events with this type.

      • id: String

        The ID of the IP allowlist configuration.

      • allowed_ips: Array[String]

        The IP addresses or CIDR ranges that were in the configuration.

      • name: String

        The name of the IP allowlist configuration.

    • ip_allowlist_updated: IPAllowlistUpdated{ id, allowed_ips}

      The details for events with this type.

      • id: String

        The ID of the IP allowlist configuration.

      • allowed_ips: Array[String]

        The updated set of IP addresses or CIDR ranges in the configuration.

    • login_failed: LoginFailed{ error_code, error_message}

      The details for events with this type.

      • error_code: String

        The error code of the failure.

      • error_message: String

        The error message of the failure.

    • login_succeeded: untyped

      This event has no additional fields beyond the standard audit log attributes.

    • logout_failed: LogoutFailed{ error_code, error_message}

      The details for events with this type.

      • error_code: String

        The error code of the failure.

      • error_message: String

        The error message of the failure.

    • logout_succeeded: untyped

      This event has no additional fields beyond the standard audit log attributes.

    • organization_updated: OrganizationUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The organization ID.

      • changes_requested: ChangesRequested{ api_call_logging, api_call_logging_project_ids, description, 4 more}

        The payload used to update the organization settings.

        • api_call_logging: String

          How your organization logs data from supported API calls. One of disabled, enabled_per_call, enabled_for_all_projects, or enabled_for_selected_projects

        • api_call_logging_project_ids: String

          The list of project ids if api_call_logging is set to enabled_for_selected_projects

        • description: String

          The organization description.

        • name: String

          The organization name.

        • threads_ui_visibility: String

          Visibility of the threads page which shows messages created with the Assistants API and Playground. One of ANY_ROLE, OWNERS, or NONE.

        • title: String

          The organization title.

        • usage_dashboard_visibility: String

          Visibility of the usage dashboard which shows activity and costs for your organization. One of ANY_ROLE or OWNERS.

    • project: Project{ id, name}

      The project that the action was scoped to. Absent for actions not scoped to projects. Note that any admin actions taken via Admin API keys are associated with the default project.

      • id: String

        The project ID.

      • name: String

        The project title.

    • project_archived: ProjectArchived{ id}

      The details for events with this type.

      • id: String

        The project ID.

    • project_created: ProjectCreated{ id, data}

      The details for events with this type.

      • id: String

        The project ID.

      • data: Data{ name, title}

        The payload used to create the project.

        • name: String

          The project name.

        • title: String

          The title of the project as seen on the dashboard.

    • project_deleted: ProjectDeleted{ id}

      The details for events with this type.

      • id: String

        The project ID.

    • project_updated: ProjectUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The project ID.

      • changes_requested: ChangesRequested{ title}

        The payload used to update the project.

        • title: String

          The title of the project as seen on the dashboard.

    • rate_limit_deleted: RateLimitDeleted{ id}

      The details for events with this type.

      • id: String

        The rate limit ID

    • rate_limit_updated: RateLimitUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The rate limit ID

      • changes_requested: ChangesRequested{ batch_1_day_max_input_tokens, max_audio_megabytes_per_1_minute, max_images_per_1_minute, 3 more}

        The payload used to update the rate limits.

        • batch_1_day_max_input_tokens: Integer

          The maximum batch input tokens per day. Only relevant for certain models.

        • max_audio_megabytes_per_1_minute: Integer

          The maximum audio megabytes per minute. Only relevant for certain models.

        • max_images_per_1_minute: Integer

          The maximum images per minute. Only relevant for certain models.

        • max_requests_per_1_day: Integer

          The maximum requests per day. Only relevant for certain models.

        • max_requests_per_1_minute: Integer

          The maximum requests per minute.

        • max_tokens_per_1_minute: Integer

          The maximum tokens per minute.

    • role_assignment_created: RoleAssignmentCreated{ id, principal_id, principal_type, 2 more}

      The details for events with this type.

      • id: String

        The identifier of the role assignment.

      • principal_id: String

        The principal (user or group) that received the role.

      • principal_type: String

        The type of principal (user or group) that received the role.

      • resource_id: String

        The resource the role assignment is scoped to.

      • resource_type: String

        The type of resource the role assignment is scoped to.

    • role_assignment_deleted: RoleAssignmentDeleted{ id, principal_id, principal_type, 2 more}

      The details for events with this type.

      • id: String

        The identifier of the role assignment.

      • principal_id: String

        The principal (user or group) that had the role removed.

      • principal_type: String

        The type of principal (user or group) that had the role removed.

      • resource_id: String

        The resource the role assignment was scoped to.

      • resource_type: String

        The type of resource the role assignment was scoped to.

    • role_bound_to_resource: RoleBoundToResource{ id, connector_id, connector_name, 7 more}

      The details for events with this type.

      • id: String

        The ID of the resource the role was bound to. ChatGPT workspace connector resources use <workspace_id>__<connector_id>.

      • connector_id: String

        The connector ID for a ChatGPT workspace connector resource.

      • connector_name: String

        The connector display name for a ChatGPT workspace connector resource, or the connector ID when the display name could not be resolved.

      • enabled: bool

        Whether the connector is enabled for the role.

      • permissions: Array[String]

        The permissions granted to the role for the resource.

      • resource_id: String

        The ID of the resource the role was bound to.

      • resource_type: String

        The type of resource the role was bound to.

      • role_id: String

        The ID of the role that was bound to the resource.

      • source: :role_toggle | :role_connector_update | :role_delete | 2 more

        The connector role mutation path that produced the event.

        • :role_toggle

        • :role_connector_update

        • :role_delete

        • :workspace_permissions

        • :connector_publish

      • workspace_id: String

        The workspace ID for a ChatGPT workspace connector resource.

    • role_created: RoleCreated{ id, permissions, resource_id, 2 more}

      The details for events with this type.

      • id: String

        The role ID.

      • permissions: Array[String]

        The permissions granted by the role.

      • resource_id: String

        The resource the role is scoped to.

      • resource_type: String

        The type of resource the role belongs to.

      • role_name: String

        The name of the role.

    • role_deleted: RoleDeleted{ id}

      The details for events with this type.

      • id: String

        The role ID.

    • role_unbound_from_resource: RoleUnboundFromResource{ id, connector_id, connector_name, 7 more}

      The details for events with this type.

      • id: String

        The ID of the resource the role was unbound from. ChatGPT workspace connector resources use <workspace_id>__<connector_id>.

      • connector_id: String

        The connector ID for a ChatGPT workspace connector resource.

      • connector_name: String

        The connector display name for a ChatGPT workspace connector resource, or the connector ID when the display name could not be resolved.

      • enabled: bool

        Whether the connector is enabled for the role.

      • permissions: Array[String]

        The permissions remaining for the role after the change.

      • resource_id: String

        The ID of the resource the role was unbound from.

      • resource_type: String

        The type of resource the role was unbound from.

      • role_id: String

        The ID of the role that was unbound from the resource.

      • source: :role_toggle | :role_connector_update | :role_delete | 2 more

        The connector role mutation path that produced the event.

        • :role_toggle

        • :role_connector_update

        • :role_delete

        • :workspace_permissions

        • :connector_publish

      • workspace_id: String

        The workspace ID for a ChatGPT workspace connector resource.

    • role_updated: RoleUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The role ID.

      • changes_requested: ChangesRequested{ description, metadata, permissions_added, 4 more}

        The payload used to update the role.

        • description: String

          The updated role description, when provided.

        • metadata: untyped

          Additional metadata stored on the role.

        • permissions_added: Array[String]

          The permissions added to the role.

        • permissions_removed: Array[String]

          The permissions removed from the role.

        • resource_id: String

          The resource the role is scoped to.

        • resource_type: String

          The type of resource the role belongs to.

        • role_name: String

          The updated role name, when provided.

    • scim_disabled: ScimDisabled{ id}

      The details for events with this type.

      • id: String

        The ID of the SCIM was disabled for.

    • scim_enabled: ScimEnabled{ id}

      The details for events with this type.

      • id: String

        The ID of the SCIM was enabled for.

    • service_account_created: ServiceAccountCreated{ id, data}

      The details for events with this type.

      • id: String

        The service account ID.

      • data: Data{ role}

        The payload used to create the service account.

        • role: String

          The role of the service account. Is either owner or member.

    • service_account_deleted: ServiceAccountDeleted{ id}

      The details for events with this type.

      • id: String

        The service account ID.

    • service_account_updated: ServiceAccountUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The service account ID.

      • changes_requested: ChangesRequested{ role}

        The payload used to updated the service account.

        • role: String

          The role of the service account. Is either owner or member.

    • user_added: UserAdded{ id, data}

      The details for events with this type.

      • id: String

        The user ID.

      • data: Data{ role}

        The payload used to add the user to the project.

        • role: String

          The role of the user. Is either owner or member.

    • user_deleted: UserDeleted{ id}

      The details for events with this type.

      • id: String

        The user ID.

    • user_updated: UserUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The project ID.

      • changes_requested: ChangesRequested{ role}

        The payload used to update the user.

        • role: String

          The role of the user. Is either owner or member.

    • workload_identity_provider_mapping_created: WorkloadIdentityProviderMappingCreated{ id, data, identity_provider_id}

      The details for events with this type.

      • id: String

        The workload identity provider mapping ID.

      • data: untyped

        The payload used to create the workload identity provider mapping.

      • identity_provider_id: String

        The workload identity provider ID.

    • workload_identity_provider_mapping_deleted: WorkloadIdentityProviderMappingDeleted{ id, identity_provider_id, project_id, service_account_id}

      The details for events with this type.

      • id: String

        The workload identity provider mapping ID.

      • identity_provider_id: String

        The workload identity provider ID.

      • project_id: String

        The project ID.

      • service_account_id: String

        The mapped service account ID.

    • workload_identity_provider_mapping_updated: WorkloadIdentityProviderMappingUpdated{ id, changes_requested, identity_provider_id}

      The details for events with this type.

      • id: String

        The workload identity provider mapping ID.

      • changes_requested: untyped

        The payload used to update the workload identity provider mapping.

      • identity_provider_id: String

        The workload identity provider ID.

    • workload_identity_provider_created: WorkloadIdentityProviderCreated{ id, data}

      The details for events with this type.

      • id: String

        The workload identity provider ID.

      • data: untyped

        The payload used to create the workload identity provider.

    • workload_identity_provider_deleted: WorkloadIdentityProviderDeleted{ id, name}

      The details for events with this type.

      • id: String

        The workload identity provider ID.

      • name: String

        The workload identity provider name.

    • workload_identity_provider_updated: WorkloadIdentityProviderUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The workload identity provider ID.

      • changes_requested: untyped

        The payload used to update the workload identity provider.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.audit_logs.list

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "effective_at": 0,
      "type": "api_key.created",
      "actor": {
        "api_key": {
          "id": "id",
          "service_account": {
            "id": "id"
          },
          "type": "user",
          "user": {
            "id": "id",
            "email": "email"
          }
        },
        "session": {
          "ip_address": "ip_address",
          "user": {
            "id": "id",
            "email": "email"
          }
        },
        "type": "session"
      },
      "api_key.created": {
        "id": "id",
        "data": {
          "scopes": [
            "string"
          ]
        }
      },
      "api_key.deleted": {
        "id": "id"
      },
      "api_key.updated": {
        "id": "id",
        "changes_requested": {
          "scopes": [
            "string"
          ]
        }
      },
      "certificate.created": {
        "id": "id",
        "name": "name"
      },
      "certificate.deleted": {
        "id": "id",
        "certificate": "certificate",
        "name": "name"
      },
      "certificate.updated": {
        "id": "id",
        "name": "name"
      },
      "certificates.activated": {
        "certificates": [
          {
            "id": "id",
            "name": "name"
          }
        ]
      },
      "certificates.deactivated": {
        "certificates": [
          {
            "id": "id",
            "name": "name"
          }
        ]
      },
      "checkpoint.permission.created": {
        "id": "id",
        "data": {
          "fine_tuned_model_checkpoint": "fine_tuned_model_checkpoint",
          "project_id": "project_id"
        }
      },
      "checkpoint.permission.deleted": {
        "id": "id"
      },
      "external_key.registered": {
        "id": "id",
        "data": {}
      },
      "external_key.removed": {
        "id": "id"
      },
      "group.created": {
        "id": "id",
        "data": {
          "group_name": "group_name"
        }
      },
      "group.deleted": {
        "id": "id"
      },
      "group.updated": {
        "id": "id",
        "changes_requested": {
          "group_name": "group_name"
        }
      },
      "invite.accepted": {
        "id": "id"
      },
      "invite.deleted": {
        "id": "id"
      },
      "invite.sent": {
        "id": "id",
        "data": {
          "email": "email",
          "role": "role"
        }
      },
      "ip_allowlist.config.activated": {
        "configs": [
          {
            "id": "id",
            "name": "name"
          }
        ]
      },
      "ip_allowlist.config.deactivated": {
        "configs": [
          {
            "id": "id",
            "name": "name"
          }
        ]
      },
      "ip_allowlist.created": {
        "id": "id",
        "allowed_ips": [
          "string"
        ],
        "name": "name"
      },
      "ip_allowlist.deleted": {
        "id": "id",
        "allowed_ips": [
          "string"
        ],
        "name": "name"
      },
      "ip_allowlist.updated": {
        "id": "id",
        "allowed_ips": [
          "string"
        ]
      },
      "login.failed": {
        "error_code": "error_code",
        "error_message": "error_message"
      },
      "login.succeeded": {},
      "logout.failed": {
        "error_code": "error_code",
        "error_message": "error_message"
      },
      "logout.succeeded": {},
      "organization.updated": {
        "id": "id",
        "changes_requested": {
          "api_call_logging": "api_call_logging",
          "api_call_logging_project_ids": "api_call_logging_project_ids",
          "description": "description",
          "name": "name",
          "threads_ui_visibility": "threads_ui_visibility",
          "title": "title",
          "usage_dashboard_visibility": "usage_dashboard_visibility"
        }
      },
      "project": {
        "id": "id",
        "name": "name"
      },
      "project.archived": {
        "id": "id"
      },
      "project.created": {
        "id": "id",
        "data": {
          "name": "name",
          "title": "title"
        }
      },
      "project.deleted": {
        "id": "id"
      },
      "project.updated": {
        "id": "id",
        "changes_requested": {
          "title": "title"
        }
      },
      "rate_limit.deleted": {
        "id": "id"
      },
      "rate_limit.updated": {
        "id": "id",
        "changes_requested": {
          "batch_1_day_max_input_tokens": 0,
          "max_audio_megabytes_per_1_minute": 0,
          "max_images_per_1_minute": 0,
          "max_requests_per_1_day": 0,
          "max_requests_per_1_minute": 0,
          "max_tokens_per_1_minute": 0
        }
      },
      "role.assignment.created": {
        "id": "id",
        "principal_id": "principal_id",
        "principal_type": "principal_type",
        "resource_id": "resource_id",
        "resource_type": "resource_type"
      },
      "role.assignment.deleted": {
        "id": "id",
        "principal_id": "principal_id",
        "principal_type": "principal_type",
        "resource_id": "resource_id",
        "resource_type": "resource_type"
      },
      "role.bound_to_resource": {
        "id": "id",
        "connector_id": "connector_id",
        "connector_name": "connector_name",
        "enabled": true,
        "permissions": [
          "string"
        ],
        "resource_id": "resource_id",
        "resource_type": "resource_type",
        "role_id": "role_id",
        "source": "role_toggle",
        "workspace_id": "workspace_id"
      },
      "role.created": {
        "id": "id",
        "permissions": [
          "string"
        ],
        "resource_id": "resource_id",
        "resource_type": "resource_type",
        "role_name": "role_name"
      },
      "role.deleted": {
        "id": "id"
      },
      "role.unbound_from_resource": {
        "id": "id",
        "connector_id": "connector_id",
        "connector_name": "connector_name",
        "enabled": true,
        "permissions": [
          "string"
        ],
        "resource_id": "resource_id",
        "resource_type": "resource_type",
        "role_id": "role_id",
        "source": "role_toggle",
        "workspace_id": "workspace_id"
      },
      "role.updated": {
        "id": "id",
        "changes_requested": {
          "description": "description",
          "metadata": {},
          "permissions_added": [
            "string"
          ],
          "permissions_removed": [
            "string"
          ],
          "resource_id": "resource_id",
          "resource_type": "resource_type",
          "role_name": "role_name"
        }
      },
      "scim.disabled": {
        "id": "id"
      },
      "scim.enabled": {
        "id": "id"
      },
      "service_account.created": {
        "id": "id",
        "data": {
          "role": "role"
        }
      },
      "service_account.deleted": {
        "id": "id"
      },
      "service_account.updated": {
        "id": "id",
        "changes_requested": {
          "role": "role"
        }
      },
      "user.added": {
        "id": "id",
        "data": {
          "role": "role"
        }
      },
      "user.deleted": {
        "id": "id"
      },
      "user.updated": {
        "id": "id",
        "changes_requested": {
          "role": "role"
        }
      },
      "workload_identity_provider_mapping.created": {
        "id": "id",
        "data": {},
        "identity_provider_id": "identity_provider_id"
      },
      "workload_identity_provider_mapping.deleted": {
        "id": "id",
        "identity_provider_id": "identity_provider_id",
        "project_id": "project_id",
        "service_account_id": "service_account_id"
      },
      "workload_identity_provider_mapping.updated": {
        "id": "id",
        "changes_requested": {},
        "identity_provider_id": "identity_provider_id"
      },
      "workload_identity_provider.created": {
        "id": "id",
        "data": {}
      },
      "workload_identity_provider.deleted": {
        "id": "id",
        "name": "name"
      },
      "workload_identity_provider.updated": {
        "id": "id",
        "changes_requested": {}
      }
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "audit_log-defb456h8dks",
  "last_id": "audit_log-hnbkd8s93s"
}

Domain Types

Audit Log List Response

  • class AuditLogListResponse

    A log of a user action or configuration change within this organization.

    • id: String

      The ID of this log.

    • effective_at: Integer

      The Unix timestamp (in seconds) of the event.

    • type: :"api_key.created" | :"api_key.updated" | :"api_key.deleted" | 56 more

      The event type.

      • :"api_key.created"

      • :"api_key.updated"

      • :"api_key.deleted"

      • :"certificate.created"

      • :"certificate.updated"

      • :"certificate.deleted"

      • :"certificates.activated"

      • :"certificates.deactivated"

      • :"checkpoint.permission.created"

      • :"checkpoint.permission.deleted"

      • :"external_key.registered"

      • :"external_key.removed"

      • :"group.created"

      • :"group.updated"

      • :"group.deleted"

      • :"invite.sent"

      • :"invite.accepted"

      • :"invite.deleted"

      • :"ip_allowlist.created"

      • :"ip_allowlist.updated"

      • :"ip_allowlist.deleted"

      • :"ip_allowlist.config.activated"

      • :"ip_allowlist.config.deactivated"

      • :"login.succeeded"

      • :"login.failed"

      • :"logout.succeeded"

      • :"logout.failed"

      • :"organization.updated"

      • :"project.created"

      • :"project.updated"

      • :"project.archived"

      • :"project.deleted"

      • :"rate_limit.updated"

      • :"rate_limit.deleted"

      • :"resource.deleted"

      • :"tunnel.created"

      • :"tunnel.updated"

      • :"tunnel.deleted"

      • :"workload_identity_provider.created"

      • :"workload_identity_provider.updated"

      • :"workload_identity_provider.deleted"

      • :"workload_identity_provider_mapping.created"

      • :"workload_identity_provider_mapping.updated"

      • :"workload_identity_provider_mapping.deleted"

      • :"role.created"

      • :"role.updated"

      • :"role.deleted"

      • :"role.assignment.created"

      • :"role.assignment.deleted"

      • :"role.bound_to_resource"

      • :"role.unbound_from_resource"

      • :"scim.enabled"

      • :"scim.disabled"

      • :"service_account.created"

      • :"service_account.updated"

      • :"service_account.deleted"

      • :"user.added"

      • :"user.updated"

      • :"user.deleted"

    • actor: Actor{ api_key, session, type}

      The actor who performed the audit logged action.

      • api_key: APIKey{ id, service_account, type, user}

        The API Key used to perform the audit logged action.

        • id: String

          The tracking id of the API key.

        • service_account: ServiceAccount{ id}

          The service account that performed the audit logged action.

          • id: String

            The service account id.

        • type: :user | :service_account

          The type of API key. Can be either user or service_account.

          • :user

          • :service_account

        • user: User{ id, email}

          The user who performed the audit logged action.

          • id: String

            The user id.

          • email: String

            The user email.

      • session: Session{ ip_address, user}

        The session in which the audit logged action was performed.

        • ip_address: String

          The IP address from which the action was performed.

        • user: User{ id, email}

          The user who performed the audit logged action.

          • id: String

            The user id.

          • email: String

            The user email.

      • type: :session | :api_key

        The type of actor. Is either session or api_key.

        • :session

        • :api_key

    • api_key_created: APIKeyCreated{ id, data}

      The details for events with this type.

      • id: String

        The tracking ID of the API key.

      • data: Data{ scopes}

        The payload used to create the API key.

        • scopes: Array[String]

          A list of scopes allowed for the API key, e.g. ["api.model.request"]

    • api_key_deleted: APIKeyDeleted{ id}

      The details for events with this type.

      • id: String

        The tracking ID of the API key.

    • api_key_updated: APIKeyUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The tracking ID of the API key.

      • changes_requested: ChangesRequested{ scopes}

        The payload used to update the API key.

        • scopes: Array[String]

          A list of scopes allowed for the API key, e.g. ["api.model.request"]

    • certificate_created: CertificateCreated{ id, name}

      The details for events with this type.

      • id: String

        The certificate ID.

      • name: String

        The name of the certificate.

    • certificate_deleted: CertificateDeleted{ id, certificate, name}

      The details for events with this type.

      • id: String

        The certificate ID.

      • certificate: String

        The certificate content in PEM format.

      • name: String

        The name of the certificate.

    • certificate_updated: CertificateUpdated{ id, name}

      The details for events with this type.

      • id: String

        The certificate ID.

      • name: String

        The name of the certificate.

    • certificates_activated: CertificatesActivated{ certificates}

      The details for events with this type.

      • certificates: Array[Certificate{ id, name}]

        • id: String

          The certificate ID.

        • name: String

          The name of the certificate.

    • certificates_deactivated: CertificatesDeactivated{ certificates}

      The details for events with this type.

      • certificates: Array[Certificate{ id, name}]

        • id: String

          The certificate ID.

        • name: String

          The name of the certificate.

    • checkpoint_permission_created: CheckpointPermissionCreated{ id, data}

      The project and fine-tuned model checkpoint that the checkpoint permission was created for.

      • id: String

        The ID of the checkpoint permission.

      • data: Data{ fine_tuned_model_checkpoint, project_id}

        The payload used to create the checkpoint permission.

        • fine_tuned_model_checkpoint: String

          The ID of the fine-tuned model checkpoint.

        • project_id: String

          The ID of the project that the checkpoint permission was created for.

    • checkpoint_permission_deleted: CheckpointPermissionDeleted{ id}

      The details for events with this type.

      • id: String

        The ID of the checkpoint permission.

    • external_key_registered: ExternalKeyRegistered{ id, data}

      The details for events with this type.

      • id: String

        The ID of the external key configuration.

      • data: untyped

        The configuration for the external key.

    • external_key_removed: ExternalKeyRemoved{ id}

      The details for events with this type.

      • id: String

        The ID of the external key configuration.

    • group_created: GroupCreated{ id, data}

      The details for events with this type.

      • id: String

        The ID of the group.

      • data: Data{ group_name}

        Information about the created group.

        • group_name: String

          The group name.

    • group_deleted: GroupDeleted{ id}

      The details for events with this type.

      • id: String

        The ID of the group.

    • group_updated: GroupUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The ID of the group.

      • changes_requested: ChangesRequested{ group_name}

        The payload used to update the group.

        • group_name: String

          The updated group name.

    • invite_accepted: InviteAccepted{ id}

      The details for events with this type.

      • id: String

        The ID of the invite.

    • invite_deleted: InviteDeleted{ id}

      The details for events with this type.

      • id: String

        The ID of the invite.

    • invite_sent: InviteSent{ id, data}

      The details for events with this type.

      • id: String

        The ID of the invite.

      • data: Data{ email, role}

        The payload used to create the invite.

        • email: String

          The email invited to the organization.

        • role: String

          The role the email was invited to be. Is either owner or member.

    • ip_allowlist_config_activated: IPAllowlistConfigActivated{ configs}

      The details for events with this type.

      • configs: Array[Config{ id, name}]

        The configurations that were activated.

        • id: String

          The ID of the IP allowlist configuration.

        • name: String

          The name of the IP allowlist configuration.

    • ip_allowlist_config_deactivated: IPAllowlistConfigDeactivated{ configs}

      The details for events with this type.

      • configs: Array[Config{ id, name}]

        The configurations that were deactivated.

        • id: String

          The ID of the IP allowlist configuration.

        • name: String

          The name of the IP allowlist configuration.

    • ip_allowlist_created: IPAllowlistCreated{ id, allowed_ips, name}

      The details for events with this type.

      • id: String

        The ID of the IP allowlist configuration.

      • allowed_ips: Array[String]

        The IP addresses or CIDR ranges included in the configuration.

      • name: String

        The name of the IP allowlist configuration.

    • ip_allowlist_deleted: IPAllowlistDeleted{ id, allowed_ips, name}

      The details for events with this type.

      • id: String

        The ID of the IP allowlist configuration.

      • allowed_ips: Array[String]

        The IP addresses or CIDR ranges that were in the configuration.

      • name: String

        The name of the IP allowlist configuration.

    • ip_allowlist_updated: IPAllowlistUpdated{ id, allowed_ips}

      The details for events with this type.

      • id: String

        The ID of the IP allowlist configuration.

      • allowed_ips: Array[String]

        The updated set of IP addresses or CIDR ranges in the configuration.

    • login_failed: LoginFailed{ error_code, error_message}

      The details for events with this type.

      • error_code: String

        The error code of the failure.

      • error_message: String

        The error message of the failure.

    • login_succeeded: untyped

      This event has no additional fields beyond the standard audit log attributes.

    • logout_failed: LogoutFailed{ error_code, error_message}

      The details for events with this type.

      • error_code: String

        The error code of the failure.

      • error_message: String

        The error message of the failure.

    • logout_succeeded: untyped

      This event has no additional fields beyond the standard audit log attributes.

    • organization_updated: OrganizationUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The organization ID.

      • changes_requested: ChangesRequested{ api_call_logging, api_call_logging_project_ids, description, 4 more}

        The payload used to update the organization settings.

        • api_call_logging: String

          How your organization logs data from supported API calls. One of disabled, enabled_per_call, enabled_for_all_projects, or enabled_for_selected_projects

        • api_call_logging_project_ids: String

          The list of project ids if api_call_logging is set to enabled_for_selected_projects

        • description: String

          The organization description.

        • name: String

          The organization name.

        • threads_ui_visibility: String

          Visibility of the threads page which shows messages created with the Assistants API and Playground. One of ANY_ROLE, OWNERS, or NONE.

        • title: String

          The organization title.

        • usage_dashboard_visibility: String

          Visibility of the usage dashboard which shows activity and costs for your organization. One of ANY_ROLE or OWNERS.

    • project: Project{ id, name}

      The project that the action was scoped to. Absent for actions not scoped to projects. Note that any admin actions taken via Admin API keys are associated with the default project.

      • id: String

        The project ID.

      • name: String

        The project title.

    • project_archived: ProjectArchived{ id}

      The details for events with this type.

      • id: String

        The project ID.

    • project_created: ProjectCreated{ id, data}

      The details for events with this type.

      • id: String

        The project ID.

      • data: Data{ name, title}

        The payload used to create the project.

        • name: String

          The project name.

        • title: String

          The title of the project as seen on the dashboard.

    • project_deleted: ProjectDeleted{ id}

      The details for events with this type.

      • id: String

        The project ID.

    • project_updated: ProjectUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The project ID.

      • changes_requested: ChangesRequested{ title}

        The payload used to update the project.

        • title: String

          The title of the project as seen on the dashboard.

    • rate_limit_deleted: RateLimitDeleted{ id}

      The details for events with this type.

      • id: String

        The rate limit ID

    • rate_limit_updated: RateLimitUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The rate limit ID

      • changes_requested: ChangesRequested{ batch_1_day_max_input_tokens, max_audio_megabytes_per_1_minute, max_images_per_1_minute, 3 more}

        The payload used to update the rate limits.

        • batch_1_day_max_input_tokens: Integer

          The maximum batch input tokens per day. Only relevant for certain models.

        • max_audio_megabytes_per_1_minute: Integer

          The maximum audio megabytes per minute. Only relevant for certain models.

        • max_images_per_1_minute: Integer

          The maximum images per minute. Only relevant for certain models.

        • max_requests_per_1_day: Integer

          The maximum requests per day. Only relevant for certain models.

        • max_requests_per_1_minute: Integer

          The maximum requests per minute.

        • max_tokens_per_1_minute: Integer

          The maximum tokens per minute.

    • role_assignment_created: RoleAssignmentCreated{ id, principal_id, principal_type, 2 more}

      The details for events with this type.

      • id: String

        The identifier of the role assignment.

      • principal_id: String

        The principal (user or group) that received the role.

      • principal_type: String

        The type of principal (user or group) that received the role.

      • resource_id: String

        The resource the role assignment is scoped to.

      • resource_type: String

        The type of resource the role assignment is scoped to.

    • role_assignment_deleted: RoleAssignmentDeleted{ id, principal_id, principal_type, 2 more}

      The details for events with this type.

      • id: String

        The identifier of the role assignment.

      • principal_id: String

        The principal (user or group) that had the role removed.

      • principal_type: String

        The type of principal (user or group) that had the role removed.

      • resource_id: String

        The resource the role assignment was scoped to.

      • resource_type: String

        The type of resource the role assignment was scoped to.

    • role_bound_to_resource: RoleBoundToResource{ id, connector_id, connector_name, 7 more}

      The details for events with this type.

      • id: String

        The ID of the resource the role was bound to. ChatGPT workspace connector resources use <workspace_id>__<connector_id>.

      • connector_id: String

        The connector ID for a ChatGPT workspace connector resource.

      • connector_name: String

        The connector display name for a ChatGPT workspace connector resource, or the connector ID when the display name could not be resolved.

      • enabled: bool

        Whether the connector is enabled for the role.

      • permissions: Array[String]

        The permissions granted to the role for the resource.

      • resource_id: String

        The ID of the resource the role was bound to.

      • resource_type: String

        The type of resource the role was bound to.

      • role_id: String

        The ID of the role that was bound to the resource.

      • source: :role_toggle | :role_connector_update | :role_delete | 2 more

        The connector role mutation path that produced the event.

        • :role_toggle

        • :role_connector_update

        • :role_delete

        • :workspace_permissions

        • :connector_publish

      • workspace_id: String

        The workspace ID for a ChatGPT workspace connector resource.

    • role_created: RoleCreated{ id, permissions, resource_id, 2 more}

      The details for events with this type.

      • id: String

        The role ID.

      • permissions: Array[String]

        The permissions granted by the role.

      • resource_id: String

        The resource the role is scoped to.

      • resource_type: String

        The type of resource the role belongs to.

      • role_name: String

        The name of the role.

    • role_deleted: RoleDeleted{ id}

      The details for events with this type.

      • id: String

        The role ID.

    • role_unbound_from_resource: RoleUnboundFromResource{ id, connector_id, connector_name, 7 more}

      The details for events with this type.

      • id: String

        The ID of the resource the role was unbound from. ChatGPT workspace connector resources use <workspace_id>__<connector_id>.

      • connector_id: String

        The connector ID for a ChatGPT workspace connector resource.

      • connector_name: String

        The connector display name for a ChatGPT workspace connector resource, or the connector ID when the display name could not be resolved.

      • enabled: bool

        Whether the connector is enabled for the role.

      • permissions: Array[String]

        The permissions remaining for the role after the change.

      • resource_id: String

        The ID of the resource the role was unbound from.

      • resource_type: String

        The type of resource the role was unbound from.

      • role_id: String

        The ID of the role that was unbound from the resource.

      • source: :role_toggle | :role_connector_update | :role_delete | 2 more

        The connector role mutation path that produced the event.

        • :role_toggle

        • :role_connector_update

        • :role_delete

        • :workspace_permissions

        • :connector_publish

      • workspace_id: String

        The workspace ID for a ChatGPT workspace connector resource.

    • role_updated: RoleUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The role ID.

      • changes_requested: ChangesRequested{ description, metadata, permissions_added, 4 more}

        The payload used to update the role.

        • description: String

          The updated role description, when provided.

        • metadata: untyped

          Additional metadata stored on the role.

        • permissions_added: Array[String]

          The permissions added to the role.

        • permissions_removed: Array[String]

          The permissions removed from the role.

        • resource_id: String

          The resource the role is scoped to.

        • resource_type: String

          The type of resource the role belongs to.

        • role_name: String

          The updated role name, when provided.

    • scim_disabled: ScimDisabled{ id}

      The details for events with this type.

      • id: String

        The ID of the SCIM was disabled for.

    • scim_enabled: ScimEnabled{ id}

      The details for events with this type.

      • id: String

        The ID of the SCIM was enabled for.

    • service_account_created: ServiceAccountCreated{ id, data}

      The details for events with this type.

      • id: String

        The service account ID.

      • data: Data{ role}

        The payload used to create the service account.

        • role: String

          The role of the service account. Is either owner or member.

    • service_account_deleted: ServiceAccountDeleted{ id}

      The details for events with this type.

      • id: String

        The service account ID.

    • service_account_updated: ServiceAccountUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The service account ID.

      • changes_requested: ChangesRequested{ role}

        The payload used to updated the service account.

        • role: String

          The role of the service account. Is either owner or member.

    • user_added: UserAdded{ id, data}

      The details for events with this type.

      • id: String

        The user ID.

      • data: Data{ role}

        The payload used to add the user to the project.

        • role: String

          The role of the user. Is either owner or member.

    • user_deleted: UserDeleted{ id}

      The details for events with this type.

      • id: String

        The user ID.

    • user_updated: UserUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The project ID.

      • changes_requested: ChangesRequested{ role}

        The payload used to update the user.

        • role: String

          The role of the user. Is either owner or member.

    • workload_identity_provider_mapping_created: WorkloadIdentityProviderMappingCreated{ id, data, identity_provider_id}

      The details for events with this type.

      • id: String

        The workload identity provider mapping ID.

      • data: untyped

        The payload used to create the workload identity provider mapping.

      • identity_provider_id: String

        The workload identity provider ID.

    • workload_identity_provider_mapping_deleted: WorkloadIdentityProviderMappingDeleted{ id, identity_provider_id, project_id, service_account_id}

      The details for events with this type.

      • id: String

        The workload identity provider mapping ID.

      • identity_provider_id: String

        The workload identity provider ID.

      • project_id: String

        The project ID.

      • service_account_id: String

        The mapped service account ID.

    • workload_identity_provider_mapping_updated: WorkloadIdentityProviderMappingUpdated{ id, changes_requested, identity_provider_id}

      The details for events with this type.

      • id: String

        The workload identity provider mapping ID.

      • changes_requested: untyped

        The payload used to update the workload identity provider mapping.

      • identity_provider_id: String

        The workload identity provider ID.

    • workload_identity_provider_created: WorkloadIdentityProviderCreated{ id, data}

      The details for events with this type.

      • id: String

        The workload identity provider ID.

      • data: untyped

        The payload used to create the workload identity provider.

    • workload_identity_provider_deleted: WorkloadIdentityProviderDeleted{ id, name}

      The details for events with this type.

      • id: String

        The workload identity provider ID.

      • name: String

        The workload identity provider name.

    • workload_identity_provider_updated: WorkloadIdentityProviderUpdated{ id, changes_requested}

      The details for events with this type.

      • id: String

        The workload identity provider ID.

      • changes_requested: untyped

        The payload used to update the workload identity provider.

Admin API Keys

List all organization and project API keys.

admin.organization.admin_api_keys.list(**kwargs) -> CursorPage<AdminAPIKey>

get /organization/admin_api_keys

List all organization and project API keys.

Parameters

  • after: String

    Return keys with IDs that come after this ID in the pagination order.

  • limit: Integer

    Maximum number of keys to return.

  • order: :asc | :desc

    Order results by creation time, ascending or descending.

    • :asc

    • :desc

Returns

  • class AdminAPIKey

    Represents an individual Admin API key in an org.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the API key was created

    • expires_at: Integer

      The Unix timestamp (in seconds) of when the API key expires

    • object: :"organization.admin_api_key"

      The object type, which is always organization.admin_api_key

      • :"organization.admin_api_key"
    • owner: Owner{ id, created_at, name, 3 more}

      • id: String

        The identifier, which can be referenced in API endpoints

      • created_at: Integer

        The Unix timestamp (in seconds) of when the user was created

      • name: String

        The name of the user

      • object: String

        The object type, which is always organization.user

      • role: String

        Always owner

      • type: String

        Always user

    • redacted_value: String

      The redacted value of the API key

    • last_used_at: Integer

      The Unix timestamp (in seconds) of when the API key was last used

    • name: String

      The name of the API key

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.admin_api_keys.list

puts(page)

Response

{
  "data": [
    {
      "id": "key_abc",
      "created_at": 1711471533,
      "expires_at": 1714063533,
      "object": "organization.admin_api_key",
      "owner": {
        "id": "sa_456",
        "created_at": 1711471533,
        "name": "My Service Account",
        "object": "organization.user",
        "role": "owner",
        "type": "user"
      },
      "redacted_value": "sk-admin...def",
      "last_used_at": 1711471534,
      "name": "Administration Key"
    }
  ],
  "has_more": false,
  "object": "list",
  "first_id": "key_abc",
  "last_id": "key_xyz"
}

Create admin API key

admin.organization.admin_api_keys.create(**kwargs) -> AdminAPIKeyCreateResponse

post /organization/admin_api_keys

Create admin API key

Parameters

  • name: String

  • expires_in_seconds: Integer

    The number of seconds until the API key expires. Omit this field for a key that does not expire.

Returns

  • class AdminAPIKeyCreateResponse

    Represents an individual Admin API key in an org.

    • value: String

      The value of the API key. Only shown on create.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

admin_api_key = openai.admin.organization.admin_api_keys.create(name: "New Admin Key")

puts(admin_api_key)

Response

{
  "id": "key_abc",
  "created_at": 1711471533,
  "expires_at": 1714063533,
  "object": "organization.admin_api_key",
  "owner": {
    "id": "sa_456",
    "created_at": 1711471533,
    "name": "My Service Account",
    "object": "organization.user",
    "role": "owner",
    "type": "user"
  },
  "redacted_value": "sk-admin...def",
  "last_used_at": 1711471534,
  "name": "Administration Key",
  "value": "sk-admin-1234abcd"
}

Retrieve admin API key

admin.organization.admin_api_keys.retrieve(key_id) -> AdminAPIKey

get /organization/admin_api_keys/{key_id}

Retrieve admin API key

Parameters

  • key_id: String

    The ID of the API key.

Returns

  • class AdminAPIKey

    Represents an individual Admin API key in an org.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the API key was created

    • expires_at: Integer

      The Unix timestamp (in seconds) of when the API key expires

    • object: :"organization.admin_api_key"

      The object type, which is always organization.admin_api_key

      • :"organization.admin_api_key"
    • owner: Owner{ id, created_at, name, 3 more}

      • id: String

        The identifier, which can be referenced in API endpoints

      • created_at: Integer

        The Unix timestamp (in seconds) of when the user was created

      • name: String

        The name of the user

      • object: String

        The object type, which is always organization.user

      • role: String

        Always owner

      • type: String

        Always user

    • redacted_value: String

      The redacted value of the API key

    • last_used_at: Integer

      The Unix timestamp (in seconds) of when the API key was last used

    • name: String

      The name of the API key

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

admin_api_key = openai.admin.organization.admin_api_keys.retrieve("key_id")

puts(admin_api_key)

Response

{
  "id": "key_abc",
  "created_at": 1711471533,
  "expires_at": 1714063533,
  "object": "organization.admin_api_key",
  "owner": {
    "id": "sa_456",
    "created_at": 1711471533,
    "name": "My Service Account",
    "object": "organization.user",
    "role": "owner",
    "type": "user"
  },
  "redacted_value": "sk-admin...def",
  "last_used_at": 1711471534,
  "name": "Administration Key"
}

Delete admin API key

admin.organization.admin_api_keys.delete(key_id) -> AdminAPIKeyDeleteResponse

delete /organization/admin_api_keys/{key_id}

Delete admin API key

Parameters

  • key_id: String

    The ID of the API key to be deleted.

Returns

  • class AdminAPIKeyDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.admin_api_key.deleted"

      • :"organization.admin_api_key.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

admin_api_key = openai.admin.organization.admin_api_keys.delete("key_id")

puts(admin_api_key)

Response

{
  "id": "key_abc",
  "deleted": true,
  "object": "organization.admin_api_key.deleted"
}

Domain Types

Admin API Key

  • class AdminAPIKey

    Represents an individual Admin API key in an org.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the API key was created

    • expires_at: Integer

      The Unix timestamp (in seconds) of when the API key expires

    • object: :"organization.admin_api_key"

      The object type, which is always organization.admin_api_key

      • :"organization.admin_api_key"
    • owner: Owner{ id, created_at, name, 3 more}

      • id: String

        The identifier, which can be referenced in API endpoints

      • created_at: Integer

        The Unix timestamp (in seconds) of when the user was created

      • name: String

        The name of the user

      • object: String

        The object type, which is always organization.user

      • role: String

        Always owner

      • type: String

        Always user

    • redacted_value: String

      The redacted value of the API key

    • last_used_at: Integer

      The Unix timestamp (in seconds) of when the API key was last used

    • name: String

      The name of the API key

Admin API Key Create Response

  • class AdminAPIKeyCreateResponse

    Represents an individual Admin API key in an org.

    • value: String

      The value of the API key. Only shown on create.

Admin API Key Delete Response

  • class AdminAPIKeyDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.admin_api_key.deleted"

      • :"organization.admin_api_key.deleted"

Usage

Audio speeches

admin.organization.usage.audio_speeches(**kwargs) -> UsageAudioSpeechesResponse

get /organization/usage/audio_speeches

Audio speeches

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only usage for these API keys.

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id | :user_id | :api_key_id | :model]

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

    • :project_id

    • :user_id

    • :api_key_id

    • :model

  • limit: Integer

    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
  • models: Array[String]

    Return only usage for these models.

  • page: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

  • user_ids: Array[String]

    Return only usage for these users.

Returns

  • class UsageAudioSpeechesResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.audio_speeches(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Audio transcriptions

admin.organization.usage.audio_transcriptions(**kwargs) -> UsageAudioTranscriptionsResponse

get /organization/usage/audio_transcriptions

Audio transcriptions

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only usage for these API keys.

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id | :user_id | :api_key_id | :model]

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

    • :project_id

    • :user_id

    • :api_key_id

    • :model

  • limit: Integer

    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
  • models: Array[String]

    Return only usage for these models.

  • page: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

  • user_ids: Array[String]

    Return only usage for these users.

Returns

  • class UsageAudioTranscriptionsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.audio_transcriptions(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Code interpreter sessions

admin.organization.usage.code_interpreter_sessions(**kwargs) -> UsageCodeInterpreterSessionsResponse

get /organization/usage/code_interpreter_sessions

Code interpreter sessions

Parameters

  • start_time: Integer

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

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id]

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

    • :project_id
  • limit: Integer

    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: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

Returns

  • class UsageCodeInterpreterSessionsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.code_interpreter_sessions(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Completions

admin.organization.usage.completions(**kwargs) -> UsageCompletionsResponse

get /organization/usage/completions

Completions

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only usage for these API keys.

  • batch: bool

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

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id | :user_id | :api_key_id | 3 more]

    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.

    • :project_id

    • :user_id

    • :api_key_id

    • :model

    • :batch

    • :service_tier

  • limit: Integer

    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
  • models: Array[String]

    Return only usage for these models.

  • page: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

  • user_ids: Array[String]

    Return only usage for these users.

Returns

  • class UsageCompletionsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.completions(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Embeddings

admin.organization.usage.embeddings(**kwargs) -> UsageEmbeddingsResponse

get /organization/usage/embeddings

Embeddings

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only usage for these API keys.

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id | :user_id | :api_key_id | :model]

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

    • :project_id

    • :user_id

    • :api_key_id

    • :model

  • limit: Integer

    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
  • models: Array[String]

    Return only usage for these models.

  • page: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

  • user_ids: Array[String]

    Return only usage for these users.

Returns

  • class UsageEmbeddingsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.embeddings(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Images

admin.organization.usage.images(**kwargs) -> UsageImagesResponse

get /organization/usage/images

Images

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only usage for these API keys.

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id | :user_id | :api_key_id | 3 more]

    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.

    • :project_id

    • :user_id

    • :api_key_id

    • :model

    • :size

    • :source

  • limit: Integer

    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
  • models: Array[String]

    Return only usage for these models.

  • page: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

  • sizes: Array[:"256x256" | :"512x512" | :"1024x1024" | 2 more]

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

    • :"256x256"

    • :"512x512"

    • :"1024x1024"

    • :"1792x1792"

    • :"1024x1792"

  • sources: Array[:"image.generation" | :"image.edit" | :"image.variation"]

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

    • :"image.generation"

    • :"image.edit"

    • :"image.variation"

  • user_ids: Array[String]

    Return only usage for these users.

Returns

  • class UsageImagesResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.images(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Moderations

admin.organization.usage.moderations(**kwargs) -> UsageModerationsResponse

get /organization/usage/moderations

Moderations

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only usage for these API keys.

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id | :user_id | :api_key_id | :model]

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

    • :project_id

    • :user_id

    • :api_key_id

    • :model

  • limit: Integer

    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
  • models: Array[String]

    Return only usage for these models.

  • page: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

  • user_ids: Array[String]

    Return only usage for these users.

Returns

  • class UsageModerationsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.moderations(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Vector stores

admin.organization.usage.vector_stores(**kwargs) -> UsageVectorStoresResponse

get /organization/usage/vector_stores

Vector stores

Parameters

  • start_time: Integer

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

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id]

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

    • :project_id
  • limit: Integer

    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: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

Returns

  • class UsageVectorStoresResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.vector_stores(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

File search calls

admin.organization.usage.file_search_calls(**kwargs) -> UsageFileSearchCallsResponse

get /organization/usage/file_search_calls

File search calls

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only usage for these API keys.

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • end_time: Integer

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

  • group_by: Array[:project_id | :user_id | :api_key_id | :vector_store_id]

    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.

    • :project_id

    • :user_id

    • :api_key_id

    • :vector_store_id

  • limit: Integer

    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: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

  • user_ids: Array[String]

    Return only usage for these users.

  • vector_store_ids: Array[String]

    Return only usage for these vector stores.

Returns

  • class UsageFileSearchCallsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.file_search_calls(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Web search calls

admin.organization.usage.web_search_calls(**kwargs) -> UsageWebSearchCallsResponse

get /organization/usage/web_search_calls

Web search calls

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only usage for these API keys.

  • bucket_width: :"1m" | :"1h" | :"1d"

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

    • :"1m"

    • :"1h"

    • :"1d"

  • context_levels: Array[:low | :medium | :high]

    Return only web search usage for these context levels.

    • :low

    • :medium

    • :high

  • end_time: Integer

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

  • group_by: Array[:project_id | :user_id | :api_key_id | 2 more]

    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.

    • :project_id

    • :user_id

    • :api_key_id

    • :model

    • :context_level

  • limit: Integer

    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
  • models: Array[String]

    Return only usage for these models.

  • page: String

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

  • project_ids: Array[String]

    Return only usage for these projects.

  • user_ids: Array[String]

    Return only usage for these users.

Returns

  • class UsageWebSearchCallsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.web_search_calls(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Costs

admin.organization.usage.costs(**kwargs) -> UsageCostsResponse

get /organization/costs

Costs

Parameters

  • start_time: Integer

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

  • api_key_ids: Array[String]

    Return only costs for these API keys.

  • bucket_width: :"1d"

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

    • :"1d"
  • end_time: Integer

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

  • group_by: Array[:project_id | :line_item | :api_key_id]

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

    • :project_id

    • :line_item

    • :api_key_id

  • limit: Integer

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

  • page: String

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

  • project_ids: Array[String]

    Return only costs for these projects.

Returns

  • class UsageCostsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

response = openai.admin.organization.usage.costs(start_time: 0)

puts(response)

Response

{
  "data": [
    {
      "end_time": 0,
      "object": "bucket",
      "results": [
        {
          "input_tokens": 0,
          "num_model_requests": 0,
          "object": "organization.usage.completions.result",
          "output_tokens": 0,
          "api_key_id": "api_key_id",
          "batch": true,
          "input_audio_tokens": 0,
          "input_cached_tokens": 0,
          "model": "model",
          "output_audio_tokens": 0,
          "project_id": "project_id",
          "service_tier": "service_tier",
          "user_id": "user_id"
        }
      ],
      "start_time": 0
    }
  ],
  "has_more": true,
  "next_page": "next_page",
  "object": "page"
}

Domain Types

Usage Audio Speeches Response

  • class UsageAudioSpeechesResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Audio Transcriptions Response

  • class UsageAudioTranscriptionsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Code Interpreter Sessions Response

  • class UsageCodeInterpreterSessionsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Completions Response

  • class UsageCompletionsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Embeddings Response

  • class UsageEmbeddingsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Images Response

  • class UsageImagesResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Moderations Response

  • class UsageModerationsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Vector Stores Response

  • class UsageVectorStoresResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage File Search Calls Response

  • class UsageFileSearchCallsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Web Search Calls Response

  • class UsageWebSearchCallsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Usage Costs Response

  • class UsageCostsResponse

    • data: Array[Data{ end_time, object, results, start_time}]

      • end_time: Integer

      • object: :bucket

        • :bucket
      • results: Array[OrganizationUsageCompletionsResult{ input_tokens, num_model_requests, object, 10 more} | OrganizationUsageEmbeddingsResult{ input_tokens, num_model_requests, object, 4 more} | OrganizationUsageModerationsResult{ input_tokens, num_model_requests, object, 4 more} | 8 more]

        • class OrganizationUsageCompletionsResult

          The aggregated completions usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of text input tokens used, including cached tokens. For customers subscribe to scale tier, this includes scale tier tokens.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.completions.result"

            • :"organization.usage.completions.result"
          • output_tokens: Integer

            The aggregated number of text output tokens used. For customers subscribe to scale tier, this includes scale tier tokens.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • batch: bool

            When group_by=batch, this field tells whether the grouped usage result is batch or not.

          • input_audio_tokens: Integer

            The aggregated number of audio input tokens used, including cached tokens.

          • input_cached_tokens: Integer

            The aggregated number of text input tokens that has been cached from previous requests. For customers subscribe to scale tier, this includes scale tier tokens.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • output_audio_tokens: Integer

            The aggregated number of audio output tokens used.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • service_tier: String

            When group_by=service_tier, this field provides the service tier of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageEmbeddingsResult

          The aggregated embeddings usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.embeddings.result"

            • :"organization.usage.embeddings.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageModerationsResult

          The aggregated moderations usage details of the specific time bucket.

          • input_tokens: Integer

            The aggregated number of input tokens used.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.moderations.result"

            • :"organization.usage.moderations.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageImagesResult

          The aggregated images usage details of the specific time bucket.

          • images: Integer

            The number of images processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.images.result"

            • :"organization.usage.images.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • size: String

            When group_by=size, this field provides the image size of the grouped usage result.

          • source: String

            When group_by=source, this field provides the source of the grouped usage result, possible values are image.generation, image.edit, image.variation.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioSpeechesResult

          The aggregated audio speeches usage details of the specific time bucket.

          • characters: Integer

            The number of characters processed.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_speeches.result"

            • :"organization.usage.audio_speeches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageAudioTranscriptionsResult

          The aggregated audio transcriptions usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of requests made to the model.

          • object: :"organization.usage.audio_transcriptions.result"

            • :"organization.usage.audio_transcriptions.result"
          • seconds: Integer

            The number of seconds processed.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationUsageVectorStoresResult

          The aggregated vector stores usage details of the specific time bucket.

          • object: :"organization.usage.vector_stores.result"

            • :"organization.usage.vector_stores.result"
          • usage_bytes: Integer

            The vector stores usage in bytes.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageCodeInterpreterSessionsResult

          The aggregated code interpreter sessions usage details of the specific time bucket.

          • num_sessions: Integer

            The number of code interpreter sessions.

          • object: :"organization.usage.code_interpreter_sessions.result"

            • :"organization.usage.code_interpreter_sessions.result"
          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

        • class OrganizationUsageFileSearchesResult

          The aggregated file search calls usage details of the specific time bucket.

          • num_requests: Integer

            The count of file search calls.

          • object: :"organization.usage.file_searches.result"

            • :"organization.usage.file_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

          • vector_store_id: String

            When group_by=vector_store_id, this field provides the vector store ID of the grouped usage result.

        • class OrganizationUsageWebSearchesResult

          The aggregated web search calls usage details of the specific time bucket.

          • num_model_requests: Integer

            The count of model requests.

          • num_requests: Integer

            The count of web search calls.

          • object: :"organization.usage.web_searches.result"

            • :"organization.usage.web_searches.result"
          • api_key_id: String

            When group_by=api_key_id, this field provides the API key ID of the grouped usage result.

          • context_level: String

            When group_by=context_level, this field provides the search context size of the grouped usage result.

          • model: String

            When group_by=model, this field provides the model name of the grouped usage result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped usage result.

          • user_id: String

            When group_by=user_id, this field provides the user ID of the grouped usage result.

        • class OrganizationCostsResult

          The aggregated costs details of the specific time bucket.

          • object: :"organization.costs.result"

            • :"organization.costs.result"
          • amount: Amount{ currency, value}

            The monetary value in its associated currency.

            • currency: String

              Lowercase ISO-4217 currency e.g. "usd"

            • value: Float

              The numeric value of the cost.

          • api_key_id: String

            When group_by=api_key_id, this field provides the API Key ID of the grouped costs result.

          • line_item: String

            When group_by=line_item, this field provides the line item of the grouped costs result.

          • project_id: String

            When group_by=project_id, this field provides the project ID of the grouped costs result.

          • quantity: Float

            When group_by=line_item, this field provides the quantity of the grouped costs result.

      • start_time: Integer

    • has_more: bool

    • next_page: String

    • object: :page

      • :page

Invites

List invites

admin.organization.invites.list(**kwargs) -> ConversationCursorPage<Invite>

get /organization/invites

List invites

Parameters

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

Returns

  • class Invite

    Represents an individual invite to the organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the invite was sent.

    • email: String

      The email address of the individual to whom the invite was sent

    • object: :"organization.invite"

      The object type, which is always organization.invite

      • :"organization.invite"
    • projects: Array[Project{ id, role}]

      The projects that were granted membership upon acceptance of the invite.

      • id: String

        Project's public ID

      • role: :member | :owner

        Project membership role

        • :member

        • :owner

    • role: :owner | :reader

      owner or reader

      • :owner

      • :reader

    • status: :accepted | :expired | :pending

      accepted,expired, or pending

      • :accepted

      • :expired

      • :pending

    • accepted_at: Integer

      The Unix timestamp (in seconds) of when the invite was accepted.

    • expires_at: Integer

      The Unix timestamp (in seconds) of when the invite expires.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.invites.list

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "email": "email",
      "object": "organization.invite",
      "projects": [
        {
          "id": "id",
          "role": "member"
        }
      ],
      "role": "owner",
      "status": "accepted",
      "accepted_at": 0,
      "expires_at": 0
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Create invite

admin.organization.invites.create(**kwargs) -> Invite

post /organization/invites

Create invite

Parameters

  • email: String

    Send an email to this address

  • role: :reader | :owner

    owner or reader

    • :reader

    • :owner

  • projects: Array[Project{ id, role}]

    An array of projects to which membership is granted at the same time the org invite is accepted. If omitted, the user will be invited to the default project for compatibility with legacy behavior. If empty list is passed, the user will not be invited to any projects, including the default one.

    • id: String

      Project's public ID

    • role: :member | :owner

      Project membership role

      • :member

      • :owner

Returns

  • class Invite

    Represents an individual invite to the organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the invite was sent.

    • email: String

      The email address of the individual to whom the invite was sent

    • object: :"organization.invite"

      The object type, which is always organization.invite

      • :"organization.invite"
    • projects: Array[Project{ id, role}]

      The projects that were granted membership upon acceptance of the invite.

      • id: String

        Project's public ID

      • role: :member | :owner

        Project membership role

        • :member

        • :owner

    • role: :owner | :reader

      owner or reader

      • :owner

      • :reader

    • status: :accepted | :expired | :pending

      accepted,expired, or pending

      • :accepted

      • :expired

      • :pending

    • accepted_at: Integer

      The Unix timestamp (in seconds) of when the invite was accepted.

    • expires_at: Integer

      The Unix timestamp (in seconds) of when the invite expires.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

invite = openai.admin.organization.invites.create(email: "email", role: :reader)

puts(invite)

Response

{
  "id": "id",
  "created_at": 0,
  "email": "email",
  "object": "organization.invite",
  "projects": [
    {
      "id": "id",
      "role": "member"
    }
  ],
  "role": "owner",
  "status": "accepted",
  "accepted_at": 0,
  "expires_at": 0
}

Retrieve invite

admin.organization.invites.retrieve(invite_id) -> Invite

get /organization/invites/{invite_id}

Retrieve invite

Parameters

  • invite_id: String

Returns

  • class Invite

    Represents an individual invite to the organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the invite was sent.

    • email: String

      The email address of the individual to whom the invite was sent

    • object: :"organization.invite"

      The object type, which is always organization.invite

      • :"organization.invite"
    • projects: Array[Project{ id, role}]

      The projects that were granted membership upon acceptance of the invite.

      • id: String

        Project's public ID

      • role: :member | :owner

        Project membership role

        • :member

        • :owner

    • role: :owner | :reader

      owner or reader

      • :owner

      • :reader

    • status: :accepted | :expired | :pending

      accepted,expired, or pending

      • :accepted

      • :expired

      • :pending

    • accepted_at: Integer

      The Unix timestamp (in seconds) of when the invite was accepted.

    • expires_at: Integer

      The Unix timestamp (in seconds) of when the invite expires.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

invite = openai.admin.organization.invites.retrieve("invite_id")

puts(invite)

Response

{
  "id": "id",
  "created_at": 0,
  "email": "email",
  "object": "organization.invite",
  "projects": [
    {
      "id": "id",
      "role": "member"
    }
  ],
  "role": "owner",
  "status": "accepted",
  "accepted_at": 0,
  "expires_at": 0
}

Delete invite

admin.organization.invites.delete(invite_id) -> InviteDeleteResponse

delete /organization/invites/{invite_id}

Delete invite

Parameters

  • invite_id: String

Returns

  • class InviteDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.invite.deleted"

      The object type, which is always organization.invite.deleted

      • :"organization.invite.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

invite = openai.admin.organization.invites.delete("invite_id")

puts(invite)

Response

{
  "id": "id",
  "deleted": true,
  "object": "organization.invite.deleted"
}

Domain Types

Invite

  • class Invite

    Represents an individual invite to the organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the invite was sent.

    • email: String

      The email address of the individual to whom the invite was sent

    • object: :"organization.invite"

      The object type, which is always organization.invite

      • :"organization.invite"
    • projects: Array[Project{ id, role}]

      The projects that were granted membership upon acceptance of the invite.

      • id: String

        Project's public ID

      • role: :member | :owner

        Project membership role

        • :member

        • :owner

    • role: :owner | :reader

      owner or reader

      • :owner

      • :reader

    • status: :accepted | :expired | :pending

      accepted,expired, or pending

      • :accepted

      • :expired

      • :pending

    • accepted_at: Integer

      The Unix timestamp (in seconds) of when the invite was accepted.

    • expires_at: Integer

      The Unix timestamp (in seconds) of when the invite expires.

Invite Delete Response

  • class InviteDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.invite.deleted"

      The object type, which is always organization.invite.deleted

      • :"organization.invite.deleted"

Users

List users

admin.organization.users.list(**kwargs) -> ConversationCursorPage<OrganizationUser>

get /organization/users

List users

Parameters

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • emails: Array[String]

    Filter by the email address of users.

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

Returns

  • class OrganizationUser

    Represents an individual user within an organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the user was added.

    • object: :"organization.user"

      The object type, which is always organization.user

      • :"organization.user"
    • api_key_last_used_at: Integer

      The Unix timestamp (in seconds) of the user's last API key usage.

    • created: Integer

      The Unix timestamp (in seconds) of when the user was created.

    • developer_persona: String

      The developer persona metadata for the user.

    • email: String

      The email address of the user

    • is_default: bool

      Whether this is the organization's default user.

    • is_scale_tier_authorized_purchaser: bool

      Whether the user is an authorized purchaser for Scale Tier.

    • is_scim_managed: bool

      Whether the user is managed through SCIM.

    • is_service_account: bool

      Whether the user is a service account.

    • name: String

      The name of the user

    • projects: Projects{ data, object}

      Projects associated with the user, if included.

      • data: Array[Data{ id, name, role}]

        • id: String

        • name: String

        • role: String

      • object: :list

        • :list
    • role: String

      owner or reader

    • technical_level: String

      The technical level metadata for the user.

    • user: User{ id, object, banned, 5 more}

      Nested user details.

      • id: String

      • object: :user

        • :user
      • banned: bool

      • banned_at: Integer

      • email: String

      • enabled: bool

      • name: String

      • picture: String

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.users.list

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "added_at": 0,
      "object": "organization.user",
      "api_key_last_used_at": 0,
      "created": 0,
      "developer_persona": "developer_persona",
      "email": "email",
      "is_default": true,
      "is_scale_tier_authorized_purchaser": true,
      "is_scim_managed": true,
      "is_service_account": true,
      "name": "name",
      "projects": {
        "data": [
          {
            "id": "id",
            "name": "name",
            "role": "role"
          }
        ],
        "object": "list"
      },
      "role": "role",
      "technical_level": "technical_level",
      "user": {
        "id": "id",
        "object": "user",
        "banned": true,
        "banned_at": 0,
        "email": "email",
        "enabled": true,
        "name": "name",
        "picture": "picture"
      }
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Retrieve user

admin.organization.users.retrieve(user_id) -> OrganizationUser

get /organization/users/{user_id}

Retrieve user

Parameters

  • user_id: String

Returns

  • class OrganizationUser

    Represents an individual user within an organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the user was added.

    • object: :"organization.user"

      The object type, which is always organization.user

      • :"organization.user"
    • api_key_last_used_at: Integer

      The Unix timestamp (in seconds) of the user's last API key usage.

    • created: Integer

      The Unix timestamp (in seconds) of when the user was created.

    • developer_persona: String

      The developer persona metadata for the user.

    • email: String

      The email address of the user

    • is_default: bool

      Whether this is the organization's default user.

    • is_scale_tier_authorized_purchaser: bool

      Whether the user is an authorized purchaser for Scale Tier.

    • is_scim_managed: bool

      Whether the user is managed through SCIM.

    • is_service_account: bool

      Whether the user is a service account.

    • name: String

      The name of the user

    • projects: Projects{ data, object}

      Projects associated with the user, if included.

      • data: Array[Data{ id, name, role}]

        • id: String

        • name: String

        • role: String

      • object: :list

        • :list
    • role: String

      owner or reader

    • technical_level: String

      The technical level metadata for the user.

    • user: User{ id, object, banned, 5 more}

      Nested user details.

      • id: String

      • object: :user

        • :user
      • banned: bool

      • banned_at: Integer

      • email: String

      • enabled: bool

      • name: String

      • picture: String

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_user = openai.admin.organization.users.retrieve("user_id")

puts(organization_user)

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.user",
  "api_key_last_used_at": 0,
  "created": 0,
  "developer_persona": "developer_persona",
  "email": "email",
  "is_default": true,
  "is_scale_tier_authorized_purchaser": true,
  "is_scim_managed": true,
  "is_service_account": true,
  "name": "name",
  "projects": {
    "data": [
      {
        "id": "id",
        "name": "name",
        "role": "role"
      }
    ],
    "object": "list"
  },
  "role": "role",
  "technical_level": "technical_level",
  "user": {
    "id": "id",
    "object": "user",
    "banned": true,
    "banned_at": 0,
    "email": "email",
    "enabled": true,
    "name": "name",
    "picture": "picture"
  }
}

Modify user

admin.organization.users.update(user_id, **kwargs) -> OrganizationUser

post /organization/users/{user_id}

Modify user

Parameters

  • user_id: String

  • developer_persona: String

    Developer persona metadata.

  • role: String

    owner or reader

  • role_id: String

    Role ID to assign to the user.

  • technical_level: String

    Technical level metadata.

Returns

  • class OrganizationUser

    Represents an individual user within an organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the user was added.

    • object: :"organization.user"

      The object type, which is always organization.user

      • :"organization.user"
    • api_key_last_used_at: Integer

      The Unix timestamp (in seconds) of the user's last API key usage.

    • created: Integer

      The Unix timestamp (in seconds) of when the user was created.

    • developer_persona: String

      The developer persona metadata for the user.

    • email: String

      The email address of the user

    • is_default: bool

      Whether this is the organization's default user.

    • is_scale_tier_authorized_purchaser: bool

      Whether the user is an authorized purchaser for Scale Tier.

    • is_scim_managed: bool

      Whether the user is managed through SCIM.

    • is_service_account: bool

      Whether the user is a service account.

    • name: String

      The name of the user

    • projects: Projects{ data, object}

      Projects associated with the user, if included.

      • data: Array[Data{ id, name, role}]

        • id: String

        • name: String

        • role: String

      • object: :list

        • :list
    • role: String

      owner or reader

    • technical_level: String

      The technical level metadata for the user.

    • user: User{ id, object, banned, 5 more}

      Nested user details.

      • id: String

      • object: :user

        • :user
      • banned: bool

      • banned_at: Integer

      • email: String

      • enabled: bool

      • name: String

      • picture: String

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_user = openai.admin.organization.users.update("user_id")

puts(organization_user)

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.user",
  "api_key_last_used_at": 0,
  "created": 0,
  "developer_persona": "developer_persona",
  "email": "email",
  "is_default": true,
  "is_scale_tier_authorized_purchaser": true,
  "is_scim_managed": true,
  "is_service_account": true,
  "name": "name",
  "projects": {
    "data": [
      {
        "id": "id",
        "name": "name",
        "role": "role"
      }
    ],
    "object": "list"
  },
  "role": "role",
  "technical_level": "technical_level",
  "user": {
    "id": "id",
    "object": "user",
    "banned": true,
    "banned_at": 0,
    "email": "email",
    "enabled": true,
    "name": "name",
    "picture": "picture"
  }
}

Delete user

admin.organization.users.delete(user_id) -> UserDeleteResponse

delete /organization/users/{user_id}

Delete user

Parameters

  • user_id: String

Returns

  • class UserDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.user.deleted"

      • :"organization.user.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

user = openai.admin.organization.users.delete("user_id")

puts(user)

Response

{
  "id": "id",
  "deleted": true,
  "object": "organization.user.deleted"
}

Domain Types

Organization User

  • class OrganizationUser

    Represents an individual user within an organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the user was added.

    • object: :"organization.user"

      The object type, which is always organization.user

      • :"organization.user"
    • api_key_last_used_at: Integer

      The Unix timestamp (in seconds) of the user's last API key usage.

    • created: Integer

      The Unix timestamp (in seconds) of when the user was created.

    • developer_persona: String

      The developer persona metadata for the user.

    • email: String

      The email address of the user

    • is_default: bool

      Whether this is the organization's default user.

    • is_scale_tier_authorized_purchaser: bool

      Whether the user is an authorized purchaser for Scale Tier.

    • is_scim_managed: bool

      Whether the user is managed through SCIM.

    • is_service_account: bool

      Whether the user is a service account.

    • name: String

      The name of the user

    • projects: Projects{ data, object}

      Projects associated with the user, if included.

      • data: Array[Data{ id, name, role}]

        • id: String

        • name: String

        • role: String

      • object: :list

        • :list
    • role: String

      owner or reader

    • technical_level: String

      The technical level metadata for the user.

    • user: User{ id, object, banned, 5 more}

      Nested user details.

      • id: String

      • object: :user

        • :user
      • banned: bool

      • banned_at: Integer

      • email: String

      • enabled: bool

      • name: String

      • picture: String

User Delete Response

  • class UserDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.user.deleted"

      • :"organization.user.deleted"

Roles

List user organization role assignments

admin.organization.users.roles.list(user_id, **kwargs) -> NextCursorPage<RoleListResponse>

get /organization/users/{user_id}/roles

List user organization role assignments

Parameters

  • user_id: String

  • after: String

    Cursor for pagination. Provide the value from the previous response's next field to continue listing organization roles.

  • limit: Integer

    A limit on the number of organization role assignments to return.

  • order: :asc | :desc

    Sort order for the returned organization roles.

    • :asc

    • :desc

Returns

  • class RoleListResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.users.roles.list("user_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "assignment_sources": [
        {
          "principal_id": "principal_id",
          "principal_type": "principal_type"
        }
      ],
      "created_at": 0,
      "created_by": "created_by",
      "created_by_user_obj": {
        "foo": "bar"
      },
      "description": "description",
      "metadata": {
        "foo": "bar"
      },
      "name": "name",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type",
      "updated_at": 0
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Assign organization role to user

admin.organization.users.roles.create(user_id, **kwargs) -> RoleCreateResponse

post /organization/users/{user_id}/roles

Assign organization role to user

Parameters

  • user_id: String

  • role_id: String

    Identifier of the role to assign.

Returns

  • class RoleCreateResponse

    Role assignment linking a user to a role.

    • object: :"user.role"

      Always user.role.

      • :"user.role"
    • role: Role

      Details about a role that can be assigned through the public Roles API.

      • id: String

        Identifier for the role.

      • description: String

        Optional description of the role.

      • name: String

        Unique name for the role.

      • object: :role

        Always role.

        • :role
      • permissions: Array[String]

        Permissions granted by the role.

      • predefined_role: bool

        Whether the role is predefined and managed by OpenAI.

      • resource_type: String

        Resource type the role is bound to (for example api.organization or api.project).

    • user: OrganizationUser

      Represents an individual user within an organization.

      • id: String

        The identifier, which can be referenced in API endpoints

      • added_at: Integer

        The Unix timestamp (in seconds) of when the user was added.

      • object: :"organization.user"

        The object type, which is always organization.user

        • :"organization.user"
      • api_key_last_used_at: Integer

        The Unix timestamp (in seconds) of the user's last API key usage.

      • created: Integer

        The Unix timestamp (in seconds) of when the user was created.

      • developer_persona: String

        The developer persona metadata for the user.

      • email: String

        The email address of the user

      • is_default: bool

        Whether this is the organization's default user.

      • is_scale_tier_authorized_purchaser: bool

        Whether the user is an authorized purchaser for Scale Tier.

      • is_scim_managed: bool

        Whether the user is managed through SCIM.

      • is_service_account: bool

        Whether the user is a service account.

      • name: String

        The name of the user

      • projects: Projects{ data, object}

        Projects associated with the user, if included.

        • data: Array[Data{ id, name, role}]

          • id: String

          • name: String

          • role: String

        • object: :list

          • :list
      • role: String

        owner or reader

      • technical_level: String

        The technical level metadata for the user.

      • user: User{ id, object, banned, 5 more}

        Nested user details.

        • id: String

        • object: :user

          • :user
        • banned: bool

        • banned_at: Integer

        • email: String

        • enabled: bool

        • name: String

        • picture: String

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.users.roles.create("user_id", role_id: "role_id")

puts(role)

Response

{
  "object": "user.role",
  "role": {
    "id": "id",
    "description": "description",
    "name": "name",
    "object": "role",
    "permissions": [
      "string"
    ],
    "predefined_role": true,
    "resource_type": "resource_type"
  },
  "user": {
    "id": "id",
    "added_at": 0,
    "object": "organization.user",
    "api_key_last_used_at": 0,
    "created": 0,
    "developer_persona": "developer_persona",
    "email": "email",
    "is_default": true,
    "is_scale_tier_authorized_purchaser": true,
    "is_scim_managed": true,
    "is_service_account": true,
    "name": "name",
    "projects": {
      "data": [
        {
          "id": "id",
          "name": "name",
          "role": "role"
        }
      ],
      "object": "list"
    },
    "role": "role",
    "technical_level": "technical_level",
    "user": {
      "id": "id",
      "object": "user",
      "banned": true,
      "banned_at": 0,
      "email": "email",
      "enabled": true,
      "name": "name",
      "picture": "picture"
    }
  }
}

Retrieve user organization role

admin.organization.users.roles.retrieve(role_id, **kwargs) -> RoleRetrieveResponse

get /organization/users/{user_id}/roles/{role_id}

Retrieve user organization role

Parameters

  • user_id: String

  • role_id: String

Returns

  • class RoleRetrieveResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.users.roles.retrieve("role_id", user_id: "user_id")

puts(role)

Response

{
  "id": "id",
  "assignment_sources": [
    {
      "principal_id": "principal_id",
      "principal_type": "principal_type"
    }
  ],
  "created_at": 0,
  "created_by": "created_by",
  "created_by_user_obj": {
    "foo": "bar"
  },
  "description": "description",
  "metadata": {
    "foo": "bar"
  },
  "name": "name",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type",
  "updated_at": 0
}

Unassign organization role from user

admin.organization.users.roles.delete(role_id, **kwargs) -> RoleDeleteResponse

delete /organization/users/{user_id}/roles/{role_id}

Unassign organization role from user

Parameters

  • user_id: String

  • role_id: String

Returns

  • class RoleDeleteResponse

    Confirmation payload returned after unassigning a role.

    • deleted: bool

      Whether the assignment was removed.

    • object: String

      Identifier for the deleted assignment, such as group.role.deleted or user.role.deleted.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.users.roles.delete("role_id", user_id: "user_id")

puts(role)

Response

{
  "deleted": true,
  "object": "object"
}

Domain Types

Role List Response

  • class RoleListResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Role Create Response

  • class RoleCreateResponse

    Role assignment linking a user to a role.

    • object: :"user.role"

      Always user.role.

      • :"user.role"
    • role: Role

      Details about a role that can be assigned through the public Roles API.

      • id: String

        Identifier for the role.

      • description: String

        Optional description of the role.

      • name: String

        Unique name for the role.

      • object: :role

        Always role.

        • :role
      • permissions: Array[String]

        Permissions granted by the role.

      • predefined_role: bool

        Whether the role is predefined and managed by OpenAI.

      • resource_type: String

        Resource type the role is bound to (for example api.organization or api.project).

    • user: OrganizationUser

      Represents an individual user within an organization.

      • id: String

        The identifier, which can be referenced in API endpoints

      • added_at: Integer

        The Unix timestamp (in seconds) of when the user was added.

      • object: :"organization.user"

        The object type, which is always organization.user

        • :"organization.user"
      • api_key_last_used_at: Integer

        The Unix timestamp (in seconds) of the user's last API key usage.

      • created: Integer

        The Unix timestamp (in seconds) of when the user was created.

      • developer_persona: String

        The developer persona metadata for the user.

      • email: String

        The email address of the user

      • is_default: bool

        Whether this is the organization's default user.

      • is_scale_tier_authorized_purchaser: bool

        Whether the user is an authorized purchaser for Scale Tier.

      • is_scim_managed: bool

        Whether the user is managed through SCIM.

      • is_service_account: bool

        Whether the user is a service account.

      • name: String

        The name of the user

      • projects: Projects{ data, object}

        Projects associated with the user, if included.

        • data: Array[Data{ id, name, role}]

          • id: String

          • name: String

          • role: String

        • object: :list

          • :list
      • role: String

        owner or reader

      • technical_level: String

        The technical level metadata for the user.

      • user: User{ id, object, banned, 5 more}

        Nested user details.

        • id: String

        • object: :user

          • :user
        • banned: bool

        • banned_at: Integer

        • email: String

        • enabled: bool

        • name: String

        • picture: String

Role Retrieve Response

  • class RoleRetrieveResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Role Delete Response

  • class RoleDeleteResponse

    Confirmation payload returned after unassigning a role.

    • deleted: bool

      Whether the assignment was removed.

    • object: String

      Identifier for the deleted assignment, such as group.role.deleted or user.role.deleted.

Groups

List groups

admin.organization.groups.list(**kwargs) -> NextCursorPage<Group>

get /organization/groups

List groups

Parameters

  • after: String

    A cursor for use in pagination. after is a group ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with group_abc, your subsequent call can include after=group_abc in order to fetch the next page of the list.

  • limit: Integer

    A limit on the number of groups to be returned. Limit can range between 0 and 1000, and the default is 100.

  • order: :asc | :desc

    Specifies the sort order of the returned groups.

    • :asc

    • :desc

Returns

  • class Group

    Details about an organization group.

    • id: String

      Identifier for the group.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was created.

    • group_type: :group | :tenant_group

      The type of the group.

      • :group

      • :tenant_group

    • is_scim_managed: bool

      Whether the group is managed through SCIM and controlled by your identity provider.

    • name: String

      Display name of the group.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.groups.list

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "group_type": "group",
      "is_scim_managed": true,
      "name": "name"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Create group

admin.organization.groups.create(**kwargs) -> Group

post /organization/groups

Create group

Parameters

  • name: String

    Human readable name for the group.

Returns

  • class Group

    Details about an organization group.

    • id: String

      Identifier for the group.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was created.

    • group_type: :group | :tenant_group

      The type of the group.

      • :group

      • :tenant_group

    • is_scim_managed: bool

      Whether the group is managed through SCIM and controlled by your identity provider.

    • name: String

      Display name of the group.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

group = openai.admin.organization.groups.create(name: "x")

puts(group)

Response

{
  "id": "id",
  "created_at": 0,
  "group_type": "group",
  "is_scim_managed": true,
  "name": "name"
}

Retrieve group

admin.organization.groups.retrieve(group_id) -> Group

get /organization/groups/{group_id}

Retrieve group

Parameters

  • group_id: String

Returns

  • class Group

    Details about an organization group.

    • id: String

      Identifier for the group.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was created.

    • group_type: :group | :tenant_group

      The type of the group.

      • :group

      • :tenant_group

    • is_scim_managed: bool

      Whether the group is managed through SCIM and controlled by your identity provider.

    • name: String

      Display name of the group.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

group = openai.admin.organization.groups.retrieve("group_id")

puts(group)

Response

{
  "id": "id",
  "created_at": 0,
  "group_type": "group",
  "is_scim_managed": true,
  "name": "name"
}

Update group

admin.organization.groups.update(group_id, **kwargs) -> GroupUpdateResponse

post /organization/groups/{group_id}

Update group

Parameters

  • group_id: String

  • name: String

    New display name for the group.

Returns

  • class GroupUpdateResponse

    Response returned after updating a group.

    • id: String

      Identifier for the group.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was created.

    • is_scim_managed: bool

      Whether the group is managed through SCIM and controlled by your identity provider.

    • name: String

      Updated display name for the group.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

group = openai.admin.organization.groups.update("group_id", name: "x")

puts(group)

Response

{
  "id": "id",
  "created_at": 0,
  "is_scim_managed": true,
  "name": "name"
}

Delete group

admin.organization.groups.delete(group_id) -> GroupDeleteResponse

delete /organization/groups/{group_id}

Delete group

Parameters

  • group_id: String

Returns

  • class GroupDeleteResponse

    Confirmation payload returned after deleting a group.

    • id: String

      Identifier of the deleted group.

    • deleted: bool

      Whether the group was deleted.

    • object: :"group.deleted"

      Always group.deleted.

      • :"group.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

group = openai.admin.organization.groups.delete("group_id")

puts(group)

Response

{
  "id": "id",
  "deleted": true,
  "object": "group.deleted"
}

Domain Types

Group

  • class Group

    Details about an organization group.

    • id: String

      Identifier for the group.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was created.

    • group_type: :group | :tenant_group

      The type of the group.

      • :group

      • :tenant_group

    • is_scim_managed: bool

      Whether the group is managed through SCIM and controlled by your identity provider.

    • name: String

      Display name of the group.

Group Update Response

  • class GroupUpdateResponse

    Response returned after updating a group.

    • id: String

      Identifier for the group.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was created.

    • is_scim_managed: bool

      Whether the group is managed through SCIM and controlled by your identity provider.

    • name: String

      Updated display name for the group.

Group Delete Response

  • class GroupDeleteResponse

    Confirmation payload returned after deleting a group.

    • id: String

      Identifier of the deleted group.

    • deleted: bool

      Whether the group was deleted.

    • object: :"group.deleted"

      Always group.deleted.

      • :"group.deleted"

Users

List group users

admin.organization.groups.users.list(group_id, **kwargs) -> NextCursorPage<OrganizationGroupUser>

get /organization/groups/{group_id}/users

List group users

Parameters

  • group_id: String

  • after: String

    A cursor for use in pagination. Provide the ID of the last user from the previous list response to retrieve the next page.

  • limit: Integer

    A limit on the number of users to be returned. Limit can range between 0 and 1000, and the default is 100.

  • order: :asc | :desc

    Specifies the sort order of users in the list.

    • :asc

    • :desc

Returns

  • class OrganizationGroupUser

    Represents an individual user returned when inspecting group membership.

    • id: String

      The identifier, which can be referenced in API endpoints

    • email: String

      The email address of the user.

    • name: String

      The name of the user.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.groups.users.list("group_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "email": "email",
      "name": "name"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Add group user

admin.organization.groups.users.create(group_id, **kwargs) -> UserCreateResponse

post /organization/groups/{group_id}/users

Add group user

Parameters

  • group_id: String

  • user_id: String

    Identifier of the user to add to the group.

Returns

  • class UserCreateResponse

    Confirmation payload returned after adding a user to a group.

    • group_id: String

      Identifier of the group the user was added to.

    • object: :"group.user"

      Always group.user.

      • :"group.user"
    • user_id: String

      Identifier of the user that was added.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

user = openai.admin.organization.groups.users.create("group_id", user_id: "user_id")

puts(user)

Response

{
  "group_id": "group_id",
  "object": "group.user",
  "user_id": "user_id"
}

Retrieve group user

admin.organization.groups.users.retrieve(user_id, **kwargs) -> UserRetrieveResponse

get /organization/groups/{group_id}/users/{user_id}

Retrieve group user

Parameters

  • group_id: String

  • user_id: String

Returns

  • class UserRetrieveResponse

    Details about a user returned from an organization group membership lookup.

    • id: String

      Identifier for the user.

    • email: String

      Email address of the user, or null for users without an email.

    • is_service_account: bool

      Whether the user is a service account.

    • name: String

      Display name of the user.

    • picture: String

      URL of the user's profile picture, if available.

    • user_type: :user | :tenant_user

      The type of user.

      • :user

      • :tenant_user

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

user = openai.admin.organization.groups.users.retrieve("user_id", group_id: "group_id")

puts(user)

Response

{
  "id": "id",
  "email": "email",
  "is_service_account": true,
  "name": "name",
  "picture": "picture",
  "user_type": "user"
}

Remove group user

admin.organization.groups.users.delete(user_id, **kwargs) -> UserDeleteResponse

delete /organization/groups/{group_id}/users/{user_id}

Remove group user

Parameters

  • group_id: String

  • user_id: String

Returns

  • class UserDeleteResponse

    Confirmation payload returned after removing a user from a group.

    • deleted: bool

      Whether the group membership was removed.

    • object: :"group.user.deleted"

      Always group.user.deleted.

      • :"group.user.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

user = openai.admin.organization.groups.users.delete("user_id", group_id: "group_id")

puts(user)

Response

{
  "deleted": true,
  "object": "group.user.deleted"
}

Domain Types

Organization Group User

  • class OrganizationGroupUser

    Represents an individual user returned when inspecting group membership.

    • id: String

      The identifier, which can be referenced in API endpoints

    • email: String

      The email address of the user.

    • name: String

      The name of the user.

User Create Response

  • class UserCreateResponse

    Confirmation payload returned after adding a user to a group.

    • group_id: String

      Identifier of the group the user was added to.

    • object: :"group.user"

      Always group.user.

      • :"group.user"
    • user_id: String

      Identifier of the user that was added.

User Retrieve Response

  • class UserRetrieveResponse

    Details about a user returned from an organization group membership lookup.

    • id: String

      Identifier for the user.

    • email: String

      Email address of the user, or null for users without an email.

    • is_service_account: bool

      Whether the user is a service account.

    • name: String

      Display name of the user.

    • picture: String

      URL of the user's profile picture, if available.

    • user_type: :user | :tenant_user

      The type of user.

      • :user

      • :tenant_user

User Delete Response

  • class UserDeleteResponse

    Confirmation payload returned after removing a user from a group.

    • deleted: bool

      Whether the group membership was removed.

    • object: :"group.user.deleted"

      Always group.user.deleted.

      • :"group.user.deleted"

Roles

List group organization role assignments

admin.organization.groups.roles.list(group_id, **kwargs) -> NextCursorPage<RoleListResponse>

get /organization/groups/{group_id}/roles

List group organization role assignments

Parameters

  • group_id: String

  • after: String

    Cursor for pagination. Provide the value from the previous response's next field to continue listing organization roles.

  • limit: Integer

    A limit on the number of organization role assignments to return.

  • order: :asc | :desc

    Sort order for the returned organization roles.

    • :asc

    • :desc

Returns

  • class RoleListResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.groups.roles.list("group_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "assignment_sources": [
        {
          "principal_id": "principal_id",
          "principal_type": "principal_type"
        }
      ],
      "created_at": 0,
      "created_by": "created_by",
      "created_by_user_obj": {
        "foo": "bar"
      },
      "description": "description",
      "metadata": {
        "foo": "bar"
      },
      "name": "name",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type",
      "updated_at": 0
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Assign organization role to group

admin.organization.groups.roles.create(group_id, **kwargs) -> RoleCreateResponse

post /organization/groups/{group_id}/roles

Assign organization role to group

Parameters

  • group_id: String

  • role_id: String

    Identifier of the role to assign.

Returns

  • class RoleCreateResponse

    Role assignment linking a group to a role.

    • group: Group{ id, created_at, name, 2 more}

      Summary information about a group returned in role assignment responses.

      • id: String

        Identifier for the group.

      • created_at: Integer

        Unix timestamp (in seconds) when the group was created.

      • name: String

        Display name of the group.

      • object: :group

        Always group.

        • :group
      • scim_managed: bool

        Whether the group is managed through SCIM.

    • object: :"group.role"

      Always group.role.

      • :"group.role"
    • role: Role

      Details about a role that can be assigned through the public Roles API.

      • id: String

        Identifier for the role.

      • description: String

        Optional description of the role.

      • name: String

        Unique name for the role.

      • object: :role

        Always role.

        • :role
      • permissions: Array[String]

        Permissions granted by the role.

      • predefined_role: bool

        Whether the role is predefined and managed by OpenAI.

      • resource_type: String

        Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.groups.roles.create("group_id", role_id: "role_id")

puts(role)

Response

{
  "group": {
    "id": "id",
    "created_at": 0,
    "name": "name",
    "object": "group",
    "scim_managed": true
  },
  "object": "group.role",
  "role": {
    "id": "id",
    "description": "description",
    "name": "name",
    "object": "role",
    "permissions": [
      "string"
    ],
    "predefined_role": true,
    "resource_type": "resource_type"
  }
}

Retrieve group organization role

admin.organization.groups.roles.retrieve(role_id, **kwargs) -> RoleRetrieveResponse

get /organization/groups/{group_id}/roles/{role_id}

Retrieve group organization role

Parameters

  • group_id: String

  • role_id: String

Returns

  • class RoleRetrieveResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.groups.roles.retrieve("role_id", group_id: "group_id")

puts(role)

Response

{
  "id": "id",
  "assignment_sources": [
    {
      "principal_id": "principal_id",
      "principal_type": "principal_type"
    }
  ],
  "created_at": 0,
  "created_by": "created_by",
  "created_by_user_obj": {
    "foo": "bar"
  },
  "description": "description",
  "metadata": {
    "foo": "bar"
  },
  "name": "name",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type",
  "updated_at": 0
}

Unassign organization role from group

admin.organization.groups.roles.delete(role_id, **kwargs) -> RoleDeleteResponse

delete /organization/groups/{group_id}/roles/{role_id}

Unassign organization role from group

Parameters

  • group_id: String

  • role_id: String

Returns

  • class RoleDeleteResponse

    Confirmation payload returned after unassigning a role.

    • deleted: bool

      Whether the assignment was removed.

    • object: String

      Identifier for the deleted assignment, such as group.role.deleted or user.role.deleted.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.groups.roles.delete("role_id", group_id: "group_id")

puts(role)

Response

{
  "deleted": true,
  "object": "object"
}

Domain Types

Role List Response

  • class RoleListResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Role Create Response

  • class RoleCreateResponse

    Role assignment linking a group to a role.

    • group: Group{ id, created_at, name, 2 more}

      Summary information about a group returned in role assignment responses.

      • id: String

        Identifier for the group.

      • created_at: Integer

        Unix timestamp (in seconds) when the group was created.

      • name: String

        Display name of the group.

      • object: :group

        Always group.

        • :group
      • scim_managed: bool

        Whether the group is managed through SCIM.

    • object: :"group.role"

      Always group.role.

      • :"group.role"
    • role: Role

      Details about a role that can be assigned through the public Roles API.

      • id: String

        Identifier for the role.

      • description: String

        Optional description of the role.

      • name: String

        Unique name for the role.

      • object: :role

        Always role.

        • :role
      • permissions: Array[String]

        Permissions granted by the role.

      • predefined_role: bool

        Whether the role is predefined and managed by OpenAI.

      • resource_type: String

        Resource type the role is bound to (for example api.organization or api.project).

Role Retrieve Response

  • class RoleRetrieveResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Role Delete Response

  • class RoleDeleteResponse

    Confirmation payload returned after unassigning a role.

    • deleted: bool

      Whether the assignment was removed.

    • object: String

      Identifier for the deleted assignment, such as group.role.deleted or user.role.deleted.

Roles

List organization roles

admin.organization.roles.list(**kwargs) -> NextCursorPage<Role>

get /organization/roles

List organization roles

Parameters

  • after: String

    Cursor for pagination. Provide the value from the previous response's next field to continue listing roles.

  • limit: Integer

    A limit on the number of roles to return. Defaults to 1000.

  • order: :asc | :desc

    Sort order for the returned roles.

    • :asc

    • :desc

Returns

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.roles.list

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "description": "description",
      "name": "name",
      "object": "role",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Create organization role

admin.organization.roles.create(**kwargs) -> Role

post /organization/roles

Create organization role

Parameters

  • permissions: Array[String]

    Permissions to grant to the role.

  • role_name: String

    Unique name for the role.

  • description: String

    Optional description of the role.

Returns

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.roles.create(permissions: ["string"], role_name: "role_name")

puts(role)

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Retrieve organization role

admin.organization.roles.retrieve(role_id) -> Role

get /organization/roles/{role_id}

Retrieve organization role

Parameters

  • role_id: String

Returns

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.roles.retrieve("role_id")

puts(role)

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Update organization role

admin.organization.roles.update(role_id, **kwargs) -> Role

post /organization/roles/{role_id}

Update organization role

Parameters

  • role_id: String

  • description: String

    New description for the role.

  • permissions: Array[String]

    Updated set of permissions for the role.

  • role_name: String

    New name for the role.

Returns

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.roles.update("role_id")

puts(role)

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Delete organization role

admin.organization.roles.delete(role_id) -> RoleDeleteResponse

delete /organization/roles/{role_id}

Delete organization role

Parameters

  • role_id: String

Returns

  • class RoleDeleteResponse

    Confirmation payload returned after deleting a role.

    • id: String

      Identifier of the deleted role.

    • deleted: bool

      Whether the role was deleted.

    • object: :"role.deleted"

      Always role.deleted.

      • :"role.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.roles.delete("role_id")

puts(role)

Response

{
  "id": "id",
  "deleted": true,
  "object": "role.deleted"
}

Domain Types

Role

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Role Delete Response

  • class RoleDeleteResponse

    Confirmation payload returned after deleting a role.

    • id: String

      Identifier of the deleted role.

    • deleted: bool

      Whether the role was deleted.

    • object: :"role.deleted"

      Always role.deleted.

      • :"role.deleted"

Data Retention

Retrieve organization data retention

admin.organization.data_retention.retrieve() -> OrganizationDataRetention

get /organization/data_retention

Retrieve organization data retention

Returns

  • class OrganizationDataRetention

    Represents the organization's data retention control setting.

    • object: :"organization.data_retention"

      The object type, which is always organization.data_retention.

      • :"organization.data_retention"
    • type: :zero_data_retention | :modified_abuse_monitoring | :enhanced_zero_data_retention | :enhanced_modified_abuse_monitoring

      The configured organization data retention type.

      • :zero_data_retention

      • :modified_abuse_monitoring

      • :enhanced_zero_data_retention

      • :enhanced_modified_abuse_monitoring

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_data_retention = openai.admin.organization.data_retention.retrieve

puts(organization_data_retention)

Response

{
  "object": "organization.data_retention",
  "type": "zero_data_retention"
}

Update organization data retention

admin.organization.data_retention.update(**kwargs) -> OrganizationDataRetention

post /organization/data_retention

Update organization data retention

Parameters

  • retention_type: :zero_data_retention | :modified_abuse_monitoring | :enhanced_zero_data_retention | :enhanced_modified_abuse_monitoring

    The desired organization data retention type.

    • :zero_data_retention

    • :modified_abuse_monitoring

    • :enhanced_zero_data_retention

    • :enhanced_modified_abuse_monitoring

Returns

  • class OrganizationDataRetention

    Represents the organization's data retention control setting.

    • object: :"organization.data_retention"

      The object type, which is always organization.data_retention.

      • :"organization.data_retention"
    • type: :zero_data_retention | :modified_abuse_monitoring | :enhanced_zero_data_retention | :enhanced_modified_abuse_monitoring

      The configured organization data retention type.

      • :zero_data_retention

      • :modified_abuse_monitoring

      • :enhanced_zero_data_retention

      • :enhanced_modified_abuse_monitoring

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_data_retention = openai.admin.organization.data_retention.update(retention_type: :zero_data_retention)

puts(organization_data_retention)

Response

{
  "object": "organization.data_retention",
  "type": "zero_data_retention"
}

Domain Types

Organization Data Retention

  • class OrganizationDataRetention

    Represents the organization's data retention control setting.

    • object: :"organization.data_retention"

      The object type, which is always organization.data_retention.

      • :"organization.data_retention"
    • type: :zero_data_retention | :modified_abuse_monitoring | :enhanced_zero_data_retention | :enhanced_modified_abuse_monitoring

      The configured organization data retention type.

      • :zero_data_retention

      • :modified_abuse_monitoring

      • :enhanced_zero_data_retention

      • :enhanced_modified_abuse_monitoring

Spend Alerts

List organization spend alerts

admin.organization.spend_alerts.list(**kwargs) -> ConversationCursorPage<OrganizationSpendAlert>

get /organization/spend_alerts

List organization spend alerts

Parameters

  • after: String

    Cursor for pagination. Provide the ID of the last spend alert from the previous response to fetch the next page.

  • before: String

    Cursor for pagination. Provide the ID of the first spend alert from the previous response to fetch the previous page.

  • limit: Integer

    A limit on the number of spend alerts to return. Defaults to 20.

  • order: :asc | :desc

    Sort order for the returned spend alerts.

    • :asc

    • :desc

Returns

  • class OrganizationSpendAlert

    Represents a spend alert configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"organization.spend_alert"

      The object type, which is always organization.spend_alert.

      • :"organization.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.spend_alerts.list

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "currency": "USD",
      "interval": "month",
      "notification_channel": {
        "recipients": [
          "string"
        ],
        "type": "email",
        "subject_prefix": "subject_prefix"
      },
      "object": "organization.spend_alert",
      "threshold_amount": 0
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}

Create organization spend alert

admin.organization.spend_alerts.create(**kwargs) -> OrganizationSpendAlert

post /organization/spend_alerts

Create organization spend alert

Parameters

  • currency: :USD

    The currency for the threshold amount.

    • :USD
  • interval: :month

    The time interval for evaluating spend against the threshold.

    • :month
  • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

    Email notification settings for a spend alert.

    • recipients: Array[String]

      Email addresses that receive the spend alert notification.

    • type: :email

      The notification channel type. Currently only email is supported.

      • :email
    • subject_prefix: String

      Optional subject prefix for alert emails.

  • threshold_amount: Integer

    The alert threshold amount, in cents.

Returns

  • class OrganizationSpendAlert

    Represents a spend alert configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"organization.spend_alert"

      The object type, which is always organization.spend_alert.

      • :"organization.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_spend_alert = openai.admin.organization.spend_alerts.create(
  currency: :USD,
  interval: :month,
  notification_channel: {recipients: ["string"], type: :email},
  threshold_amount: 0
)

puts(organization_spend_alert)

Response

{
  "id": "id",
  "currency": "USD",
  "interval": "month",
  "notification_channel": {
    "recipients": [
      "string"
    ],
    "type": "email",
    "subject_prefix": "subject_prefix"
  },
  "object": "organization.spend_alert",
  "threshold_amount": 0
}

Retrieve organization spend alert

admin.organization.spend_alerts.retrieve(alert_id) -> OrganizationSpendAlert

get /organization/spend_alerts/{alert_id}

Retrieve organization spend alert

Parameters

  • alert_id: String

Returns

  • class OrganizationSpendAlert

    Represents a spend alert configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"organization.spend_alert"

      The object type, which is always organization.spend_alert.

      • :"organization.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_spend_alert = openai.admin.organization.spend_alerts.retrieve("alert_id")

puts(organization_spend_alert)

Response

{
  "id": "id",
  "currency": "USD",
  "interval": "month",
  "notification_channel": {
    "recipients": [
      "string"
    ],
    "type": "email",
    "subject_prefix": "subject_prefix"
  },
  "object": "organization.spend_alert",
  "threshold_amount": 0
}

Update organization spend alert

admin.organization.spend_alerts.update(alert_id, **kwargs) -> OrganizationSpendAlert

post /organization/spend_alerts/{alert_id}

Update organization spend alert

Parameters

  • alert_id: String

  • currency: :USD

    The currency for the threshold amount.

    • :USD
  • interval: :month

    The time interval for evaluating spend against the threshold.

    • :month
  • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

    Email notification settings for a spend alert.

    • recipients: Array[String]

      Email addresses that receive the spend alert notification.

    • type: :email

      The notification channel type. Currently only email is supported.

      • :email
    • subject_prefix: String

      Optional subject prefix for alert emails.

  • threshold_amount: Integer

    The alert threshold amount, in cents.

Returns

  • class OrganizationSpendAlert

    Represents a spend alert configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"organization.spend_alert"

      The object type, which is always organization.spend_alert.

      • :"organization.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_spend_alert = openai.admin.organization.spend_alerts.update(
  "alert_id",
  currency: :USD,
  interval: :month,
  notification_channel: {recipients: ["string"], type: :email},
  threshold_amount: 0
)

puts(organization_spend_alert)

Response

{
  "id": "id",
  "currency": "USD",
  "interval": "month",
  "notification_channel": {
    "recipients": [
      "string"
    ],
    "type": "email",
    "subject_prefix": "subject_prefix"
  },
  "object": "organization.spend_alert",
  "threshold_amount": 0
}

Delete organization spend alert

admin.organization.spend_alerts.delete(alert_id) -> OrganizationSpendAlertDeleted

delete /organization/spend_alerts/{alert_id}

Delete organization spend alert

Parameters

  • alert_id: String

Returns

  • class OrganizationSpendAlertDeleted

    Confirmation payload returned after deleting an organization spend alert.

    • id: String

      The deleted spend alert ID.

    • deleted: bool

      Whether the spend alert was deleted.

    • object: :"organization.spend_alert.deleted"

      Always organization.spend_alert.deleted.

      • :"organization.spend_alert.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

organization_spend_alert_deleted = openai.admin.organization.spend_alerts.delete("alert_id")

puts(organization_spend_alert_deleted)

Response

{
  "id": "id",
  "deleted": true,
  "object": "organization.spend_alert.deleted"
}

Domain Types

Organization Spend Alert

  • class OrganizationSpendAlert

    Represents a spend alert configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"organization.spend_alert"

      The object type, which is always organization.spend_alert.

      • :"organization.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Organization Spend Alert Deleted

  • class OrganizationSpendAlertDeleted

    Confirmation payload returned after deleting an organization spend alert.

    • id: String

      The deleted spend alert ID.

    • deleted: bool

      Whether the spend alert was deleted.

    • object: :"organization.spend_alert.deleted"

      Always organization.spend_alert.deleted.

      • :"organization.spend_alert.deleted"

Certificates

List organization certificates

admin.organization.certificates.list(**kwargs) -> ConversationCursorPage<CertificateListResponse>

get /organization/certificates

List organization certificates

Parameters

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

  • order: :asc | :desc

    Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

    • :asc

    • :desc

Returns

  • class CertificateListResponse

    Represents an individual certificate configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the organization level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.certificate"

      The object type, which is always organization.certificate.

      • :"organization.certificate"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.certificates.list

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.certificate"
    }
  ],
  "first_id": "cert_abc",
  "has_more": true,
  "last_id": "cert_abc",
  "object": "list"
}

Upload certificate

admin.organization.certificates.create(**kwargs) -> Certificate

post /organization/certificates

Upload certificate

Parameters

  • certificate: String

    The certificate content in PEM format

  • name: String

    An optional name for the certificate

Returns

  • class Certificate

    Represents an individual certificate uploaded to the organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • certificate_details: CertificateDetails{ content, expires_at, valid_at}

      • content: String

        The content of the certificate in PEM format.

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :certificate | :"organization.certificate" | :"organization.project.certificate"

      The object type.

      • If creating, updating, or getting a specific certificate, the object type is certificate.

      • If listing, activating, or deactivating certificates for the organization, the object type is organization.certificate.

      • If listing, activating, or deactivating certificates for a project, the object type is organization.project.certificate.

      • :certificate

      • :"organization.certificate"

      • :"organization.project.certificate"

    • active: bool

      Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

certificate = openai.admin.organization.certificates.create(certificate: "certificate")

puts(certificate)

Response

{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}

Get certificate

admin.organization.certificates.retrieve(certificate_id, **kwargs) -> Certificate

get /organization/certificates/{certificate_id}

Get certificate

Parameters

  • certificate_id: String

  • include: Array[:content]

    A list of additional fields to include in the response. Currently the only supported value is content to fetch the PEM content of the certificate.

    • :content

Returns

  • class Certificate

    Represents an individual certificate uploaded to the organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • certificate_details: CertificateDetails{ content, expires_at, valid_at}

      • content: String

        The content of the certificate in PEM format.

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :certificate | :"organization.certificate" | :"organization.project.certificate"

      The object type.

      • If creating, updating, or getting a specific certificate, the object type is certificate.

      • If listing, activating, or deactivating certificates for the organization, the object type is organization.certificate.

      • If listing, activating, or deactivating certificates for a project, the object type is organization.project.certificate.

      • :certificate

      • :"organization.certificate"

      • :"organization.project.certificate"

    • active: bool

      Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

certificate = openai.admin.organization.certificates.retrieve("certificate_id")

puts(certificate)

Response

{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}

Modify certificate

admin.organization.certificates.update(certificate_id, **kwargs) -> Certificate

post /organization/certificates/{certificate_id}

Modify certificate

Parameters

  • certificate_id: String

  • name: String

    The updated name for the certificate

Returns

  • class Certificate

    Represents an individual certificate uploaded to the organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • certificate_details: CertificateDetails{ content, expires_at, valid_at}

      • content: String

        The content of the certificate in PEM format.

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :certificate | :"organization.certificate" | :"organization.project.certificate"

      The object type.

      • If creating, updating, or getting a specific certificate, the object type is certificate.

      • If listing, activating, or deactivating certificates for the organization, the object type is organization.certificate.

      • If listing, activating, or deactivating certificates for a project, the object type is organization.project.certificate.

      • :certificate

      • :"organization.certificate"

      • :"organization.project.certificate"

    • active: bool

      Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

certificate = openai.admin.organization.certificates.update("certificate_id")

puts(certificate)

Response

{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}

Delete certificate

admin.organization.certificates.delete(certificate_id) -> CertificateDeleteResponse

delete /organization/certificates/{certificate_id}

Delete certificate

Parameters

  • certificate_id: String

Returns

  • class CertificateDeleteResponse

    • id: String

      The ID of the certificate that was deleted.

    • object: :"certificate.deleted"

      The object type, must be certificate.deleted.

      • :"certificate.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

certificate = openai.admin.organization.certificates.delete("certificate_id")

puts(certificate)

Response

{
  "id": "id",
  "object": "certificate.deleted"
}

Activate certificates for organization

admin.organization.certificates.activate(**kwargs) -> Page<CertificateActivateResponse>

post /organization/certificates/activate

Activate certificates for organization

Parameters

  • certificate_ids: Array[String]

Returns

  • class CertificateActivateResponse

    Represents an individual certificate configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the organization level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.certificate"

      The object type, which is always organization.certificate.

      • :"organization.certificate"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.certificates.activate(certificate_ids: ["cert_abc"])

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.certificate"
    }
  ],
  "object": "organization.certificate.activation"
}

Deactivate certificates for organization

admin.organization.certificates.deactivate(**kwargs) -> Page<CertificateDeactivateResponse>

post /organization/certificates/deactivate

Deactivate certificates for organization

Parameters

  • certificate_ids: Array[String]

Returns

  • class CertificateDeactivateResponse

    Represents an individual certificate configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the organization level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.certificate"

      The object type, which is always organization.certificate.

      • :"organization.certificate"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.certificates.deactivate(certificate_ids: ["cert_abc"])

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.certificate"
    }
  ],
  "object": "organization.certificate.deactivation"
}

Domain Types

Certificate

  • class Certificate

    Represents an individual certificate uploaded to the organization.

    • id: String

      The identifier, which can be referenced in API endpoints

    • certificate_details: CertificateDetails{ content, expires_at, valid_at}

      • content: String

        The content of the certificate in PEM format.

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :certificate | :"organization.certificate" | :"organization.project.certificate"

      The object type.

      • If creating, updating, or getting a specific certificate, the object type is certificate.

      • If listing, activating, or deactivating certificates for the organization, the object type is organization.certificate.

      • If listing, activating, or deactivating certificates for a project, the object type is organization.project.certificate.

      • :certificate

      • :"organization.certificate"

      • :"organization.project.certificate"

    • active: bool

      Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

Certificate List Response

  • class CertificateListResponse

    Represents an individual certificate configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the organization level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.certificate"

      The object type, which is always organization.certificate.

      • :"organization.certificate"

Certificate Delete Response

  • class CertificateDeleteResponse

    • id: String

      The ID of the certificate that was deleted.

    • object: :"certificate.deleted"

      The object type, must be certificate.deleted.

      • :"certificate.deleted"

Certificate Activate Response

  • class CertificateActivateResponse

    Represents an individual certificate configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the organization level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.certificate"

      The object type, which is always organization.certificate.

      • :"organization.certificate"

Certificate Deactivate Response

  • class CertificateDeactivateResponse

    Represents an individual certificate configured at the organization level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the organization level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.certificate"

      The object type, which is always organization.certificate.

      • :"organization.certificate"

Projects

List projects

admin.organization.projects.list(**kwargs) -> ConversationCursorPage<Project>

get /organization/projects

List projects

Parameters

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • include_archived: bool

    If true returns all projects including those that have been archived. Archived projects are not included by default.

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

Returns

  • class Project

    Represents an individual project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the project was created.

    • object: :"organization.project"

      The object type, which is always organization.project

      • :"organization.project"
    • archived_at: Integer

      The Unix timestamp (in seconds) of when the project was archived or null.

    • external_key_id: String

      The external key associated with the project.

    • name: String

      The name of the project. This appears in reporting.

    • status: String

      active or archived

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.list

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "object": "organization.project",
      "archived_at": 0,
      "external_key_id": "external_key_id",
      "name": "name",
      "status": "status"
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Create project

admin.organization.projects.create(**kwargs) -> Project

post /organization/projects

Create project

Parameters

  • name: String

    The friendly name of the project, this name appears in reports.

  • external_key_id: String

    External key ID to associate with the project.

  • geography: String

    Create the project with the specified data residency region. Your organization must have access to Data residency functionality in order to use. See data residency controls to review the functionality and limitations of setting this field.

Returns

  • class Project

    Represents an individual project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the project was created.

    • object: :"organization.project"

      The object type, which is always organization.project

      • :"organization.project"
    • archived_at: Integer

      The Unix timestamp (in seconds) of when the project was archived or null.

    • external_key_id: String

      The external key associated with the project.

    • name: String

      The name of the project. This appears in reporting.

    • status: String

      active or archived

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project = openai.admin.organization.projects.create(name: "name")

puts(project)

Response

{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}

Retrieve project

admin.organization.projects.retrieve(project_id) -> Project

get /organization/projects/{project_id}

Retrieve project

Parameters

  • project_id: String

Returns

  • class Project

    Represents an individual project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the project was created.

    • object: :"organization.project"

      The object type, which is always organization.project

      • :"organization.project"
    • archived_at: Integer

      The Unix timestamp (in seconds) of when the project was archived or null.

    • external_key_id: String

      The external key associated with the project.

    • name: String

      The name of the project. This appears in reporting.

    • status: String

      active or archived

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project = openai.admin.organization.projects.retrieve("project_id")

puts(project)

Response

{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}

Modify project

admin.organization.projects.update(project_id, **kwargs) -> Project

post /organization/projects/{project_id}

Modify project

Parameters

  • project_id: String

  • external_key_id: String

    External key ID to associate with the project.

  • geography: String

    Geography for the project.

  • name: String

    The updated name of the project, this name appears in reports.

Returns

  • class Project

    Represents an individual project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the project was created.

    • object: :"organization.project"

      The object type, which is always organization.project

      • :"organization.project"
    • archived_at: Integer

      The Unix timestamp (in seconds) of when the project was archived or null.

    • external_key_id: String

      The external key associated with the project.

    • name: String

      The name of the project. This appears in reporting.

    • status: String

      active or archived

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project = openai.admin.organization.projects.update("project_id")

puts(project)

Response

{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}

Archive project

admin.organization.projects.archive(project_id) -> Project

post /organization/projects/{project_id}/archive

Archive project

Parameters

  • project_id: String

Returns

  • class Project

    Represents an individual project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the project was created.

    • object: :"organization.project"

      The object type, which is always organization.project

      • :"organization.project"
    • archived_at: Integer

      The Unix timestamp (in seconds) of when the project was archived or null.

    • external_key_id: String

      The external key associated with the project.

    • name: String

      The name of the project. This appears in reporting.

    • status: String

      active or archived

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project = openai.admin.organization.projects.archive("project_id")

puts(project)

Response

{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}

Domain Types

Project

  • class Project

    Represents an individual project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the project was created.

    • object: :"organization.project"

      The object type, which is always organization.project

      • :"organization.project"
    • archived_at: Integer

      The Unix timestamp (in seconds) of when the project was archived or null.

    • external_key_id: String

      The external key associated with the project.

    • name: String

      The name of the project. This appears in reporting.

    • status: String

      active or archived

Users

List project users

admin.organization.projects.users.list(project_id, **kwargs) -> ConversationCursorPage<ProjectUser>

get /organization/projects/{project_id}/users

List project users

Parameters

  • project_id: String

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

Returns

  • class ProjectUser

    Represents an individual user in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the project was added.

    • object: :"organization.project.user"

      The object type, which is always organization.project.user

      • :"organization.project.user"
    • role: String

      owner or member

    • email: String

      The email address of the user

    • name: String

      The name of the user

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.users.list("project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "added_at": 0,
      "object": "organization.project.user",
      "role": "role",
      "email": "email",
      "name": "name"
    }
  ],
  "has_more": true,
  "object": "object",
  "first_id": "first_id",
  "last_id": "last_id"
}

Create project user

admin.organization.projects.users.create(project_id, **kwargs) -> ProjectUser

post /organization/projects/{project_id}/users

Create project user

Parameters

  • project_id: String

  • role: String

    owner or member

  • email: String

    Email of the user to add.

  • user_id: String

    The ID of the user.

Returns

  • class ProjectUser

    Represents an individual user in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the project was added.

    • object: :"organization.project.user"

      The object type, which is always organization.project.user

      • :"organization.project.user"
    • role: String

      owner or member

    • email: String

      The email address of the user

    • name: String

      The name of the user

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_user = openai.admin.organization.projects.users.create("project_id", role: "role")

puts(project_user)

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}

Retrieve project user

admin.organization.projects.users.retrieve(user_id, **kwargs) -> ProjectUser

get /organization/projects/{project_id}/users/{user_id}

Retrieve project user

Parameters

  • project_id: String

  • user_id: String

Returns

  • class ProjectUser

    Represents an individual user in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the project was added.

    • object: :"organization.project.user"

      The object type, which is always organization.project.user

      • :"organization.project.user"
    • role: String

      owner or member

    • email: String

      The email address of the user

    • name: String

      The name of the user

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_user = openai.admin.organization.projects.users.retrieve("user_id", project_id: "project_id")

puts(project_user)

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}

Modify project user

admin.organization.projects.users.update(user_id, **kwargs) -> ProjectUser

post /organization/projects/{project_id}/users/{user_id}

Modify project user

Parameters

  • project_id: String

  • user_id: String

  • role: String

    owner or member

Returns

  • class ProjectUser

    Represents an individual user in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the project was added.

    • object: :"organization.project.user"

      The object type, which is always organization.project.user

      • :"organization.project.user"
    • role: String

      owner or member

    • email: String

      The email address of the user

    • name: String

      The name of the user

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_user = openai.admin.organization.projects.users.update("user_id", project_id: "project_id")

puts(project_user)

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}

Delete project user

admin.organization.projects.users.delete(user_id, **kwargs) -> UserDeleteResponse

delete /organization/projects/{project_id}/users/{user_id}

Delete project user

Parameters

  • project_id: String

  • user_id: String

Returns

  • class UserDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.project.user.deleted"

      • :"organization.project.user.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

user = openai.admin.organization.projects.users.delete("user_id", project_id: "project_id")

puts(user)

Response

{
  "id": "id",
  "deleted": true,
  "object": "organization.project.user.deleted"
}

Domain Types

Project User

  • class ProjectUser

    Represents an individual user in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • added_at: Integer

      The Unix timestamp (in seconds) of when the project was added.

    • object: :"organization.project.user"

      The object type, which is always organization.project.user

      • :"organization.project.user"
    • role: String

      owner or member

    • email: String

      The email address of the user

    • name: String

      The name of the user

User Delete Response

  • class UserDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.project.user.deleted"

      • :"organization.project.user.deleted"

Roles

List project user role assignments

admin.organization.projects.users.roles.list(user_id, **kwargs) -> NextCursorPage<RoleListResponse>

get /projects/{project_id}/users/{user_id}/roles

List project user role assignments

Parameters

  • project_id: String

  • user_id: String

  • after: String

    Cursor for pagination. Provide the value from the previous response's next field to continue listing project roles.

  • limit: Integer

    A limit on the number of project role assignments to return.

  • order: :asc | :desc

    Sort order for the returned project roles.

    • :asc

    • :desc

Returns

  • class RoleListResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.users.roles.list("user_id", project_id: "project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "assignment_sources": [
        {
          "principal_id": "principal_id",
          "principal_type": "principal_type"
        }
      ],
      "created_at": 0,
      "created_by": "created_by",
      "created_by_user_obj": {
        "foo": "bar"
      },
      "description": "description",
      "metadata": {
        "foo": "bar"
      },
      "name": "name",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type",
      "updated_at": 0
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Assign project role to user

admin.organization.projects.users.roles.create(user_id, **kwargs) -> RoleCreateResponse

post /projects/{project_id}/users/{user_id}/roles

Assign project role to user

Parameters

  • project_id: String

  • user_id: String

  • role_id: String

    Identifier of the role to assign.

Returns

  • class RoleCreateResponse

    Role assignment linking a user to a role.

    • object: :"user.role"

      Always user.role.

      • :"user.role"
    • role: Role

      Details about a role that can be assigned through the public Roles API.

      • id: String

        Identifier for the role.

      • description: String

        Optional description of the role.

      • name: String

        Unique name for the role.

      • object: :role

        Always role.

        • :role
      • permissions: Array[String]

        Permissions granted by the role.

      • predefined_role: bool

        Whether the role is predefined and managed by OpenAI.

      • resource_type: String

        Resource type the role is bound to (for example api.organization or api.project).

    • user: OrganizationUser

      Represents an individual user within an organization.

      • id: String

        The identifier, which can be referenced in API endpoints

      • added_at: Integer

        The Unix timestamp (in seconds) of when the user was added.

      • object: :"organization.user"

        The object type, which is always organization.user

        • :"organization.user"
      • api_key_last_used_at: Integer

        The Unix timestamp (in seconds) of the user's last API key usage.

      • created: Integer

        The Unix timestamp (in seconds) of when the user was created.

      • developer_persona: String

        The developer persona metadata for the user.

      • email: String

        The email address of the user

      • is_default: bool

        Whether this is the organization's default user.

      • is_scale_tier_authorized_purchaser: bool

        Whether the user is an authorized purchaser for Scale Tier.

      • is_scim_managed: bool

        Whether the user is managed through SCIM.

      • is_service_account: bool

        Whether the user is a service account.

      • name: String

        The name of the user

      • projects: Projects{ data, object}

        Projects associated with the user, if included.

        • data: Array[Data{ id, name, role}]

          • id: String

          • name: String

          • role: String

        • object: :list

          • :list
      • role: String

        owner or reader

      • technical_level: String

        The technical level metadata for the user.

      • user: User{ id, object, banned, 5 more}

        Nested user details.

        • id: String

        • object: :user

          • :user
        • banned: bool

        • banned_at: Integer

        • email: String

        • enabled: bool

        • name: String

        • picture: String

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.users.roles.create(
  "user_id",
  project_id: "project_id",
  role_id: "role_id"
)

puts(role)

Response

{
  "object": "user.role",
  "role": {
    "id": "id",
    "description": "description",
    "name": "name",
    "object": "role",
    "permissions": [
      "string"
    ],
    "predefined_role": true,
    "resource_type": "resource_type"
  },
  "user": {
    "id": "id",
    "added_at": 0,
    "object": "organization.user",
    "api_key_last_used_at": 0,
    "created": 0,
    "developer_persona": "developer_persona",
    "email": "email",
    "is_default": true,
    "is_scale_tier_authorized_purchaser": true,
    "is_scim_managed": true,
    "is_service_account": true,
    "name": "name",
    "projects": {
      "data": [
        {
          "id": "id",
          "name": "name",
          "role": "role"
        }
      ],
      "object": "list"
    },
    "role": "role",
    "technical_level": "technical_level",
    "user": {
      "id": "id",
      "object": "user",
      "banned": true,
      "banned_at": 0,
      "email": "email",
      "enabled": true,
      "name": "name",
      "picture": "picture"
    }
  }
}

Retrieve project user role

admin.organization.projects.users.roles.retrieve(role_id, **kwargs) -> RoleRetrieveResponse

get /projects/{project_id}/users/{user_id}/roles/{role_id}

Retrieve project user role

Parameters

  • project_id: String

  • user_id: String

  • role_id: String

Returns

  • class RoleRetrieveResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.users.roles.retrieve(
  "role_id",
  project_id: "project_id",
  user_id: "user_id"
)

puts(role)

Response

{
  "id": "id",
  "assignment_sources": [
    {
      "principal_id": "principal_id",
      "principal_type": "principal_type"
    }
  ],
  "created_at": 0,
  "created_by": "created_by",
  "created_by_user_obj": {
    "foo": "bar"
  },
  "description": "description",
  "metadata": {
    "foo": "bar"
  },
  "name": "name",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type",
  "updated_at": 0
}

Unassign project role from user

admin.organization.projects.users.roles.delete(role_id, **kwargs) -> RoleDeleteResponse

delete /projects/{project_id}/users/{user_id}/roles/{role_id}

Unassign project role from user

Parameters

  • project_id: String

  • user_id: String

  • role_id: String

Returns

  • class RoleDeleteResponse

    Confirmation payload returned after unassigning a role.

    • deleted: bool

      Whether the assignment was removed.

    • object: String

      Identifier for the deleted assignment, such as group.role.deleted or user.role.deleted.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.users.roles.delete(
  "role_id",
  project_id: "project_id",
  user_id: "user_id"
)

puts(role)

Response

{
  "deleted": true,
  "object": "object"
}

Domain Types

Role List Response

  • class RoleListResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Role Create Response

  • class RoleCreateResponse

    Role assignment linking a user to a role.

    • object: :"user.role"

      Always user.role.

      • :"user.role"
    • role: Role

      Details about a role that can be assigned through the public Roles API.

      • id: String

        Identifier for the role.

      • description: String

        Optional description of the role.

      • name: String

        Unique name for the role.

      • object: :role

        Always role.

        • :role
      • permissions: Array[String]

        Permissions granted by the role.

      • predefined_role: bool

        Whether the role is predefined and managed by OpenAI.

      • resource_type: String

        Resource type the role is bound to (for example api.organization or api.project).

    • user: OrganizationUser

      Represents an individual user within an organization.

      • id: String

        The identifier, which can be referenced in API endpoints

      • added_at: Integer

        The Unix timestamp (in seconds) of when the user was added.

      • object: :"organization.user"

        The object type, which is always organization.user

        • :"organization.user"
      • api_key_last_used_at: Integer

        The Unix timestamp (in seconds) of the user's last API key usage.

      • created: Integer

        The Unix timestamp (in seconds) of when the user was created.

      • developer_persona: String

        The developer persona metadata for the user.

      • email: String

        The email address of the user

      • is_default: bool

        Whether this is the organization's default user.

      • is_scale_tier_authorized_purchaser: bool

        Whether the user is an authorized purchaser for Scale Tier.

      • is_scim_managed: bool

        Whether the user is managed through SCIM.

      • is_service_account: bool

        Whether the user is a service account.

      • name: String

        The name of the user

      • projects: Projects{ data, object}

        Projects associated with the user, if included.

        • data: Array[Data{ id, name, role}]

          • id: String

          • name: String

          • role: String

        • object: :list

          • :list
      • role: String

        owner or reader

      • technical_level: String

        The technical level metadata for the user.

      • user: User{ id, object, banned, 5 more}

        Nested user details.

        • id: String

        • object: :user

          • :user
        • banned: bool

        • banned_at: Integer

        • email: String

        • enabled: bool

        • name: String

        • picture: String

Role Retrieve Response

  • class RoleRetrieveResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Role Delete Response

  • class RoleDeleteResponse

    Confirmation payload returned after unassigning a role.

    • deleted: bool

      Whether the assignment was removed.

    • object: String

      Identifier for the deleted assignment, such as group.role.deleted or user.role.deleted.

Service Accounts

List project service accounts

admin.organization.projects.service_accounts.list(project_id, **kwargs) -> ConversationCursorPage<ProjectServiceAccount>

get /organization/projects/{project_id}/service_accounts

List project service accounts

Parameters

  • project_id: String

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

Returns

  • class ProjectServiceAccount

    Represents an individual service account in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the service account was created

    • name: String

      The name of the service account

    • object: :"organization.project.service_account"

      The object type, which is always organization.project.service_account

      • :"organization.project.service_account"
    • role: :owner | :member

      owner or member

      • :owner

      • :member

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.service_accounts.list("project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "name": "name",
      "object": "organization.project.service_account",
      "role": "owner"
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Create project service account

admin.organization.projects.service_accounts.create(project_id, **kwargs) -> ServiceAccountCreateResponse

post /organization/projects/{project_id}/service_accounts

Create project service account

Parameters

  • project_id: String

  • name: String

    The name of the service account being created.

Returns

  • class ServiceAccountCreateResponse

    • id: String

    • api_key: APIKey{ id, created_at, name, 2 more}

      • id: String

      • created_at: Integer

      • name: String

      • object: :"organization.project.service_account.api_key"

        The object type, which is always organization.project.service_account.api_key

        • :"organization.project.service_account.api_key"
      • value: String

    • created_at: Integer

    • name: String

    • object: :"organization.project.service_account"

      • :"organization.project.service_account"
    • role: :member

      Service accounts can only have one role of type member

      • :member

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

service_account = openai.admin.organization.projects.service_accounts.create("project_id", name: "name")

puts(service_account)

Response

{
  "id": "id",
  "api_key": {
    "id": "id",
    "created_at": 0,
    "name": "name",
    "object": "organization.project.service_account.api_key",
    "value": "value"
  },
  "created_at": 0,
  "name": "name",
  "object": "organization.project.service_account",
  "role": "member"
}

Retrieve project service account

admin.organization.projects.service_accounts.retrieve(service_account_id, **kwargs) -> ProjectServiceAccount

get /organization/projects/{project_id}/service_accounts/{service_account_id}

Retrieve project service account

Parameters

  • project_id: String

  • service_account_id: String

Returns

  • class ProjectServiceAccount

    Represents an individual service account in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the service account was created

    • name: String

      The name of the service account

    • object: :"organization.project.service_account"

      The object type, which is always organization.project.service_account

      • :"organization.project.service_account"
    • role: :owner | :member

      owner or member

      • :owner

      • :member

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_service_account = openai.admin.organization.projects.service_accounts.retrieve(
  "service_account_id",
  project_id: "project_id"
)

puts(project_service_account)

Response

{
  "id": "id",
  "created_at": 0,
  "name": "name",
  "object": "organization.project.service_account",
  "role": "owner"
}

Update project service account

admin.organization.projects.service_accounts.update(service_account_id, **kwargs) -> ProjectServiceAccount

post /organization/projects/{project_id}/service_accounts/{service_account_id}

Update project service account

Parameters

  • project_id: String

  • service_account_id: String

  • name: String

    The updated service account name.

  • role: :member | :owner

    The updated service account role.

    • :member

    • :owner

Returns

  • class ProjectServiceAccount

    Represents an individual service account in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the service account was created

    • name: String

      The name of the service account

    • object: :"organization.project.service_account"

      The object type, which is always organization.project.service_account

      • :"organization.project.service_account"
    • role: :owner | :member

      owner or member

      • :owner

      • :member

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_service_account = openai.admin.organization.projects.service_accounts.update("service_account_id", project_id: "project_id")

puts(project_service_account)

Response

{
  "id": "id",
  "created_at": 0,
  "name": "name",
  "object": "organization.project.service_account",
  "role": "owner"
}

Delete project service account

admin.organization.projects.service_accounts.delete(service_account_id, **kwargs) -> ServiceAccountDeleteResponse

delete /organization/projects/{project_id}/service_accounts/{service_account_id}

Delete project service account

Parameters

  • project_id: String

  • service_account_id: String

Returns

  • class ServiceAccountDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.project.service_account.deleted"

      • :"organization.project.service_account.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

service_account = openai.admin.organization.projects.service_accounts.delete("service_account_id", project_id: "project_id")

puts(service_account)

Response

{
  "id": "id",
  "deleted": true,
  "object": "organization.project.service_account.deleted"
}

Domain Types

Project Service Account

  • class ProjectServiceAccount

    Represents an individual service account in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the service account was created

    • name: String

      The name of the service account

    • object: :"organization.project.service_account"

      The object type, which is always organization.project.service_account

      • :"organization.project.service_account"
    • role: :owner | :member

      owner or member

      • :owner

      • :member

Service Account Create Response

  • class ServiceAccountCreateResponse

    • id: String

    • api_key: APIKey{ id, created_at, name, 2 more}

      • id: String

      • created_at: Integer

      • name: String

      • object: :"organization.project.service_account.api_key"

        The object type, which is always organization.project.service_account.api_key

        • :"organization.project.service_account.api_key"
      • value: String

    • created_at: Integer

    • name: String

    • object: :"organization.project.service_account"

      • :"organization.project.service_account"
    • role: :member

      Service accounts can only have one role of type member

      • :member

Service Account Delete Response

  • class ServiceAccountDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.project.service_account.deleted"

      • :"organization.project.service_account.deleted"

API Keys

List project API keys

admin.organization.projects.api_keys.list(project_id, **kwargs) -> ConversationCursorPage<ProjectAPIKey>

get /organization/projects/{project_id}/api_keys

List project API keys

Parameters

  • project_id: String

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

Returns

  • class ProjectAPIKey

    Represents an individual API key in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the API key was created

    • last_used_at: Integer

      The Unix timestamp (in seconds) of when the API key was last used.

    • name: String

      The name of the API key

    • object: :"organization.project.api_key"

      The object type, which is always organization.project.api_key

      • :"organization.project.api_key"
    • owner: Owner{ service_account, type, user}

      • service_account: ServiceAccount{ id, created_at, name, role}

        The service account that owns a project API key.

        • id: String

          The identifier, which can be referenced in API endpoints

        • created_at: Integer

          The Unix timestamp (in seconds) of when the service account was created.

        • name: String

          The name of the service account.

        • role: String

          The service account's project role.

      • type: :user | :service_account

        user or service_account

        • :user

        • :service_account

      • user: User{ id, created_at, email, 2 more}

        The user that owns a project API key.

        • id: String

          The identifier, which can be referenced in API endpoints

        • created_at: Integer

          The Unix timestamp (in seconds) of when the user was created.

        • email: String

          The email address of the user.

        • name: String

          The name of the user.

        • role: String

          The user's project role.

    • redacted_value: String

      The redacted value of the API key

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.api_keys.list("project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "last_used_at": 0,
      "name": "name",
      "object": "organization.project.api_key",
      "owner": {
        "service_account": {
          "id": "id",
          "created_at": 0,
          "name": "name",
          "role": "role"
        },
        "type": "user",
        "user": {
          "id": "id",
          "created_at": 0,
          "email": "email",
          "name": "name",
          "role": "role"
        }
      },
      "redacted_value": "redacted_value"
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Retrieve project API key

admin.organization.projects.api_keys.retrieve(api_key_id, **kwargs) -> ProjectAPIKey

get /organization/projects/{project_id}/api_keys/{api_key_id}

Retrieve project API key

Parameters

  • project_id: String

  • api_key_id: String

Returns

  • class ProjectAPIKey

    Represents an individual API key in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the API key was created

    • last_used_at: Integer

      The Unix timestamp (in seconds) of when the API key was last used.

    • name: String

      The name of the API key

    • object: :"organization.project.api_key"

      The object type, which is always organization.project.api_key

      • :"organization.project.api_key"
    • owner: Owner{ service_account, type, user}

      • service_account: ServiceAccount{ id, created_at, name, role}

        The service account that owns a project API key.

        • id: String

          The identifier, which can be referenced in API endpoints

        • created_at: Integer

          The Unix timestamp (in seconds) of when the service account was created.

        • name: String

          The name of the service account.

        • role: String

          The service account's project role.

      • type: :user | :service_account

        user or service_account

        • :user

        • :service_account

      • user: User{ id, created_at, email, 2 more}

        The user that owns a project API key.

        • id: String

          The identifier, which can be referenced in API endpoints

        • created_at: Integer

          The Unix timestamp (in seconds) of when the user was created.

        • email: String

          The email address of the user.

        • name: String

          The name of the user.

        • role: String

          The user's project role.

    • redacted_value: String

      The redacted value of the API key

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_api_key = openai.admin.organization.projects.api_keys.retrieve("api_key_id", project_id: "project_id")

puts(project_api_key)

Response

{
  "id": "id",
  "created_at": 0,
  "last_used_at": 0,
  "name": "name",
  "object": "organization.project.api_key",
  "owner": {
    "service_account": {
      "id": "id",
      "created_at": 0,
      "name": "name",
      "role": "role"
    },
    "type": "user",
    "user": {
      "id": "id",
      "created_at": 0,
      "email": "email",
      "name": "name",
      "role": "role"
    }
  },
  "redacted_value": "redacted_value"
}

Delete project API key

admin.organization.projects.api_keys.delete(api_key_id, **kwargs) -> APIKeyDeleteResponse

delete /organization/projects/{project_id}/api_keys/{api_key_id}

Delete project API key

Parameters

  • project_id: String

  • api_key_id: String

Returns

  • class APIKeyDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.project.api_key.deleted"

      • :"organization.project.api_key.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

api_key = openai.admin.organization.projects.api_keys.delete("api_key_id", project_id: "project_id")

puts(api_key)

Response

{
  "id": "id",
  "deleted": true,
  "object": "organization.project.api_key.deleted"
}

Domain Types

Project API Key

  • class ProjectAPIKey

    Represents an individual API key in a project.

    • id: String

      The identifier, which can be referenced in API endpoints

    • created_at: Integer

      The Unix timestamp (in seconds) of when the API key was created

    • last_used_at: Integer

      The Unix timestamp (in seconds) of when the API key was last used.

    • name: String

      The name of the API key

    • object: :"organization.project.api_key"

      The object type, which is always organization.project.api_key

      • :"organization.project.api_key"
    • owner: Owner{ service_account, type, user}

      • service_account: ServiceAccount{ id, created_at, name, role}

        The service account that owns a project API key.

        • id: String

          The identifier, which can be referenced in API endpoints

        • created_at: Integer

          The Unix timestamp (in seconds) of when the service account was created.

        • name: String

          The name of the service account.

        • role: String

          The service account's project role.

      • type: :user | :service_account

        user or service_account

        • :user

        • :service_account

      • user: User{ id, created_at, email, 2 more}

        The user that owns a project API key.

        • id: String

          The identifier, which can be referenced in API endpoints

        • created_at: Integer

          The Unix timestamp (in seconds) of when the user was created.

        • email: String

          The email address of the user.

        • name: String

          The name of the user.

        • role: String

          The user's project role.

    • redacted_value: String

      The redacted value of the API key

API Key Delete Response

  • class APIKeyDeleteResponse

    • id: String

    • deleted: bool

    • object: :"organization.project.api_key.deleted"

      • :"organization.project.api_key.deleted"

Rate Limits

List project rate limits

admin.organization.projects.rate_limits.list_rate_limits(project_id, **kwargs) -> ConversationCursorPage<ProjectRateLimit>

get /organization/projects/{project_id}/rate_limits

List project rate limits

Parameters

  • project_id: String

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • before: String

    A cursor for use in pagination. before is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, beginning with obj_foo, your subsequent call can include before=obj_foo in order to fetch the previous page of the list.

  • limit: Integer

    A limit on the number of objects to be returned. The default is 100.

Returns

  • class ProjectRateLimit

    Represents a project rate limit config.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • max_requests_per_1_minute: Integer

      The maximum requests per minute.

    • max_tokens_per_1_minute: Integer

      The maximum tokens per minute.

    • model: String

      The model this rate limit applies to.

    • object: :"project.rate_limit"

      The object type, which is always project.rate_limit

      • :"project.rate_limit"
    • batch_1_day_max_input_tokens: Integer

      The maximum batch input tokens per day. Only present for relevant models.

    • max_audio_megabytes_per_1_minute: Integer

      The maximum audio megabytes per minute. Only present for relevant models.

    • max_images_per_1_minute: Integer

      The maximum images per minute. Only present for relevant models.

    • max_requests_per_1_day: Integer

      The maximum requests per day. Only present for relevant models.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.rate_limits.list_rate_limits("project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "max_requests_per_1_minute": 0,
      "max_tokens_per_1_minute": 0,
      "model": "model",
      "object": "project.rate_limit",
      "batch_1_day_max_input_tokens": 0,
      "max_audio_megabytes_per_1_minute": 0,
      "max_images_per_1_minute": 0,
      "max_requests_per_1_day": 0
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Modify project rate limit

admin.organization.projects.rate_limits.update_rate_limit(rate_limit_id, **kwargs) -> ProjectRateLimit

post /organization/projects/{project_id}/rate_limits/{rate_limit_id}

Modify project rate limit

Parameters

  • project_id: String

  • rate_limit_id: String

  • batch_1_day_max_input_tokens: Integer

    The maximum batch input tokens per day. Only relevant for certain models.

  • max_audio_megabytes_per_1_minute: Integer

    The maximum audio megabytes per minute. Only relevant for certain models.

  • max_images_per_1_minute: Integer

    The maximum images per minute. Only relevant for certain models.

  • max_requests_per_1_day: Integer

    The maximum requests per day. Only relevant for certain models.

  • max_requests_per_1_minute: Integer

    The maximum requests per minute.

  • max_tokens_per_1_minute: Integer

    The maximum tokens per minute.

Returns

  • class ProjectRateLimit

    Represents a project rate limit config.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • max_requests_per_1_minute: Integer

      The maximum requests per minute.

    • max_tokens_per_1_minute: Integer

      The maximum tokens per minute.

    • model: String

      The model this rate limit applies to.

    • object: :"project.rate_limit"

      The object type, which is always project.rate_limit

      • :"project.rate_limit"
    • batch_1_day_max_input_tokens: Integer

      The maximum batch input tokens per day. Only present for relevant models.

    • max_audio_megabytes_per_1_minute: Integer

      The maximum audio megabytes per minute. Only present for relevant models.

    • max_images_per_1_minute: Integer

      The maximum images per minute. Only present for relevant models.

    • max_requests_per_1_day: Integer

      The maximum requests per day. Only present for relevant models.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_rate_limit = openai.admin.organization.projects.rate_limits.update_rate_limit(
  "rate_limit_id",
  project_id: "project_id"
)

puts(project_rate_limit)

Response

{
  "id": "id",
  "max_requests_per_1_minute": 0,
  "max_tokens_per_1_minute": 0,
  "model": "model",
  "object": "project.rate_limit",
  "batch_1_day_max_input_tokens": 0,
  "max_audio_megabytes_per_1_minute": 0,
  "max_images_per_1_minute": 0,
  "max_requests_per_1_day": 0
}

Domain Types

Project Rate Limit

  • class ProjectRateLimit

    Represents a project rate limit config.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • max_requests_per_1_minute: Integer

      The maximum requests per minute.

    • max_tokens_per_1_minute: Integer

      The maximum tokens per minute.

    • model: String

      The model this rate limit applies to.

    • object: :"project.rate_limit"

      The object type, which is always project.rate_limit

      • :"project.rate_limit"
    • batch_1_day_max_input_tokens: Integer

      The maximum batch input tokens per day. Only present for relevant models.

    • max_audio_megabytes_per_1_minute: Integer

      The maximum audio megabytes per minute. Only present for relevant models.

    • max_images_per_1_minute: Integer

      The maximum images per minute. Only present for relevant models.

    • max_requests_per_1_day: Integer

      The maximum requests per day. Only present for relevant models.

Model Permissions

Retrieve project model permissions

admin.organization.projects.model_permissions.retrieve(project_id) -> ProjectModelPermissions

get /organization/projects/{project_id}/model_permissions

Retrieve project model permissions

Parameters

  • project_id: String

Returns

  • class ProjectModelPermissions

    Represents the model allowlist or denylist policy for a project.

    • mode: :allow_list | :deny_list

      Whether the project uses an allowlist or a denylist.

      • :allow_list

      • :deny_list

    • model_ids: Array[String]

      The model IDs included in the model permissions policy.

    • object: :"project.model_permissions"

      The object type, which is always project.model_permissions.

      • :"project.model_permissions"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_model_permissions = openai.admin.organization.projects.model_permissions.retrieve("project_id")

puts(project_model_permissions)

Response

{
  "mode": "allow_list",
  "model_ids": [
    "string"
  ],
  "object": "project.model_permissions"
}

Modify project model permissions

admin.organization.projects.model_permissions.update(project_id, **kwargs) -> ProjectModelPermissions

post /organization/projects/{project_id}/model_permissions

Modify project model permissions

Parameters

  • project_id: String

  • mode: :allow_list | :deny_list

    The model permissions mode to apply.

    • :allow_list

    • :deny_list

  • model_ids: Array[String]

    The model IDs included in this permissions policy.

Returns

  • class ProjectModelPermissions

    Represents the model allowlist or denylist policy for a project.

    • mode: :allow_list | :deny_list

      Whether the project uses an allowlist or a denylist.

      • :allow_list

      • :deny_list

    • model_ids: Array[String]

      The model IDs included in the model permissions policy.

    • object: :"project.model_permissions"

      The object type, which is always project.model_permissions.

      • :"project.model_permissions"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_model_permissions = openai.admin.organization.projects.model_permissions.update(
  "project_id",
  mode: :allow_list,
  model_ids: ["string"]
)

puts(project_model_permissions)

Response

{
  "mode": "allow_list",
  "model_ids": [
    "string"
  ],
  "object": "project.model_permissions"
}

Delete project model permissions

admin.organization.projects.model_permissions.delete(project_id) -> ProjectModelPermissionsDeleted

delete /organization/projects/{project_id}/model_permissions

Delete project model permissions

Parameters

  • project_id: String

Returns

  • class ProjectModelPermissionsDeleted

    Confirmation payload returned after deleting project model permissions.

    • deleted: bool

      Whether the project model permissions were deleted.

    • object: :"project.model_permissions.deleted"

      The object type, which is always project.model_permissions.deleted.

      • :"project.model_permissions.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_model_permissions_deleted = openai.admin.organization.projects.model_permissions.delete("project_id")

puts(project_model_permissions_deleted)

Response

{
  "deleted": true,
  "object": "project.model_permissions.deleted"
}

Domain Types

Project Model Permissions

  • class ProjectModelPermissions

    Represents the model allowlist or denylist policy for a project.

    • mode: :allow_list | :deny_list

      Whether the project uses an allowlist or a denylist.

      • :allow_list

      • :deny_list

    • model_ids: Array[String]

      The model IDs included in the model permissions policy.

    • object: :"project.model_permissions"

      The object type, which is always project.model_permissions.

      • :"project.model_permissions"

Project Model Permissions Deleted

  • class ProjectModelPermissionsDeleted

    Confirmation payload returned after deleting project model permissions.

    • deleted: bool

      Whether the project model permissions were deleted.

    • object: :"project.model_permissions.deleted"

      The object type, which is always project.model_permissions.deleted.

      • :"project.model_permissions.deleted"

Hosted Tool Permissions

Retrieve project hosted tool permissions

admin.organization.projects.hosted_tool_permissions.retrieve(project_id) -> ProjectHostedToolPermissions

get /organization/projects/{project_id}/hosted_tool_permissions

Retrieve project hosted tool permissions

Parameters

  • project_id: String

Returns

  • class ProjectHostedToolPermissions

    Represents hosted tool permissions for a project.

    • code_interpreter: CodeInterpreter{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • file_search: FileSearch{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • image_generation: ImageGeneration{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • mcp: Mcp{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • web_search: WebSearch{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_hosted_tool_permissions = openai.admin.organization.projects.hosted_tool_permissions.retrieve("project_id")

puts(project_hosted_tool_permissions)

Response

{
  "code_interpreter": {
    "enabled": true
  },
  "file_search": {
    "enabled": true
  },
  "image_generation": {
    "enabled": true
  },
  "mcp": {
    "enabled": true
  },
  "web_search": {
    "enabled": true
  }
}

Modify project hosted tool permissions

admin.organization.projects.hosted_tool_permissions.update(project_id, **kwargs) -> ProjectHostedToolPermissions

post /organization/projects/{project_id}/hosted_tool_permissions

Modify project hosted tool permissions

Parameters

  • project_id: String

  • code_interpreter: CodeInterpreter{ enabled}

    The code interpreter permission update.

    • enabled: bool

      Whether to enable the hosted tool for the project.

  • file_search: FileSearch{ enabled}

    The file search permission update.

    • enabled: bool

      Whether to enable the hosted tool for the project.

  • image_generation: ImageGeneration{ enabled}

    The image generation permission update.

    • enabled: bool

      Whether to enable the hosted tool for the project.

  • mcp: Mcp{ enabled}

    The MCP permission update.

    • enabled: bool

      Whether to enable the hosted tool for the project.

  • web_search: WebSearch{ enabled}

    The web search permission update.

    • enabled: bool

      Whether to enable the hosted tool for the project.

Returns

  • class ProjectHostedToolPermissions

    Represents hosted tool permissions for a project.

    • code_interpreter: CodeInterpreter{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • file_search: FileSearch{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • image_generation: ImageGeneration{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • mcp: Mcp{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • web_search: WebSearch{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_hosted_tool_permissions = openai.admin.organization.projects.hosted_tool_permissions.update("project_id")

puts(project_hosted_tool_permissions)

Response

{
  "code_interpreter": {
    "enabled": true
  },
  "file_search": {
    "enabled": true
  },
  "image_generation": {
    "enabled": true
  },
  "mcp": {
    "enabled": true
  },
  "web_search": {
    "enabled": true
  }
}

Domain Types

Project Hosted Tool Permissions

  • class ProjectHostedToolPermissions

    Represents hosted tool permissions for a project.

    • code_interpreter: CodeInterpreter{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • file_search: FileSearch{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • image_generation: ImageGeneration{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • mcp: Mcp{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

    • web_search: WebSearch{ enabled}

      Permission state for a single hosted tool on a project.

      • enabled: bool

        Whether the hosted tool is enabled for the project.

Groups

List project groups

admin.organization.projects.groups.list(project_id, **kwargs) -> NextCursorPage<ProjectGroup>

get /organization/projects/{project_id}/groups

List project groups

Parameters

  • project_id: String

  • after: String

    Cursor for pagination. Provide the ID of the last group from the previous response to fetch the next page.

  • limit: Integer

    A limit on the number of project groups to return. Defaults to 20.

  • order: :asc | :desc

    Sort order for the returned groups.

    • :asc

    • :desc

Returns

  • class ProjectGroup

    Details about a group's membership in a project.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was granted project access.

    • group_id: String

      Identifier of the group that has access to the project.

    • group_name: String

      Display name of the group.

    • group_type: :group | :tenant_group

      The type of the group.

      • :group

      • :tenant_group

    • object: :"project.group"

      Always project.group.

      • :"project.group"
    • project_id: String

      Identifier of the project.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.groups.list("project_id")

puts(page)

Response

{
  "data": [
    {
      "created_at": 0,
      "group_id": "group_id",
      "group_name": "group_name",
      "group_type": "group",
      "object": "project.group",
      "project_id": "project_id"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Add project group

admin.organization.projects.groups.create(project_id, **kwargs) -> ProjectGroup

post /organization/projects/{project_id}/groups

Add project group

Parameters

  • project_id: String

  • group_id: String

    Identifier of the group to add to the project.

  • role: String

    Identifier of the project role to grant to the group.

Returns

  • class ProjectGroup

    Details about a group's membership in a project.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was granted project access.

    • group_id: String

      Identifier of the group that has access to the project.

    • group_name: String

      Display name of the group.

    • group_type: :group | :tenant_group

      The type of the group.

      • :group

      • :tenant_group

    • object: :"project.group"

      Always project.group.

      • :"project.group"
    • project_id: String

      Identifier of the project.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_group = openai.admin.organization.projects.groups.create("project_id", group_id: "group_id", role: "role")

puts(project_group)

Response

{
  "created_at": 0,
  "group_id": "group_id",
  "group_name": "group_name",
  "group_type": "group",
  "object": "project.group",
  "project_id": "project_id"
}

Retrieve project group

admin.organization.projects.groups.retrieve(group_id, **kwargs) -> ProjectGroup

get /organization/projects/{project_id}/groups/{group_id}

Retrieve project group

Parameters

  • project_id: String

  • group_id: String

  • group_type: :group | :tenant_group

    The type of group to retrieve.

    • :group

    • :tenant_group

Returns

  • class ProjectGroup

    Details about a group's membership in a project.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was granted project access.

    • group_id: String

      Identifier of the group that has access to the project.

    • group_name: String

      Display name of the group.

    • group_type: :group | :tenant_group

      The type of the group.

      • :group

      • :tenant_group

    • object: :"project.group"

      Always project.group.

      • :"project.group"
    • project_id: String

      Identifier of the project.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_group = openai.admin.organization.projects.groups.retrieve("group_id", project_id: "project_id")

puts(project_group)

Response

{
  "created_at": 0,
  "group_id": "group_id",
  "group_name": "group_name",
  "group_type": "group",
  "object": "project.group",
  "project_id": "project_id"
}

Remove project group

admin.organization.projects.groups.delete(group_id, **kwargs) -> GroupDeleteResponse

delete /organization/projects/{project_id}/groups/{group_id}

Remove project group

Parameters

  • project_id: String

  • group_id: String

Returns

  • class GroupDeleteResponse

    Confirmation payload returned after removing a group from a project.

    • deleted: bool

      Whether the group membership in the project was removed.

    • object: :"project.group.deleted"

      Always project.group.deleted.

      • :"project.group.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

group = openai.admin.organization.projects.groups.delete("group_id", project_id: "project_id")

puts(group)

Response

{
  "deleted": true,
  "object": "project.group.deleted"
}

Domain Types

Project Group

  • class ProjectGroup

    Details about a group's membership in a project.

    • created_at: Integer

      Unix timestamp (in seconds) when the group was granted project access.

    • group_id: String

      Identifier of the group that has access to the project.

    • group_name: String

      Display name of the group.

    • group_type: :group | :tenant_group

      The type of the group.

      • :group

      • :tenant_group

    • object: :"project.group"

      Always project.group.

      • :"project.group"
    • project_id: String

      Identifier of the project.

Group Delete Response

  • class GroupDeleteResponse

    Confirmation payload returned after removing a group from a project.

    • deleted: bool

      Whether the group membership in the project was removed.

    • object: :"project.group.deleted"

      Always project.group.deleted.

      • :"project.group.deleted"

Roles

List project group role assignments

admin.organization.projects.groups.roles.list(group_id, **kwargs) -> NextCursorPage<RoleListResponse>

get /projects/{project_id}/groups/{group_id}/roles

List project group role assignments

Parameters

  • project_id: String

  • group_id: String

  • after: String

    Cursor for pagination. Provide the value from the previous response's next field to continue listing project roles.

  • limit: Integer

    A limit on the number of project role assignments to return.

  • order: :asc | :desc

    Sort order for the returned project roles.

    • :asc

    • :desc

Returns

  • class RoleListResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.groups.roles.list("group_id", project_id: "project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "assignment_sources": [
        {
          "principal_id": "principal_id",
          "principal_type": "principal_type"
        }
      ],
      "created_at": 0,
      "created_by": "created_by",
      "created_by_user_obj": {
        "foo": "bar"
      },
      "description": "description",
      "metadata": {
        "foo": "bar"
      },
      "name": "name",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type",
      "updated_at": 0
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Assign project role to group

admin.organization.projects.groups.roles.create(group_id, **kwargs) -> RoleCreateResponse

post /projects/{project_id}/groups/{group_id}/roles

Assign project role to group

Parameters

  • project_id: String

  • group_id: String

  • role_id: String

    Identifier of the role to assign.

Returns

  • class RoleCreateResponse

    Role assignment linking a group to a role.

    • group: Group{ id, created_at, name, 2 more}

      Summary information about a group returned in role assignment responses.

      • id: String

        Identifier for the group.

      • created_at: Integer

        Unix timestamp (in seconds) when the group was created.

      • name: String

        Display name of the group.

      • object: :group

        Always group.

        • :group
      • scim_managed: bool

        Whether the group is managed through SCIM.

    • object: :"group.role"

      Always group.role.

      • :"group.role"
    • role: Role

      Details about a role that can be assigned through the public Roles API.

      • id: String

        Identifier for the role.

      • description: String

        Optional description of the role.

      • name: String

        Unique name for the role.

      • object: :role

        Always role.

        • :role
      • permissions: Array[String]

        Permissions granted by the role.

      • predefined_role: bool

        Whether the role is predefined and managed by OpenAI.

      • resource_type: String

        Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.groups.roles.create(
  "group_id",
  project_id: "project_id",
  role_id: "role_id"
)

puts(role)

Response

{
  "group": {
    "id": "id",
    "created_at": 0,
    "name": "name",
    "object": "group",
    "scim_managed": true
  },
  "object": "group.role",
  "role": {
    "id": "id",
    "description": "description",
    "name": "name",
    "object": "role",
    "permissions": [
      "string"
    ],
    "predefined_role": true,
    "resource_type": "resource_type"
  }
}

Retrieve project group role

admin.organization.projects.groups.roles.retrieve(role_id, **kwargs) -> RoleRetrieveResponse

get /projects/{project_id}/groups/{group_id}/roles/{role_id}

Retrieve project group role

Parameters

  • project_id: String

  • group_id: String

  • role_id: String

Returns

  • class RoleRetrieveResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.groups.roles.retrieve(
  "role_id",
  project_id: "project_id",
  group_id: "group_id"
)

puts(role)

Response

{
  "id": "id",
  "assignment_sources": [
    {
      "principal_id": "principal_id",
      "principal_type": "principal_type"
    }
  ],
  "created_at": 0,
  "created_by": "created_by",
  "created_by_user_obj": {
    "foo": "bar"
  },
  "description": "description",
  "metadata": {
    "foo": "bar"
  },
  "name": "name",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type",
  "updated_at": 0
}

Unassign project role from group

admin.organization.projects.groups.roles.delete(role_id, **kwargs) -> RoleDeleteResponse

delete /projects/{project_id}/groups/{group_id}/roles/{role_id}

Unassign project role from group

Parameters

  • project_id: String

  • group_id: String

  • role_id: String

Returns

  • class RoleDeleteResponse

    Confirmation payload returned after unassigning a role.

    • deleted: bool

      Whether the assignment was removed.

    • object: String

      Identifier for the deleted assignment, such as group.role.deleted or user.role.deleted.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.groups.roles.delete(
  "role_id",
  project_id: "project_id",
  group_id: "group_id"
)

puts(role)

Response

{
  "deleted": true,
  "object": "object"
}

Domain Types

Role List Response

  • class RoleListResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Role Create Response

  • class RoleCreateResponse

    Role assignment linking a group to a role.

    • group: Group{ id, created_at, name, 2 more}

      Summary information about a group returned in role assignment responses.

      • id: String

        Identifier for the group.

      • created_at: Integer

        Unix timestamp (in seconds) when the group was created.

      • name: String

        Display name of the group.

      • object: :group

        Always group.

        • :group
      • scim_managed: bool

        Whether the group is managed through SCIM.

    • object: :"group.role"

      Always group.role.

      • :"group.role"
    • role: Role

      Details about a role that can be assigned through the public Roles API.

      • id: String

        Identifier for the role.

      • description: String

        Optional description of the role.

      • name: String

        Unique name for the role.

      • object: :role

        Always role.

        • :role
      • permissions: Array[String]

        Permissions granted by the role.

      • predefined_role: bool

        Whether the role is predefined and managed by OpenAI.

      • resource_type: String

        Resource type the role is bound to (for example api.organization or api.project).

Role Retrieve Response

  • class RoleRetrieveResponse

    Detailed information about a role assignment entry returned when listing assignments.

    • id: String

      Identifier for the role.

    • assignment_sources: Array[AssignmentSource{ principal_id, principal_type}]

      Principals from which the role assignment is inherited, when available.

      • principal_id: String

      • principal_type: String

    • created_at: Integer

      When the role was created.

    • created_by: String

      Identifier of the actor who created the role.

    • created_by_user_obj: Hash[Symbol, untyped]

      User details for the actor that created the role, when available.

    • description: String

      Description of the role.

    • metadata: Hash[Symbol, untyped]

      Arbitrary metadata stored on the role.

    • name: String

      Name of the role.

    • permissions: Array[String]

      Permissions associated with the role.

    • predefined_role: bool

      Whether the role is predefined by OpenAI.

    • resource_type: String

      Resource type the role applies to.

    • updated_at: Integer

      When the role was last updated.

Role Delete Response

  • class RoleDeleteResponse

    Confirmation payload returned after unassigning a role.

    • deleted: bool

      Whether the assignment was removed.

    • object: String

      Identifier for the deleted assignment, such as group.role.deleted or user.role.deleted.

Roles

List project roles

admin.organization.projects.roles.list(project_id, **kwargs) -> NextCursorPage<Role>

get /projects/{project_id}/roles

List project roles

Parameters

  • project_id: String

  • after: String

    Cursor for pagination. Provide the value from the previous response's next field to continue listing roles.

  • limit: Integer

    A limit on the number of roles to return. Defaults to 1000.

  • order: :asc | :desc

    Sort order for the returned roles.

    • :asc

    • :desc

Returns

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.roles.list("project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "description": "description",
      "name": "name",
      "object": "role",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Create project role

admin.organization.projects.roles.create(project_id, **kwargs) -> Role

post /projects/{project_id}/roles

Create project role

Parameters

  • project_id: String

  • permissions: Array[String]

    Permissions to grant to the role.

  • role_name: String

    Unique name for the role.

  • description: String

    Optional description of the role.

Returns

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.roles.create(
  "project_id",
  permissions: ["string"],
  role_name: "role_name"
)

puts(role)

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Retrieve project role

admin.organization.projects.roles.retrieve(role_id, **kwargs) -> Role

get /projects/{project_id}/roles/{role_id}

Retrieve project role

Parameters

  • project_id: String

  • role_id: String

Returns

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.roles.retrieve("role_id", project_id: "project_id")

puts(role)

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Update project role

admin.organization.projects.roles.update(role_id, **kwargs) -> Role

post /projects/{project_id}/roles/{role_id}

Update project role

Parameters

  • project_id: String

  • role_id: String

  • description: String

    New description for the role.

  • permissions: Array[String]

    Updated set of permissions for the role.

  • role_name: String

    New name for the role.

Returns

  • class Role

    Details about a role that can be assigned through the public Roles API.

    • id: String

      Identifier for the role.

    • description: String

      Optional description of the role.

    • name: String

      Unique name for the role.

    • object: :role

      Always role.

      • :role
    • permissions: Array[String]

      Permissions granted by the role.

    • predefined_role: bool

      Whether the role is predefined and managed by OpenAI.

    • resource_type: String

      Resource type the role is bound to (for example api.organization or api.project).

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.roles.update("role_id", project_id: "project_id")

puts(role)

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Delete project role

admin.organization.projects.roles.delete(role_id, **kwargs) -> RoleDeleteResponse

delete /projects/{project_id}/roles/{role_id}

Delete project role

Parameters

  • project_id: String

  • role_id: String

Returns

  • class RoleDeleteResponse

    Confirmation payload returned after deleting a role.

    • id: String

      Identifier of the deleted role.

    • deleted: bool

      Whether the role was deleted.

    • object: :"role.deleted"

      Always role.deleted.

      • :"role.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

role = openai.admin.organization.projects.roles.delete("role_id", project_id: "project_id")

puts(role)

Response

{
  "id": "id",
  "deleted": true,
  "object": "role.deleted"
}

Domain Types

Role Delete Response

  • class RoleDeleteResponse

    Confirmation payload returned after deleting a role.

    • id: String

      Identifier of the deleted role.

    • deleted: bool

      Whether the role was deleted.

    • object: :"role.deleted"

      Always role.deleted.

      • :"role.deleted"

Data Retention

Retrieve project data retention

admin.organization.projects.data_retention.retrieve(project_id) -> ProjectDataRetention

get /organization/projects/{project_id}/data_retention

Retrieve project data retention

Parameters

  • project_id: String

Returns

  • class ProjectDataRetention

    Represents a project's data retention control setting.

    • object: :"project.data_retention"

      The object type, which is always project.data_retention.

      • :"project.data_retention"
    • type: :organization_default | :none | :zero_data_retention | 3 more

      The configured project data retention type.

      • :organization_default

      • :none

      • :zero_data_retention

      • :modified_abuse_monitoring

      • :enhanced_zero_data_retention

      • :enhanced_modified_abuse_monitoring

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_data_retention = openai.admin.organization.projects.data_retention.retrieve("project_id")

puts(project_data_retention)

Response

{
  "object": "project.data_retention",
  "type": "organization_default"
}

Update project data retention

admin.organization.projects.data_retention.update(project_id, **kwargs) -> ProjectDataRetention

post /organization/projects/{project_id}/data_retention

Update project data retention

Parameters

  • project_id: String

  • retention_type: :organization_default | :none | :zero_data_retention | 3 more

    The desired project data retention type.

    • :organization_default

    • :none

    • :zero_data_retention

    • :modified_abuse_monitoring

    • :enhanced_zero_data_retention

    • :enhanced_modified_abuse_monitoring

Returns

  • class ProjectDataRetention

    Represents a project's data retention control setting.

    • object: :"project.data_retention"

      The object type, which is always project.data_retention.

      • :"project.data_retention"
    • type: :organization_default | :none | :zero_data_retention | 3 more

      The configured project data retention type.

      • :organization_default

      • :none

      • :zero_data_retention

      • :modified_abuse_monitoring

      • :enhanced_zero_data_retention

      • :enhanced_modified_abuse_monitoring

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_data_retention = openai.admin.organization.projects.data_retention.update(
  "project_id",
  retention_type: :organization_default
)

puts(project_data_retention)

Response

{
  "object": "project.data_retention",
  "type": "organization_default"
}

Domain Types

Project Data Retention

  • class ProjectDataRetention

    Represents a project's data retention control setting.

    • object: :"project.data_retention"

      The object type, which is always project.data_retention.

      • :"project.data_retention"
    • type: :organization_default | :none | :zero_data_retention | 3 more

      The configured project data retention type.

      • :organization_default

      • :none

      • :zero_data_retention

      • :modified_abuse_monitoring

      • :enhanced_zero_data_retention

      • :enhanced_modified_abuse_monitoring

Spend Alerts

List project spend alerts

admin.organization.projects.spend_alerts.list(project_id, **kwargs) -> ConversationCursorPage<ProjectSpendAlert>

get /organization/projects/{project_id}/spend_alerts

List project spend alerts

Parameters

  • project_id: String

  • after: String

    Cursor for pagination. Provide the ID of the last spend alert from the previous response to fetch the next page.

  • before: String

    Cursor for pagination. Provide the ID of the first spend alert from the previous response to fetch the previous page.

  • limit: Integer

    A limit on the number of spend alerts to return. Defaults to 20.

  • order: :asc | :desc

    Sort order for the returned spend alerts.

    • :asc

    • :desc

Returns

  • class ProjectSpendAlert

    Represents a spend alert configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"project.spend_alert"

      The object type, which is always project.spend_alert.

      • :"project.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.spend_alerts.list("project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "currency": "USD",
      "interval": "month",
      "notification_channel": {
        "recipients": [
          "string"
        ],
        "type": "email",
        "subject_prefix": "subject_prefix"
      },
      "object": "project.spend_alert",
      "threshold_amount": 0
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id",
  "object": "list"
}

Create project spend alert

admin.organization.projects.spend_alerts.create(project_id, **kwargs) -> ProjectSpendAlert

post /organization/projects/{project_id}/spend_alerts

Create project spend alert

Parameters

  • project_id: String

  • currency: :USD

    The currency for the threshold amount.

    • :USD
  • interval: :month

    The time interval for evaluating spend against the threshold.

    • :month
  • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

    Email notification settings for a spend alert.

    • recipients: Array[String]

      Email addresses that receive the spend alert notification.

    • type: :email

      The notification channel type. Currently only email is supported.

      • :email
    • subject_prefix: String

      Optional subject prefix for alert emails.

  • threshold_amount: Integer

    The alert threshold amount, in cents.

Returns

  • class ProjectSpendAlert

    Represents a spend alert configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"project.spend_alert"

      The object type, which is always project.spend_alert.

      • :"project.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_spend_alert = openai.admin.organization.projects.spend_alerts.create(
  "project_id",
  currency: :USD,
  interval: :month,
  notification_channel: {recipients: ["string"], type: :email},
  threshold_amount: 0
)

puts(project_spend_alert)

Response

{
  "id": "id",
  "currency": "USD",
  "interval": "month",
  "notification_channel": {
    "recipients": [
      "string"
    ],
    "type": "email",
    "subject_prefix": "subject_prefix"
  },
  "object": "project.spend_alert",
  "threshold_amount": 0
}

Retrieve project spend alert

admin.organization.projects.spend_alerts.retrieve(alert_id, **kwargs) -> ProjectSpendAlert

get /organization/projects/{project_id}/spend_alerts/{alert_id}

Retrieve project spend alert

Parameters

  • project_id: String

  • alert_id: String

Returns

  • class ProjectSpendAlert

    Represents a spend alert configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"project.spend_alert"

      The object type, which is always project.spend_alert.

      • :"project.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_spend_alert = openai.admin.organization.projects.spend_alerts.retrieve("alert_id", project_id: "project_id")

puts(project_spend_alert)

Response

{
  "id": "id",
  "currency": "USD",
  "interval": "month",
  "notification_channel": {
    "recipients": [
      "string"
    ],
    "type": "email",
    "subject_prefix": "subject_prefix"
  },
  "object": "project.spend_alert",
  "threshold_amount": 0
}

Update project spend alert

admin.organization.projects.spend_alerts.update(alert_id, **kwargs) -> ProjectSpendAlert

post /organization/projects/{project_id}/spend_alerts/{alert_id}

Update project spend alert

Parameters

  • project_id: String

  • alert_id: String

  • currency: :USD

    The currency for the threshold amount.

    • :USD
  • interval: :month

    The time interval for evaluating spend against the threshold.

    • :month
  • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

    Email notification settings for a spend alert.

    • recipients: Array[String]

      Email addresses that receive the spend alert notification.

    • type: :email

      The notification channel type. Currently only email is supported.

      • :email
    • subject_prefix: String

      Optional subject prefix for alert emails.

  • threshold_amount: Integer

    The alert threshold amount, in cents.

Returns

  • class ProjectSpendAlert

    Represents a spend alert configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"project.spend_alert"

      The object type, which is always project.spend_alert.

      • :"project.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_spend_alert = openai.admin.organization.projects.spend_alerts.update(
  "alert_id",
  project_id: "project_id",
  currency: :USD,
  interval: :month,
  notification_channel: {recipients: ["string"], type: :email},
  threshold_amount: 0
)

puts(project_spend_alert)

Response

{
  "id": "id",
  "currency": "USD",
  "interval": "month",
  "notification_channel": {
    "recipients": [
      "string"
    ],
    "type": "email",
    "subject_prefix": "subject_prefix"
  },
  "object": "project.spend_alert",
  "threshold_amount": 0
}

Delete project spend alert

admin.organization.projects.spend_alerts.delete(alert_id, **kwargs) -> ProjectSpendAlertDeleted

delete /organization/projects/{project_id}/spend_alerts/{alert_id}

Delete project spend alert

Parameters

  • project_id: String

  • alert_id: String

Returns

  • class ProjectSpendAlertDeleted

    Confirmation payload returned after deleting a project spend alert.

    • id: String

      The deleted spend alert ID.

    • deleted: bool

      Whether the spend alert was deleted.

    • object: :"project.spend_alert.deleted"

      Always project.spend_alert.deleted.

      • :"project.spend_alert.deleted"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

project_spend_alert_deleted = openai.admin.organization.projects.spend_alerts.delete("alert_id", project_id: "project_id")

puts(project_spend_alert_deleted)

Response

{
  "id": "id",
  "deleted": true,
  "object": "project.spend_alert.deleted"
}

Domain Types

Project Spend Alert

  • class ProjectSpendAlert

    Represents a spend alert configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints.

    • currency: :USD

      The currency for the threshold amount.

      • :USD
    • interval: :month

      The time interval for evaluating spend against the threshold.

      • :month
    • notification_channel: NotificationChannel{ recipients, type, subject_prefix}

      Email notification settings for a spend alert.

      • recipients: Array[String]

        Email addresses that receive the spend alert notification.

      • type: :email

        The notification channel type. Currently only email is supported.

        • :email
      • subject_prefix: String

        Optional subject prefix for alert emails.

    • object: :"project.spend_alert"

      The object type, which is always project.spend_alert.

      • :"project.spend_alert"
    • threshold_amount: Integer

      The alert threshold amount, in cents.

Project Spend Alert Deleted

  • class ProjectSpendAlertDeleted

    Confirmation payload returned after deleting a project spend alert.

    • id: String

      The deleted spend alert ID.

    • deleted: bool

      Whether the spend alert was deleted.

    • object: :"project.spend_alert.deleted"

      Always project.spend_alert.deleted.

      • :"project.spend_alert.deleted"

Certificates

List project certificates

admin.organization.projects.certificates.list(project_id, **kwargs) -> ConversationCursorPage<CertificateListResponse>

get /organization/projects/{project_id}/certificates

List project certificates

Parameters

  • project_id: String

  • after: String

    A cursor for use in pagination. after is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.

  • limit: Integer

    A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.

  • order: :asc | :desc

    Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

    • :asc

    • :desc

Returns

  • class CertificateListResponse

    Represents an individual certificate configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the project level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.project.certificate"

      The object type, which is always organization.project.certificate.

      • :"organization.project.certificate"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.certificates.list("project_id")

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.project.certificate"
    }
  ],
  "first_id": "cert_abc",
  "has_more": true,
  "last_id": "cert_abc",
  "object": "list"
}

Activate certificates for project

admin.organization.projects.certificates.activate(project_id, **kwargs) -> Page<CertificateActivateResponse>

post /organization/projects/{project_id}/certificates/activate

Activate certificates for project

Parameters

  • project_id: String

  • certificate_ids: Array[String]

Returns

  • class CertificateActivateResponse

    Represents an individual certificate configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the project level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.project.certificate"

      The object type, which is always organization.project.certificate.

      • :"organization.project.certificate"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.certificates.activate("project_id", certificate_ids: ["cert_abc"])

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.project.certificate"
    }
  ],
  "object": "organization.project.certificate.activation"
}

Deactivate certificates for project

admin.organization.projects.certificates.deactivate(project_id, **kwargs) -> Page<CertificateDeactivateResponse>

post /organization/projects/{project_id}/certificates/deactivate

Deactivate certificates for project

Parameters

  • project_id: String

  • certificate_ids: Array[String]

Returns

  • class CertificateDeactivateResponse

    Represents an individual certificate configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the project level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.project.certificate"

      The object type, which is always organization.project.certificate.

      • :"organization.project.certificate"

Example

require "openai"

openai = OpenAI::Client.new(admin_api_key: "My Admin API Key")

page = openai.admin.organization.projects.certificates.deactivate("project_id", certificate_ids: ["cert_abc"])

puts(page)

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.project.certificate"
    }
  ],
  "object": "organization.project.certificate.deactivation"
}

Domain Types

Certificate List Response

  • class CertificateListResponse

    Represents an individual certificate configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the project level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.project.certificate"

      The object type, which is always organization.project.certificate.

      • :"organization.project.certificate"

Certificate Activate Response

  • class CertificateActivateResponse

    Represents an individual certificate configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the project level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.project.certificate"

      The object type, which is always organization.project.certificate.

      • :"organization.project.certificate"

Certificate Deactivate Response

  • class CertificateDeactivateResponse

    Represents an individual certificate configured at the project level.

    • id: String

      The identifier, which can be referenced in API endpoints

    • active: bool

      Whether the certificate is currently active at the project level.

    • certificate_details: CertificateDetails{ expires_at, valid_at}

      • expires_at: Integer

        The Unix timestamp (in seconds) of when the certificate expires.

      • valid_at: Integer

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • created_at: Integer

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • name: String

      The name of the certificate.

    • object: :"organization.project.certificate"

      The object type, which is always organization.project.certificate.

      • :"organization.project.certificate"