# Admin

# Organization

# Audit Logs

## List audit logs

`AuditLogListPage admin().organization().auditLogs().list(AuditLogListParamsparams = AuditLogListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/audit_logs`

List user actions and configuration changes within this organization.

### Parameters

- `AuditLogListParams params`

  - `Optional<List<String>> actorEmails`

    Return only events performed by users with these emails.

  - `Optional<List<String>> actorIds`

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

  - `Optional<String> after`

    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.

  - `Optional<String> before`

    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.

  - `Optional<EffectiveAt> effectiveAt`

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

    - `Optional<Long> gt`

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

    - `Optional<Long> gte`

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

    - `Optional<Long> lt`

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

    - `Optional<Long> lte`

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

  - `Optional<List<EventType>> eventTypes`

    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](https://platform.openai.com/docs/api-reference/audit-logs/object).

    - `API_KEY_CREATED("api_key.created")`

    - `API_KEY_UPDATED("api_key.updated")`

    - `API_KEY_DELETED("api_key.deleted")`

    - `CERTIFICATE_CREATED("certificate.created")`

    - `CERTIFICATE_UPDATED("certificate.updated")`

    - `CERTIFICATE_DELETED("certificate.deleted")`

    - `CERTIFICATES_ACTIVATED("certificates.activated")`

    - `CERTIFICATES_DEACTIVATED("certificates.deactivated")`

    - `CHECKPOINT_PERMISSION_CREATED("checkpoint.permission.created")`

    - `CHECKPOINT_PERMISSION_DELETED("checkpoint.permission.deleted")`

    - `EXTERNAL_KEY_REGISTERED("external_key.registered")`

    - `EXTERNAL_KEY_REMOVED("external_key.removed")`

    - `GROUP_CREATED("group.created")`

    - `GROUP_UPDATED("group.updated")`

    - `GROUP_DELETED("group.deleted")`

    - `INVITE_SENT("invite.sent")`

    - `INVITE_ACCEPTED("invite.accepted")`

    - `INVITE_DELETED("invite.deleted")`

    - `IP_ALLOWLIST_CREATED("ip_allowlist.created")`

    - `IP_ALLOWLIST_UPDATED("ip_allowlist.updated")`

    - `IP_ALLOWLIST_DELETED("ip_allowlist.deleted")`

    - `IP_ALLOWLIST_CONFIG_ACTIVATED("ip_allowlist.config.activated")`

    - `IP_ALLOWLIST_CONFIG_DEACTIVATED("ip_allowlist.config.deactivated")`

    - `LOGIN_SUCCEEDED("login.succeeded")`

    - `LOGIN_FAILED("login.failed")`

    - `LOGOUT_SUCCEEDED("logout.succeeded")`

    - `LOGOUT_FAILED("logout.failed")`

    - `ORGANIZATION_UPDATED("organization.updated")`

    - `PROJECT_CREATED("project.created")`

    - `PROJECT_UPDATED("project.updated")`

    - `PROJECT_ARCHIVED("project.archived")`

    - `PROJECT_DELETED("project.deleted")`

    - `RATE_LIMIT_UPDATED("rate_limit.updated")`

    - `RATE_LIMIT_DELETED("rate_limit.deleted")`

    - `RESOURCE_DELETED("resource.deleted")`

    - `TUNNEL_CREATED("tunnel.created")`

    - `TUNNEL_UPDATED("tunnel.updated")`

    - `TUNNEL_DELETED("tunnel.deleted")`

    - `ROLE_CREATED("role.created")`

    - `ROLE_UPDATED("role.updated")`

    - `ROLE_DELETED("role.deleted")`

    - `ROLE_ASSIGNMENT_CREATED("role.assignment.created")`

    - `ROLE_ASSIGNMENT_DELETED("role.assignment.deleted")`

    - `SCIM_ENABLED("scim.enabled")`

    - `SCIM_DISABLED("scim.disabled")`

    - `SERVICE_ACCOUNT_CREATED("service_account.created")`

    - `SERVICE_ACCOUNT_UPDATED("service_account.updated")`

    - `SERVICE_ACCOUNT_DELETED("service_account.deleted")`

    - `USER_ADDED("user.added")`

    - `USER_UPDATED("user.updated")`

    - `USER_DELETED("user.deleted")`

  - `Optional<Long> limit`

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

  - `Optional<List<String>> projectIds`

    Return only events for these projects.

  - `Optional<List<String>> resourceIds`

    Return only events performed on these targets. For example, a project ID updated.

### Returns

- `class AuditLogListResponse:`

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

  - `String id`

    The ID of this log.

  - `long effectiveAt`

    The Unix timestamp (in seconds) of the event.

  - `Type type`

    The event type.

    - `API_KEY_CREATED("api_key.created")`

    - `API_KEY_UPDATED("api_key.updated")`

    - `API_KEY_DELETED("api_key.deleted")`

    - `CERTIFICATE_CREATED("certificate.created")`

    - `CERTIFICATE_UPDATED("certificate.updated")`

    - `CERTIFICATE_DELETED("certificate.deleted")`

    - `CERTIFICATES_ACTIVATED("certificates.activated")`

    - `CERTIFICATES_DEACTIVATED("certificates.deactivated")`

    - `CHECKPOINT_PERMISSION_CREATED("checkpoint.permission.created")`

    - `CHECKPOINT_PERMISSION_DELETED("checkpoint.permission.deleted")`

    - `EXTERNAL_KEY_REGISTERED("external_key.registered")`

    - `EXTERNAL_KEY_REMOVED("external_key.removed")`

    - `GROUP_CREATED("group.created")`

    - `GROUP_UPDATED("group.updated")`

    - `GROUP_DELETED("group.deleted")`

    - `INVITE_SENT("invite.sent")`

    - `INVITE_ACCEPTED("invite.accepted")`

    - `INVITE_DELETED("invite.deleted")`

    - `IP_ALLOWLIST_CREATED("ip_allowlist.created")`

    - `IP_ALLOWLIST_UPDATED("ip_allowlist.updated")`

    - `IP_ALLOWLIST_DELETED("ip_allowlist.deleted")`

    - `IP_ALLOWLIST_CONFIG_ACTIVATED("ip_allowlist.config.activated")`

    - `IP_ALLOWLIST_CONFIG_DEACTIVATED("ip_allowlist.config.deactivated")`

    - `LOGIN_SUCCEEDED("login.succeeded")`

    - `LOGIN_FAILED("login.failed")`

    - `LOGOUT_SUCCEEDED("logout.succeeded")`

    - `LOGOUT_FAILED("logout.failed")`

    - `ORGANIZATION_UPDATED("organization.updated")`

    - `PROJECT_CREATED("project.created")`

    - `PROJECT_UPDATED("project.updated")`

    - `PROJECT_ARCHIVED("project.archived")`

    - `PROJECT_DELETED("project.deleted")`

    - `RATE_LIMIT_UPDATED("rate_limit.updated")`

    - `RATE_LIMIT_DELETED("rate_limit.deleted")`

    - `RESOURCE_DELETED("resource.deleted")`

    - `TUNNEL_CREATED("tunnel.created")`

    - `TUNNEL_UPDATED("tunnel.updated")`

    - `TUNNEL_DELETED("tunnel.deleted")`

    - `ROLE_CREATED("role.created")`

    - `ROLE_UPDATED("role.updated")`

    - `ROLE_DELETED("role.deleted")`

    - `ROLE_ASSIGNMENT_CREATED("role.assignment.created")`

    - `ROLE_ASSIGNMENT_DELETED("role.assignment.deleted")`

    - `SCIM_ENABLED("scim.enabled")`

    - `SCIM_DISABLED("scim.disabled")`

    - `SERVICE_ACCOUNT_CREATED("service_account.created")`

    - `SERVICE_ACCOUNT_UPDATED("service_account.updated")`

    - `SERVICE_ACCOUNT_DELETED("service_account.deleted")`

    - `USER_ADDED("user.added")`

    - `USER_UPDATED("user.updated")`

    - `USER_DELETED("user.deleted")`

  - `Optional<Actor> actor`

    The actor who performed the audit logged action.

    - `Optional<ApiKey> apiKey`

      The API Key used to perform the audit logged action.

      - `Optional<String> id`

        The tracking id of the API key.

      - `Optional<ServiceAccount> serviceAccount`

        The service account that performed the audit logged action.

        - `Optional<String> id`

          The service account id.

      - `Optional<Type> type`

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

        - `USER("user")`

        - `SERVICE_ACCOUNT("service_account")`

      - `Optional<User> user`

        The user who performed the audit logged action.

        - `Optional<String> id`

          The user id.

        - `Optional<String> email`

          The user email.

    - `Optional<Session> session`

      The session in which the audit logged action was performed.

      - `Optional<String> ipAddress`

        The IP address from which the action was performed.

      - `Optional<User> user`

        The user who performed the audit logged action.

        - `Optional<String> id`

          The user id.

        - `Optional<String> email`

          The user email.

    - `Optional<Type> type`

      The type of actor. Is either `session` or `api_key`.

      - `SESSION("session")`

      - `API_KEY("api_key")`

  - `Optional<ApiKeyCreated> apiKeyCreated`

    The details for events with this `type`.

    - `Optional<String> id`

      The tracking ID of the API key.

    - `Optional<Data> data`

      The payload used to create the API key.

      - `Optional<List<String>> scopes`

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

  - `Optional<ApiKeyDeleted> apiKeyDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The tracking ID of the API key.

  - `Optional<ApiKeyUpdated> apiKeyUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The tracking ID of the API key.

    - `Optional<ChangesRequested> changesRequested`

      The payload used to update the API key.

      - `Optional<List<String>> scopes`

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

  - `Optional<CertificateCreated> certificateCreated`

    The details for events with this `type`.

    - `Optional<String> id`

      The certificate ID.

    - `Optional<String> name`

      The name of the certificate.

  - `Optional<CertificateDeleted> certificateDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The certificate ID.

    - `Optional<String> certificate`

      The certificate content in PEM format.

    - `Optional<String> name`

      The name of the certificate.

  - `Optional<CertificateUpdated> certificateUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The certificate ID.

    - `Optional<String> name`

      The name of the certificate.

  - `Optional<CertificatesActivated> certificatesActivated`

    The details for events with this `type`.

    - `Optional<List<Certificate>> certificates`

      - `Optional<String> id`

        The certificate ID.

      - `Optional<String> name`

        The name of the certificate.

  - `Optional<CertificatesDeactivated> certificatesDeactivated`

    The details for events with this `type`.

    - `Optional<List<Certificate>> certificates`

      - `Optional<String> id`

        The certificate ID.

      - `Optional<String> name`

        The name of the certificate.

  - `Optional<CheckpointPermissionCreated> checkpointPermissionCreated`

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

    - `Optional<String> id`

      The ID of the checkpoint permission.

    - `Optional<Data> data`

      The payload used to create the checkpoint permission.

      - `Optional<String> fineTunedModelCheckpoint`

        The ID of the fine-tuned model checkpoint.

      - `Optional<String> projectId`

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

  - `Optional<CheckpointPermissionDeleted> checkpointPermissionDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the checkpoint permission.

  - `Optional<ExternalKeyRegistered> externalKeyRegistered`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the external key configuration.

    - `Optional<JsonValue> data`

      The configuration for the external key.

  - `Optional<ExternalKeyRemoved> externalKeyRemoved`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the external key configuration.

  - `Optional<GroupCreated> groupCreated`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the group.

    - `Optional<Data> data`

      Information about the created group.

      - `Optional<String> groupName`

        The group name.

  - `Optional<GroupDeleted> groupDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the group.

  - `Optional<GroupUpdated> groupUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the group.

    - `Optional<ChangesRequested> changesRequested`

      The payload used to update the group.

      - `Optional<String> groupName`

        The updated group name.

  - `Optional<InviteAccepted> inviteAccepted`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the invite.

  - `Optional<InviteDeleted> inviteDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the invite.

  - `Optional<InviteSent> inviteSent`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the invite.

    - `Optional<Data> data`

      The payload used to create the invite.

      - `Optional<String> email`

        The email invited to the organization.

      - `Optional<String> role`

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

  - `Optional<IpAllowlistConfigActivated> ipAllowlistConfigActivated`

    The details for events with this `type`.

    - `Optional<List<Config>> configs`

      The configurations that were activated.

      - `Optional<String> id`

        The ID of the IP allowlist configuration.

      - `Optional<String> name`

        The name of the IP allowlist configuration.

  - `Optional<IpAllowlistConfigDeactivated> ipAllowlistConfigDeactivated`

    The details for events with this `type`.

    - `Optional<List<Config>> configs`

      The configurations that were deactivated.

      - `Optional<String> id`

        The ID of the IP allowlist configuration.

      - `Optional<String> name`

        The name of the IP allowlist configuration.

  - `Optional<IpAllowlistCreated> ipAllowlistCreated`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the IP allowlist configuration.

    - `Optional<List<String>> allowedIps`

      The IP addresses or CIDR ranges included in the configuration.

    - `Optional<String> name`

      The name of the IP allowlist configuration.

  - `Optional<IpAllowlistDeleted> ipAllowlistDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the IP allowlist configuration.

    - `Optional<List<String>> allowedIps`

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

    - `Optional<String> name`

      The name of the IP allowlist configuration.

  - `Optional<IpAllowlistUpdated> ipAllowlistUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the IP allowlist configuration.

    - `Optional<List<String>> allowedIps`

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

  - `Optional<LoginFailed> loginFailed`

    The details for events with this `type`.

    - `Optional<String> errorCode`

      The error code of the failure.

    - `Optional<String> errorMessage`

      The error message of the failure.

  - `Optional<JsonValue> loginSucceeded`

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

  - `Optional<LogoutFailed> logoutFailed`

    The details for events with this `type`.

    - `Optional<String> errorCode`

      The error code of the failure.

    - `Optional<String> errorMessage`

      The error message of the failure.

  - `Optional<JsonValue> logoutSucceeded`

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

  - `Optional<OrganizationUpdated> organizationUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The organization ID.

    - `Optional<ChangesRequested> changesRequested`

      The payload used to update the organization settings.

      - `Optional<String> apiCallLogging`

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

      - `Optional<String> apiCallLoggingProjectIds`

        The list of project ids if api_call_logging is set to `enabled_for_selected_projects`

      - `Optional<String> description`

        The organization description.

      - `Optional<String> name`

        The organization name.

      - `Optional<String> threadsUiVisibility`

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

      - `Optional<String> title`

        The organization title.

      - `Optional<String> usageDashboardVisibility`

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

  - `Optional<Project> project`

    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.

    - `Optional<String> id`

      The project ID.

    - `Optional<String> name`

      The project title.

  - `Optional<ProjectArchived> projectArchived`

    The details for events with this `type`.

    - `Optional<String> id`

      The project ID.

  - `Optional<ProjectCreated> projectCreated`

    The details for events with this `type`.

    - `Optional<String> id`

      The project ID.

    - `Optional<Data> data`

      The payload used to create the project.

      - `Optional<String> name`

        The project name.

      - `Optional<String> title`

        The title of the project as seen on the dashboard.

  - `Optional<ProjectDeleted> projectDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The project ID.

  - `Optional<ProjectUpdated> projectUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The project ID.

    - `Optional<ChangesRequested> changesRequested`

      The payload used to update the project.

      - `Optional<String> title`

        The title of the project as seen on the dashboard.

  - `Optional<RateLimitDeleted> rateLimitDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The rate limit ID

  - `Optional<RateLimitUpdated> rateLimitUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The rate limit ID

    - `Optional<ChangesRequested> changesRequested`

      The payload used to update the rate limits.

      - `Optional<Long> batch1DayMaxInputTokens`

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

      - `Optional<Long> maxAudioMegabytesPer1Minute`

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

      - `Optional<Long> maxImagesPer1Minute`

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

      - `Optional<Long> maxRequestsPer1Day`

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

      - `Optional<Long> maxRequestsPer1Minute`

        The maximum requests per minute.

      - `Optional<Long> maxTokensPer1Minute`

        The maximum tokens per minute.

  - `Optional<RoleAssignmentCreated> roleAssignmentCreated`

    The details for events with this `type`.

    - `Optional<String> id`

      The identifier of the role assignment.

    - `Optional<String> principalId`

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

    - `Optional<String> principalType`

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

    - `Optional<String> resourceId`

      The resource the role assignment is scoped to.

    - `Optional<String> resourceType`

      The type of resource the role assignment is scoped to.

  - `Optional<RoleAssignmentDeleted> roleAssignmentDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The identifier of the role assignment.

    - `Optional<String> principalId`

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

    - `Optional<String> principalType`

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

    - `Optional<String> resourceId`

      The resource the role assignment was scoped to.

    - `Optional<String> resourceType`

      The type of resource the role assignment was scoped to.

  - `Optional<RoleCreated> roleCreated`

    The details for events with this `type`.

    - `Optional<String> id`

      The role ID.

    - `Optional<List<String>> permissions`

      The permissions granted by the role.

    - `Optional<String> resourceId`

      The resource the role is scoped to.

    - `Optional<String> resourceType`

      The type of resource the role belongs to.

    - `Optional<String> roleName`

      The name of the role.

  - `Optional<RoleDeleted> roleDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The role ID.

  - `Optional<RoleUpdated> roleUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The role ID.

    - `Optional<ChangesRequested> changesRequested`

      The payload used to update the role.

      - `Optional<String> description`

        The updated role description, when provided.

      - `Optional<JsonValue> metadata`

        Additional metadata stored on the role.

      - `Optional<List<String>> permissionsAdded`

        The permissions added to the role.

      - `Optional<List<String>> permissionsRemoved`

        The permissions removed from the role.

      - `Optional<String> resourceId`

        The resource the role is scoped to.

      - `Optional<String> resourceType`

        The type of resource the role belongs to.

      - `Optional<String> roleName`

        The updated role name, when provided.

  - `Optional<ScimDisabled> scimDisabled`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the SCIM was disabled for.

  - `Optional<ScimEnabled> scimEnabled`

    The details for events with this `type`.

    - `Optional<String> id`

      The ID of the SCIM was enabled for.

  - `Optional<ServiceAccountCreated> serviceAccountCreated`

    The details for events with this `type`.

    - `Optional<String> id`

      The service account ID.

    - `Optional<Data> data`

      The payload used to create the service account.

      - `Optional<String> role`

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

  - `Optional<ServiceAccountDeleted> serviceAccountDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The service account ID.

  - `Optional<ServiceAccountUpdated> serviceAccountUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The service account ID.

    - `Optional<ChangesRequested> changesRequested`

      The payload used to updated the service account.

      - `Optional<String> role`

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

  - `Optional<UserAdded> userAdded`

    The details for events with this `type`.

    - `Optional<String> id`

      The user ID.

    - `Optional<Data> data`

      The payload used to add the user to the project.

      - `Optional<String> role`

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

  - `Optional<UserDeleted> userDeleted`

    The details for events with this `type`.

    - `Optional<String> id`

      The user ID.

  - `Optional<UserUpdated> userUpdated`

    The details for events with this `type`.

    - `Optional<String> id`

      The project ID.

    - `Optional<ChangesRequested> changesRequested`

      The payload used to update the user.

      - `Optional<String> role`

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

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.auditlogs.AuditLogListPage;
import com.openai.models.admin.organization.auditlogs.AuditLogListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        AuditLogListPage page = client.admin().organization().auditLogs().list();
    }
}
```

#### Response

```json
{
  "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.created": {
        "id": "id",
        "permissions": [
          "string"
        ],
        "resource_id": "resource_id",
        "resource_type": "resource_type",
        "role_name": "role_name"
      },
      "role.deleted": {
        "id": "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"
        }
      }
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "audit_log-defb456h8dks",
  "last_id": "audit_log-hnbkd8s93s"
}
```

# Admin API Keys

## List all organization and project API keys.

`AdminApiKeyListPage admin().organization().adminApiKeys().list(AdminApiKeyListParamsparams = AdminApiKeyListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/admin_api_keys`

List organization API keys

### Parameters

- `AdminApiKeyListParams params`

  - `Optional<String> after`

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

  - `Optional<Long> limit`

    Maximum number of keys to return.

  - `Optional<Order> order`

    Order results by creation time, ascending or descending.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class AdminApiKey:`

  Represents an individual Admin API key in an org.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.admin_api_key"constant`

    The object type, which is always `organization.admin_api_key`

    - `ORGANIZATION_ADMIN_API_KEY("organization.admin_api_key")`

  - `Owner owner`

    - `Optional<String> id`

      The identifier, which can be referenced in API endpoints

    - `Optional<Long> createdAt`

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

    - `Optional<String> name`

      The name of the user

    - `Optional<String> object_`

      The object type, which is always organization.user

    - `Optional<String> role`

      Always `owner`

    - `Optional<String> type`

      Always `user`

  - `String redactedValue`

    The redacted value of the API key

  - `Optional<Long> lastUsedAt`

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

  - `Optional<String> name`

    The name of the API key

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.adminapikeys.AdminApiKeyListPage;
import com.openai.models.admin.organization.adminapikeys.AdminApiKeyListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        AdminApiKeyListPage page = client.admin().organization().adminApiKeys().list();
    }
}
```

#### Response

```json
{
  "data": [
    {
      "id": "key_abc",
      "created_at": 1711471533,
      "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

`AdminApiKeyCreateResponse admin().organization().adminApiKeys().create(AdminApiKeyCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/admin_api_keys`

Create an organization admin API key

### Parameters

- `AdminApiKeyCreateParams params`

  - `String name`

### Returns

- `class AdminApiKeyCreateResponse:`

  Represents an individual Admin API key in an org.

  - `String value`

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

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.adminapikeys.AdminApiKeyCreateParams;
import com.openai.models.admin.organization.adminapikeys.AdminApiKeyCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        AdminApiKeyCreateParams params = AdminApiKeyCreateParams.builder()
            .name("New Admin Key")
            .build();
        AdminApiKeyCreateResponse adminApiKey = client.admin().organization().adminApiKeys().create(params);
    }
}
```

#### Response

```json
{
  "id": "key_abc",
  "created_at": 1711471533,
  "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

`AdminApiKey admin().organization().adminApiKeys().retrieve(AdminApiKeyRetrieveParamsparams = AdminApiKeyRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/admin_api_keys/{key_id}`

Retrieve a single organization API key

### Parameters

- `AdminApiKeyRetrieveParams params`

  - `Optional<String> keyId`

    The ID of the API key.

### Returns

- `class AdminApiKey:`

  Represents an individual Admin API key in an org.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.admin_api_key"constant`

    The object type, which is always `organization.admin_api_key`

    - `ORGANIZATION_ADMIN_API_KEY("organization.admin_api_key")`

  - `Owner owner`

    - `Optional<String> id`

      The identifier, which can be referenced in API endpoints

    - `Optional<Long> createdAt`

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

    - `Optional<String> name`

      The name of the user

    - `Optional<String> object_`

      The object type, which is always organization.user

    - `Optional<String> role`

      Always `owner`

    - `Optional<String> type`

      Always `user`

  - `String redactedValue`

    The redacted value of the API key

  - `Optional<Long> lastUsedAt`

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

  - `Optional<String> name`

    The name of the API key

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.adminapikeys.AdminApiKey;
import com.openai.models.admin.organization.adminapikeys.AdminApiKeyRetrieveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        AdminApiKey adminApiKey = client.admin().organization().adminApiKeys().retrieve("key_id");
    }
}
```

#### Response

```json
{
  "id": "key_abc",
  "created_at": 1711471533,
  "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

`AdminApiKeyDeleteResponse admin().organization().adminApiKeys().delete(AdminApiKeyDeleteParamsparams = AdminApiKeyDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/admin_api_keys/{key_id}`

Delete an organization admin API key

### Parameters

- `AdminApiKeyDeleteParams params`

  - `Optional<String> keyId`

    The ID of the API key to be deleted.

### Returns

- `class AdminApiKeyDeleteResponse:`

  - `String id`

  - `boolean deleted`

  - `JsonValue; object_ "organization.admin_api_key.deleted"constant`

    - `ORGANIZATION_ADMIN_API_KEY_DELETED("organization.admin_api_key.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.adminapikeys.AdminApiKeyDeleteParams;
import com.openai.models.admin.organization.adminapikeys.AdminApiKeyDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        AdminApiKeyDeleteResponse adminApiKey = client.admin().organization().adminApiKeys().delete("key_id");
    }
}
```

#### Response

```json
{
  "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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.admin_api_key"constant`

    The object type, which is always `organization.admin_api_key`

    - `ORGANIZATION_ADMIN_API_KEY("organization.admin_api_key")`

  - `Owner owner`

    - `Optional<String> id`

      The identifier, which can be referenced in API endpoints

    - `Optional<Long> createdAt`

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

    - `Optional<String> name`

      The name of the user

    - `Optional<String> object_`

      The object type, which is always organization.user

    - `Optional<String> role`

      Always `owner`

    - `Optional<String> type`

      Always `user`

  - `String redactedValue`

    The redacted value of the API key

  - `Optional<Long> lastUsedAt`

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

  - `Optional<String> name`

    The name of the API key

# Usage

## Audio speeches

`UsageAudioSpeechesResponse admin().organization().usage().audioSpeeches(UsageAudioSpeechesParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/usage/audio_speeches`

Get audio speeches usage details for the organization.

### Parameters

- `UsageAudioSpeechesParams params`

  - `long startTime`

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

  - `Optional<List<String>> apiKeyIds`

    Return only usage for these API keys.

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1M("1m")`

    - `_1H("1h")`

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

    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("project_id")`

    - `USER_ID("user_id")`

    - `API_KEY_ID("api_key_id")`

    - `MODEL("model")`

  - `Optional<Long> limit`

    Specifies the number of buckets to return.

    - `bucket_width=1d`: default: 7, max: 31
    - `bucket_width=1h`: default: 24, max: 168
    - `bucket_width=1m`: default: 60, max: 1440

  - `Optional<List<String>> models`

    Return only usage for these models.

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only usage for these projects.

  - `Optional<List<String>> userIds`

    Return only usage for these users.

### Returns

- `class UsageAudioSpeechesResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageAudioSpeechesParams;
import com.openai.models.admin.organization.usage.UsageAudioSpeechesResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageAudioSpeechesParams params = UsageAudioSpeechesParams.builder()
            .startTime(0L)
            .build();
        UsageAudioSpeechesResponse response = client.admin().organization().usage().audioSpeeches(params);
    }
}
```

#### Response

```json
{
  "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

`UsageAudioTranscriptionsResponse admin().organization().usage().audioTranscriptions(UsageAudioTranscriptionsParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/usage/audio_transcriptions`

Get audio transcriptions usage details for the organization.

### Parameters

- `UsageAudioTranscriptionsParams params`

  - `long startTime`

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

  - `Optional<List<String>> apiKeyIds`

    Return only usage for these API keys.

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1M("1m")`

    - `_1H("1h")`

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

    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("project_id")`

    - `USER_ID("user_id")`

    - `API_KEY_ID("api_key_id")`

    - `MODEL("model")`

  - `Optional<Long> limit`

    Specifies the number of buckets to return.

    - `bucket_width=1d`: default: 7, max: 31
    - `bucket_width=1h`: default: 24, max: 168
    - `bucket_width=1m`: default: 60, max: 1440

  - `Optional<List<String>> models`

    Return only usage for these models.

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only usage for these projects.

  - `Optional<List<String>> userIds`

    Return only usage for these users.

### Returns

- `class UsageAudioTranscriptionsResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageAudioTranscriptionsParams;
import com.openai.models.admin.organization.usage.UsageAudioTranscriptionsResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageAudioTranscriptionsParams params = UsageAudioTranscriptionsParams.builder()
            .startTime(0L)
            .build();
        UsageAudioTranscriptionsResponse response = client.admin().organization().usage().audioTranscriptions(params);
    }
}
```

#### Response

```json
{
  "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

`UsageCodeInterpreterSessionsResponse admin().organization().usage().codeInterpreterSessions(UsageCodeInterpreterSessionsParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/usage/code_interpreter_sessions`

Get code interpreter sessions usage details for the organization.

### Parameters

- `UsageCodeInterpreterSessionsParams params`

  - `long startTime`

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

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1M("1m")`

    - `_1H("1h")`

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

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

    - `PROJECT_ID("project_id")`

  - `Optional<Long> limit`

    Specifies the number of buckets to return.

    - `bucket_width=1d`: default: 7, max: 31
    - `bucket_width=1h`: default: 24, max: 168
    - `bucket_width=1m`: default: 60, max: 1440

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only usage for these projects.

### Returns

- `class UsageCodeInterpreterSessionsResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageCodeInterpreterSessionsParams;
import com.openai.models.admin.organization.usage.UsageCodeInterpreterSessionsResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageCodeInterpreterSessionsParams params = UsageCodeInterpreterSessionsParams.builder()
            .startTime(0L)
            .build();
        UsageCodeInterpreterSessionsResponse response = client.admin().organization().usage().codeInterpreterSessions(params);
    }
}
```

#### Response

```json
{
  "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

`UsageCompletionsResponse admin().organization().usage().completions(UsageCompletionsParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/usage/completions`

Get completions usage details for the organization.

### Parameters

- `UsageCompletionsParams params`

  - `long startTime`

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

  - `Optional<List<String>> apiKeyIds`

    Return only usage for these API keys.

  - `Optional<Boolean> batch`

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

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1M("1m")`

    - `_1H("1h")`

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

    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("project_id")`

    - `USER_ID("user_id")`

    - `API_KEY_ID("api_key_id")`

    - `MODEL("model")`

    - `BATCH("batch")`

    - `SERVICE_TIER("service_tier")`

  - `Optional<Long> limit`

    Specifies the number of buckets to return.

    - `bucket_width=1d`: default: 7, max: 31
    - `bucket_width=1h`: default: 24, max: 168
    - `bucket_width=1m`: default: 60, max: 1440

  - `Optional<List<String>> models`

    Return only usage for these models.

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only usage for these projects.

  - `Optional<List<String>> userIds`

    Return only usage for these users.

### Returns

- `class UsageCompletionsResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageCompletionsParams;
import com.openai.models.admin.organization.usage.UsageCompletionsResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageCompletionsParams params = UsageCompletionsParams.builder()
            .startTime(0L)
            .build();
        UsageCompletionsResponse response = client.admin().organization().usage().completions(params);
    }
}
```

#### Response

```json
{
  "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

`UsageEmbeddingsResponse admin().organization().usage().embeddings(UsageEmbeddingsParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/usage/embeddings`

Get embeddings usage details for the organization.

### Parameters

- `UsageEmbeddingsParams params`

  - `long startTime`

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

  - `Optional<List<String>> apiKeyIds`

    Return only usage for these API keys.

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1M("1m")`

    - `_1H("1h")`

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

    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("project_id")`

    - `USER_ID("user_id")`

    - `API_KEY_ID("api_key_id")`

    - `MODEL("model")`

  - `Optional<Long> limit`

    Specifies the number of buckets to return.

    - `bucket_width=1d`: default: 7, max: 31
    - `bucket_width=1h`: default: 24, max: 168
    - `bucket_width=1m`: default: 60, max: 1440

  - `Optional<List<String>> models`

    Return only usage for these models.

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only usage for these projects.

  - `Optional<List<String>> userIds`

    Return only usage for these users.

### Returns

- `class UsageEmbeddingsResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageEmbeddingsParams;
import com.openai.models.admin.organization.usage.UsageEmbeddingsResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageEmbeddingsParams params = UsageEmbeddingsParams.builder()
            .startTime(0L)
            .build();
        UsageEmbeddingsResponse response = client.admin().organization().usage().embeddings(params);
    }
}
```

#### Response

```json
{
  "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

`UsageImagesResponse admin().organization().usage().images(UsageImagesParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/usage/images`

Get images usage details for the organization.

### Parameters

- `UsageImagesParams params`

  - `long startTime`

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

  - `Optional<List<String>> apiKeyIds`

    Return only usage for these API keys.

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1M("1m")`

    - `_1H("1h")`

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

    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("project_id")`

    - `USER_ID("user_id")`

    - `API_KEY_ID("api_key_id")`

    - `MODEL("model")`

    - `SIZE("size")`

    - `SOURCE("source")`

  - `Optional<Long> limit`

    Specifies the number of buckets to return.

    - `bucket_width=1d`: default: 7, max: 31
    - `bucket_width=1h`: default: 24, max: 168
    - `bucket_width=1m`: default: 60, max: 1440

  - `Optional<List<String>> models`

    Return only usage for these models.

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only usage for these projects.

  - `Optional<List<Size>> sizes`

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

    - `_256X256("256x256")`

    - `_512X512("512x512")`

    - `_1024X1024("1024x1024")`

    - `_1792X1792("1792x1792")`

    - `_1024X1792("1024x1792")`

  - `Optional<List<Source>> sources`

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

    - `IMAGE_GENERATION("image.generation")`

    - `IMAGE_EDIT("image.edit")`

    - `IMAGE_VARIATION("image.variation")`

  - `Optional<List<String>> userIds`

    Return only usage for these users.

### Returns

- `class UsageImagesResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageImagesParams;
import com.openai.models.admin.organization.usage.UsageImagesResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageImagesParams params = UsageImagesParams.builder()
            .startTime(0L)
            .build();
        UsageImagesResponse response = client.admin().organization().usage().images(params);
    }
}
```

#### Response

```json
{
  "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

`UsageModerationsResponse admin().organization().usage().moderations(UsageModerationsParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/usage/moderations`

Get moderations usage details for the organization.

### Parameters

- `UsageModerationsParams params`

  - `long startTime`

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

  - `Optional<List<String>> apiKeyIds`

    Return only usage for these API keys.

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1M("1m")`

    - `_1H("1h")`

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

    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("project_id")`

    - `USER_ID("user_id")`

    - `API_KEY_ID("api_key_id")`

    - `MODEL("model")`

  - `Optional<Long> limit`

    Specifies the number of buckets to return.

    - `bucket_width=1d`: default: 7, max: 31
    - `bucket_width=1h`: default: 24, max: 168
    - `bucket_width=1m`: default: 60, max: 1440

  - `Optional<List<String>> models`

    Return only usage for these models.

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only usage for these projects.

  - `Optional<List<String>> userIds`

    Return only usage for these users.

### Returns

- `class UsageModerationsResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageModerationsParams;
import com.openai.models.admin.organization.usage.UsageModerationsResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageModerationsParams params = UsageModerationsParams.builder()
            .startTime(0L)
            .build();
        UsageModerationsResponse response = client.admin().organization().usage().moderations(params);
    }
}
```

#### Response

```json
{
  "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

`UsageVectorStoresResponse admin().organization().usage().vectorStores(UsageVectorStoresParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/usage/vector_stores`

Get vector stores usage details for the organization.

### Parameters

- `UsageVectorStoresParams params`

  - `long startTime`

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

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1M("1m")`

    - `_1H("1h")`

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

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

    - `PROJECT_ID("project_id")`

  - `Optional<Long> limit`

    Specifies the number of buckets to return.

    - `bucket_width=1d`: default: 7, max: 31
    - `bucket_width=1h`: default: 24, max: 168
    - `bucket_width=1m`: default: 60, max: 1440

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only usage for these projects.

### Returns

- `class UsageVectorStoresResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageVectorStoresParams;
import com.openai.models.admin.organization.usage.UsageVectorStoresResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageVectorStoresParams params = UsageVectorStoresParams.builder()
            .startTime(0L)
            .build();
        UsageVectorStoresResponse response = client.admin().organization().usage().vectorStores(params);
    }
}
```

#### Response

```json
{
  "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

`UsageCostsResponse admin().organization().usage().costs(UsageCostsParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/costs`

Get costs details for the organization.

### Parameters

- `UsageCostsParams params`

  - `long startTime`

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

  - `Optional<List<String>> apiKeyIds`

    Return only costs for these API keys.

  - `Optional<BucketWidth> bucketWidth`

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

    - `_1D("1d")`

  - `Optional<Long> endTime`

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

  - `Optional<List<GroupBy>> groupBy`

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

    - `PROJECT_ID("project_id")`

    - `LINE_ITEM("line_item")`

    - `API_KEY_ID("api_key_id")`

  - `Optional<Long> limit`

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

  - `Optional<String> page`

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

  - `Optional<List<String>> projectIds`

    Return only costs for these projects.

### Returns

- `class UsageCostsResponse:`

  - `List<Data> data`

    - `long endTime`

    - `JsonValue; object_ "bucket"constant`

      - `BUCKET("bucket")`

    - `List<Result> results`

      - `class OrganizationUsageCompletionsResult:`

        The aggregated completions usage details of the specific time bucket.

        - `long inputTokens`

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

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.completions.result"constant`

          - `ORGANIZATION_USAGE_COMPLETIONS_RESULT("organization.usage.completions.result")`

        - `long outputTokens`

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

        - `Optional<String> apiKeyId`

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

        - `Optional<Boolean> batch`

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

        - `Optional<Long> inputAudioTokens`

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

        - `Optional<Long> inputCachedTokens`

          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.

        - `Optional<String> model`

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

        - `Optional<Long> outputAudioTokens`

          The aggregated number of audio output tokens used.

        - `Optional<String> projectId`

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

        - `Optional<String> serviceTier`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.embeddings.result"constant`

          - `ORGANIZATION_USAGE_EMBEDDINGS_RESULT("organization.usage.embeddings.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long inputTokens`

          The aggregated number of input tokens used.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.moderations.result"constant`

          - `ORGANIZATION_USAGE_MODERATIONS_RESULT("organization.usage.moderations.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long images`

          The number of images processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.images.result"constant`

          - `ORGANIZATION_USAGE_IMAGES_RESULT("organization.usage.images.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> size`

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

        - `Optional<String> source`

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

        - `Optional<String> userId`

          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.

        - `long characters`

          The number of characters processed.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_speeches.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_SPEECHES_RESULT("organization.usage.audio_speeches.result")`

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `long numModelRequests`

          The count of requests made to the model.

        - `JsonValue; object_ "organization.usage.audio_transcriptions.result"constant`

          - `ORGANIZATION_USAGE_AUDIO_TRANSCRIPTIONS_RESULT("organization.usage.audio_transcriptions.result")`

        - `long seconds`

          The number of seconds processed.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> model`

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

        - `Optional<String> projectId`

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

        - `Optional<String> userId`

          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.

        - `JsonValue; object_ "organization.usage.vector_stores.result"constant`

          - `ORGANIZATION_USAGE_VECTOR_STORES_RESULT("organization.usage.vector_stores.result")`

        - `long usageBytes`

          The vector stores usage in bytes.

        - `Optional<String> projectId`

          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.

        - `long numSessions`

          The number of code interpreter sessions.

        - `JsonValue; object_ "organization.usage.code_interpreter_sessions.result"constant`

          - `ORGANIZATION_USAGE_CODE_INTERPRETER_SESSIONS_RESULT("organization.usage.code_interpreter_sessions.result")`

        - `Optional<String> projectId`

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

      - `class OrganizationCostsResult:`

        The aggregated costs details of the specific time bucket.

        - `JsonValue; object_ "organization.costs.result"constant`

          - `ORGANIZATION_COSTS_RESULT("organization.costs.result")`

        - `Optional<Amount> amount`

          The monetary value in its associated currency.

          - `Optional<String> currency`

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

          - `Optional<Double> value`

            The numeric value of the cost.

        - `Optional<String> apiKeyId`

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

        - `Optional<String> lineItem`

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

        - `Optional<String> projectId`

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

        - `Optional<Double> quantity`

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

    - `long startTime`

  - `boolean hasMore`

  - `Optional<String> nextPage`

  - `JsonValue; object_ "page"constant`

    - `PAGE("page")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.usage.UsageCostsParams;
import com.openai.models.admin.organization.usage.UsageCostsResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UsageCostsParams params = UsageCostsParams.builder()
            .startTime(0L)
            .build();
        UsageCostsResponse response = client.admin().organization().usage().costs(params);
    }
}
```

#### Response

```json
{
  "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"
}
```

# Invites

## List invites

`InviteListPage admin().organization().invites().list(InviteListParamsparams = InviteListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/invites`

Returns a list of invites in the organization.

### Parameters

- `InviteListParams params`

  - `Optional<String> after`

    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.

  - `Optional<Long> limit`

    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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

    The Unix timestamp (in seconds) of when the invite was sent.

  - `String email`

    The email address of the individual to whom the invite was sent

  - `JsonValue; object_ "organization.invite"constant`

    The object type, which is always `organization.invite`

    - `ORGANIZATION_INVITE("organization.invite")`

  - `List<Project> projects`

    The projects that were granted membership upon acceptance of the invite.

    - `String id`

      Project's public ID

    - `Role role`

      Project membership role

      - `MEMBER("member")`

      - `OWNER("owner")`

  - `Role role`

    `owner` or `reader`

    - `OWNER("owner")`

    - `READER("reader")`

  - `Status status`

    `accepted`,`expired`, or `pending`

    - `ACCEPTED("accepted")`

    - `EXPIRED("expired")`

    - `PENDING("pending")`

  - `Optional<Long> acceptedAt`

    The Unix timestamp (in seconds) of when the invite was accepted.

  - `Optional<Long> expiresAt`

    The Unix timestamp (in seconds) of when the invite expires.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.invites.InviteListPage;
import com.openai.models.admin.organization.invites.InviteListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        InviteListPage page = client.admin().organization().invites().list();
    }
}
```

#### Response

```json
{
  "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

`Invite admin().organization().invites().create(InviteCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/invites`

Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization.

### Parameters

- `InviteCreateParams params`

  - `String email`

    Send an email to this address

  - `Role role`

    `owner` or `reader`

    - `READER("reader")`

    - `OWNER("owner")`

  - `Optional<List<Project>> projects`

    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.

    - `String id`

      Project's public ID

    - `Role role`

      Project membership role

      - `MEMBER("member")`

      - `OWNER("owner")`

### Returns

- `class Invite:`

  Represents an individual `invite` to the organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

    The Unix timestamp (in seconds) of when the invite was sent.

  - `String email`

    The email address of the individual to whom the invite was sent

  - `JsonValue; object_ "organization.invite"constant`

    The object type, which is always `organization.invite`

    - `ORGANIZATION_INVITE("organization.invite")`

  - `List<Project> projects`

    The projects that were granted membership upon acceptance of the invite.

    - `String id`

      Project's public ID

    - `Role role`

      Project membership role

      - `MEMBER("member")`

      - `OWNER("owner")`

  - `Role role`

    `owner` or `reader`

    - `OWNER("owner")`

    - `READER("reader")`

  - `Status status`

    `accepted`,`expired`, or `pending`

    - `ACCEPTED("accepted")`

    - `EXPIRED("expired")`

    - `PENDING("pending")`

  - `Optional<Long> acceptedAt`

    The Unix timestamp (in seconds) of when the invite was accepted.

  - `Optional<Long> expiresAt`

    The Unix timestamp (in seconds) of when the invite expires.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.invites.Invite;
import com.openai.models.admin.organization.invites.InviteCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        InviteCreateParams params = InviteCreateParams.builder()
            .email("email")
            .role(InviteCreateParams.Role.READER)
            .build();
        Invite invite = client.admin().organization().invites().create(params);
    }
}
```

#### Response

```json
{
  "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

`Invite admin().organization().invites().retrieve(InviteRetrieveParamsparams = InviteRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/invites/{invite_id}`

Retrieves an invite.

### Parameters

- `InviteRetrieveParams params`

  - `Optional<String> inviteId`

### Returns

- `class Invite:`

  Represents an individual `invite` to the organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

    The Unix timestamp (in seconds) of when the invite was sent.

  - `String email`

    The email address of the individual to whom the invite was sent

  - `JsonValue; object_ "organization.invite"constant`

    The object type, which is always `organization.invite`

    - `ORGANIZATION_INVITE("organization.invite")`

  - `List<Project> projects`

    The projects that were granted membership upon acceptance of the invite.

    - `String id`

      Project's public ID

    - `Role role`

      Project membership role

      - `MEMBER("member")`

      - `OWNER("owner")`

  - `Role role`

    `owner` or `reader`

    - `OWNER("owner")`

    - `READER("reader")`

  - `Status status`

    `accepted`,`expired`, or `pending`

    - `ACCEPTED("accepted")`

    - `EXPIRED("expired")`

    - `PENDING("pending")`

  - `Optional<Long> acceptedAt`

    The Unix timestamp (in seconds) of when the invite was accepted.

  - `Optional<Long> expiresAt`

    The Unix timestamp (in seconds) of when the invite expires.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.invites.Invite;
import com.openai.models.admin.organization.invites.InviteRetrieveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        Invite invite = client.admin().organization().invites().retrieve("invite_id");
    }
}
```

#### Response

```json
{
  "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

`InviteDeleteResponse admin().organization().invites().delete(InviteDeleteParamsparams = InviteDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/invites/{invite_id}`

Delete an invite. If the invite has already been accepted, it cannot be deleted.

### Parameters

- `InviteDeleteParams params`

  - `Optional<String> inviteId`

### Returns

- `class InviteDeleteResponse:`

  - `String id`

  - `boolean deleted`

  - `JsonValue; object_ "organization.invite.deleted"constant`

    The object type, which is always `organization.invite.deleted`

    - `ORGANIZATION_INVITE_DELETED("organization.invite.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.invites.InviteDeleteParams;
import com.openai.models.admin.organization.invites.InviteDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        InviteDeleteResponse invite = client.admin().organization().invites().delete("invite_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "deleted": true,
  "object": "organization.invite.deleted"
}
```

## Domain Types

### Invite

- `class Invite:`

  Represents an individual `invite` to the organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

    The Unix timestamp (in seconds) of when the invite was sent.

  - `String email`

    The email address of the individual to whom the invite was sent

  - `JsonValue; object_ "organization.invite"constant`

    The object type, which is always `organization.invite`

    - `ORGANIZATION_INVITE("organization.invite")`

  - `List<Project> projects`

    The projects that were granted membership upon acceptance of the invite.

    - `String id`

      Project's public ID

    - `Role role`

      Project membership role

      - `MEMBER("member")`

      - `OWNER("owner")`

  - `Role role`

    `owner` or `reader`

    - `OWNER("owner")`

    - `READER("reader")`

  - `Status status`

    `accepted`,`expired`, or `pending`

    - `ACCEPTED("accepted")`

    - `EXPIRED("expired")`

    - `PENDING("pending")`

  - `Optional<Long> acceptedAt`

    The Unix timestamp (in seconds) of when the invite was accepted.

  - `Optional<Long> expiresAt`

    The Unix timestamp (in seconds) of when the invite expires.

# Users

## List users

`UserListPage admin().organization().users().list(UserListParamsparams = UserListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/users`

Lists all of the users in the organization.

### Parameters

- `UserListParams params`

  - `Optional<String> after`

    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.

  - `Optional<List<String>> emails`

    Filter by the email address of users.

  - `Optional<Long> limit`

    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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

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

  - `JsonValue; object_ "organization.user"constant`

    The object type, which is always `organization.user`

    - `ORGANIZATION_USER("organization.user")`

  - `Optional<Long> apiKeyLastUsedAt`

    The Unix timestamp (in seconds) of the user's last API key usage.

  - `Optional<Long> created`

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

  - `Optional<String> developerPersona`

    The developer persona metadata for the user.

  - `Optional<String> email`

    The email address of the user

  - `Optional<Boolean> isDefault`

    Whether this is the organization's default user.

  - `Optional<Boolean> isScaleTierAuthorizedPurchaser`

    Whether the user is an authorized purchaser for Scale Tier.

  - `Optional<Boolean> isScimManaged`

    Whether the user is managed through SCIM.

  - `Optional<Boolean> isServiceAccount`

    Whether the user is a service account.

  - `Optional<String> name`

    The name of the user

  - `Optional<Projects> projects`

    Projects associated with the user, if included.

    - `List<Data> data`

      - `Optional<String> id`

      - `Optional<String> name`

      - `Optional<String> role`

    - `JsonValue; object_ "list"constant`

      - `LIST("list")`

  - `Optional<String> role`

    `owner` or `reader`

  - `Optional<String> technicalLevel`

    The technical level metadata for the user.

  - `Optional<User> user`

    Nested user details.

    - `String id`

    - `JsonValue; object_ "user"constant`

      - `USER("user")`

    - `Optional<Boolean> banned`

    - `Optional<Long> bannedAt`

    - `Optional<String> email`

    - `Optional<Boolean> enabled`

    - `Optional<String> name`

    - `Optional<String> picture`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.users.UserListPage;
import com.openai.models.admin.organization.users.UserListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserListPage page = client.admin().organization().users().list();
    }
}
```

#### Response

```json
{
  "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

`OrganizationUser admin().organization().users().retrieve(UserRetrieveParamsparams = UserRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/users/{user_id}`

Retrieves a user by their identifier.

### Parameters

- `UserRetrieveParams params`

  - `Optional<String> userId`

### Returns

- `class OrganizationUser:`

  Represents an individual `user` within an organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

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

  - `JsonValue; object_ "organization.user"constant`

    The object type, which is always `organization.user`

    - `ORGANIZATION_USER("organization.user")`

  - `Optional<Long> apiKeyLastUsedAt`

    The Unix timestamp (in seconds) of the user's last API key usage.

  - `Optional<Long> created`

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

  - `Optional<String> developerPersona`

    The developer persona metadata for the user.

  - `Optional<String> email`

    The email address of the user

  - `Optional<Boolean> isDefault`

    Whether this is the organization's default user.

  - `Optional<Boolean> isScaleTierAuthorizedPurchaser`

    Whether the user is an authorized purchaser for Scale Tier.

  - `Optional<Boolean> isScimManaged`

    Whether the user is managed through SCIM.

  - `Optional<Boolean> isServiceAccount`

    Whether the user is a service account.

  - `Optional<String> name`

    The name of the user

  - `Optional<Projects> projects`

    Projects associated with the user, if included.

    - `List<Data> data`

      - `Optional<String> id`

      - `Optional<String> name`

      - `Optional<String> role`

    - `JsonValue; object_ "list"constant`

      - `LIST("list")`

  - `Optional<String> role`

    `owner` or `reader`

  - `Optional<String> technicalLevel`

    The technical level metadata for the user.

  - `Optional<User> user`

    Nested user details.

    - `String id`

    - `JsonValue; object_ "user"constant`

      - `USER("user")`

    - `Optional<Boolean> banned`

    - `Optional<Long> bannedAt`

    - `Optional<String> email`

    - `Optional<Boolean> enabled`

    - `Optional<String> name`

    - `Optional<String> picture`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.users.OrganizationUser;
import com.openai.models.admin.organization.users.UserRetrieveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        OrganizationUser organizationUser = client.admin().organization().users().retrieve("user_id");
    }
}
```

#### Response

```json
{
  "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

`OrganizationUser admin().organization().users().update(UserUpdateParamsparams = UserUpdateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/users/{user_id}`

Modifies a user's role in the organization.

### Parameters

- `UserUpdateParams params`

  - `Optional<String> userId`

  - `Optional<String> developerPersona`

    Developer persona metadata.

  - `Optional<String> role`

    `owner` or `reader`

  - `Optional<String> roleId`

    Role ID to assign to the user.

  - `Optional<String> technicalLevel`

    Technical level metadata.

### Returns

- `class OrganizationUser:`

  Represents an individual `user` within an organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

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

  - `JsonValue; object_ "organization.user"constant`

    The object type, which is always `organization.user`

    - `ORGANIZATION_USER("organization.user")`

  - `Optional<Long> apiKeyLastUsedAt`

    The Unix timestamp (in seconds) of the user's last API key usage.

  - `Optional<Long> created`

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

  - `Optional<String> developerPersona`

    The developer persona metadata for the user.

  - `Optional<String> email`

    The email address of the user

  - `Optional<Boolean> isDefault`

    Whether this is the organization's default user.

  - `Optional<Boolean> isScaleTierAuthorizedPurchaser`

    Whether the user is an authorized purchaser for Scale Tier.

  - `Optional<Boolean> isScimManaged`

    Whether the user is managed through SCIM.

  - `Optional<Boolean> isServiceAccount`

    Whether the user is a service account.

  - `Optional<String> name`

    The name of the user

  - `Optional<Projects> projects`

    Projects associated with the user, if included.

    - `List<Data> data`

      - `Optional<String> id`

      - `Optional<String> name`

      - `Optional<String> role`

    - `JsonValue; object_ "list"constant`

      - `LIST("list")`

  - `Optional<String> role`

    `owner` or `reader`

  - `Optional<String> technicalLevel`

    The technical level metadata for the user.

  - `Optional<User> user`

    Nested user details.

    - `String id`

    - `JsonValue; object_ "user"constant`

      - `USER("user")`

    - `Optional<Boolean> banned`

    - `Optional<Long> bannedAt`

    - `Optional<String> email`

    - `Optional<Boolean> enabled`

    - `Optional<String> name`

    - `Optional<String> picture`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.users.OrganizationUser;
import com.openai.models.admin.organization.users.UserUpdateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        OrganizationUser organizationUser = client.admin().organization().users().update("user_id");
    }
}
```

#### Response

```json
{
  "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

`UserDeleteResponse admin().organization().users().delete(UserDeleteParamsparams = UserDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/users/{user_id}`

Deletes a user from the organization.

### Parameters

- `UserDeleteParams params`

  - `Optional<String> userId`

### Returns

- `class UserDeleteResponse:`

  - `String id`

  - `boolean deleted`

  - `JsonValue; object_ "organization.user.deleted"constant`

    - `ORGANIZATION_USER_DELETED("organization.user.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.users.UserDeleteParams;
import com.openai.models.admin.organization.users.UserDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserDeleteResponse user = client.admin().organization().users().delete("user_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "deleted": true,
  "object": "organization.user.deleted"
}
```

## Domain Types

### Organization User

- `class OrganizationUser:`

  Represents an individual `user` within an organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

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

  - `JsonValue; object_ "organization.user"constant`

    The object type, which is always `organization.user`

    - `ORGANIZATION_USER("organization.user")`

  - `Optional<Long> apiKeyLastUsedAt`

    The Unix timestamp (in seconds) of the user's last API key usage.

  - `Optional<Long> created`

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

  - `Optional<String> developerPersona`

    The developer persona metadata for the user.

  - `Optional<String> email`

    The email address of the user

  - `Optional<Boolean> isDefault`

    Whether this is the organization's default user.

  - `Optional<Boolean> isScaleTierAuthorizedPurchaser`

    Whether the user is an authorized purchaser for Scale Tier.

  - `Optional<Boolean> isScimManaged`

    Whether the user is managed through SCIM.

  - `Optional<Boolean> isServiceAccount`

    Whether the user is a service account.

  - `Optional<String> name`

    The name of the user

  - `Optional<Projects> projects`

    Projects associated with the user, if included.

    - `List<Data> data`

      - `Optional<String> id`

      - `Optional<String> name`

      - `Optional<String> role`

    - `JsonValue; object_ "list"constant`

      - `LIST("list")`

  - `Optional<String> role`

    `owner` or `reader`

  - `Optional<String> technicalLevel`

    The technical level metadata for the user.

  - `Optional<User> user`

    Nested user details.

    - `String id`

    - `JsonValue; object_ "user"constant`

      - `USER("user")`

    - `Optional<Boolean> banned`

    - `Optional<Long> bannedAt`

    - `Optional<String> email`

    - `Optional<Boolean> enabled`

    - `Optional<String> name`

    - `Optional<String> picture`

# Roles

## List user organization role assignments

`RoleListPage admin().organization().users().roles().list(RoleListParamsparams = RoleListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/users/{user_id}/roles`

Lists the organization roles assigned to a user within the organization.

### Parameters

- `RoleListParams params`

  - `Optional<String> userId`

  - `Optional<String> after`

    Cursor for pagination. Provide the value from the previous response's `next` field to continue listing organization roles.

  - `Optional<Long> limit`

    A limit on the number of organization role assignments to return.

  - `Optional<Order> order`

    Sort order for the returned organization roles.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class RoleListResponse:`

  Detailed information about a role assignment entry returned when listing assignments.

  - `String id`

    Identifier for the role.

  - `Optional<Long> createdAt`

    When the role was created.

  - `Optional<String> createdBy`

    Identifier of the actor who created the role.

  - `Optional<CreatedByUserObj> createdByUserObj`

    User details for the actor that created the role, when available.

  - `Optional<String> description`

    Description of the role.

  - `Optional<Metadata> metadata`

    Arbitrary metadata stored on the role.

  - `String name`

    Name of the role.

  - `List<String> permissions`

    Permissions associated with the role.

  - `boolean predefinedRole`

    Whether the role is predefined by OpenAI.

  - `String resourceType`

    Resource type the role applies to.

  - `Optional<Long> updatedAt`

    When the role was last updated.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.users.roles.RoleListPage;
import com.openai.models.admin.organization.users.roles.RoleListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleListPage page = client.admin().organization().users().roles().list("user_id");
    }
}
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "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

`RoleCreateResponse admin().organization().users().roles().create(RoleCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/users/{user_id}/roles`

Assigns an organization role to a user within the organization.

### Parameters

- `RoleCreateParams params`

  - `Optional<String> userId`

  - `String roleId`

    Identifier of the role to assign.

### Returns

- `class RoleCreateResponse:`

  Role assignment linking a user to a role.

  - `JsonValue; object_ "user.role"constant`

    Always `user.role`.

    - `USER_ROLE("user.role")`

  - `Role role`

    Details about a role that can be assigned through the public Roles API.

    - `String id`

      Identifier for the role.

    - `Optional<String> description`

      Optional description of the role.

    - `String name`

      Unique name for the role.

    - `JsonValue; object_ "role"constant`

      Always `role`.

      - `ROLE("role")`

    - `List<String> permissions`

      Permissions granted by the role.

    - `boolean predefinedRole`

      Whether the role is predefined and managed by OpenAI.

    - `String resourceType`

      Resource type the role is bound to (for example `api.organization` or `api.project`).

  - `OrganizationUser user`

    Represents an individual `user` within an organization.

    - `String id`

      The identifier, which can be referenced in API endpoints

    - `long addedAt`

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

    - `JsonValue; object_ "organization.user"constant`

      The object type, which is always `organization.user`

      - `ORGANIZATION_USER("organization.user")`

    - `Optional<Long> apiKeyLastUsedAt`

      The Unix timestamp (in seconds) of the user's last API key usage.

    - `Optional<Long> created`

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

    - `Optional<String> developerPersona`

      The developer persona metadata for the user.

    - `Optional<String> email`

      The email address of the user

    - `Optional<Boolean> isDefault`

      Whether this is the organization's default user.

    - `Optional<Boolean> isScaleTierAuthorizedPurchaser`

      Whether the user is an authorized purchaser for Scale Tier.

    - `Optional<Boolean> isScimManaged`

      Whether the user is managed through SCIM.

    - `Optional<Boolean> isServiceAccount`

      Whether the user is a service account.

    - `Optional<String> name`

      The name of the user

    - `Optional<Projects> projects`

      Projects associated with the user, if included.

      - `List<Data> data`

        - `Optional<String> id`

        - `Optional<String> name`

        - `Optional<String> role`

      - `JsonValue; object_ "list"constant`

        - `LIST("list")`

    - `Optional<String> role`

      `owner` or `reader`

    - `Optional<String> technicalLevel`

      The technical level metadata for the user.

    - `Optional<User> user`

      Nested user details.

      - `String id`

      - `JsonValue; object_ "user"constant`

        - `USER("user")`

      - `Optional<Boolean> banned`

      - `Optional<Long> bannedAt`

      - `Optional<String> email`

      - `Optional<Boolean> enabled`

      - `Optional<String> name`

      - `Optional<String> picture`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.users.roles.RoleCreateParams;
import com.openai.models.admin.organization.users.roles.RoleCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleCreateParams params = RoleCreateParams.builder()
            .userId("user_id")
            .roleId("role_id")
            .build();
        RoleCreateResponse role = client.admin().organization().users().roles().create(params);
    }
}
```

#### Response

```json
{
  "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"
    }
  }
}
```

## Unassign organization role from user

`RoleDeleteResponse admin().organization().users().roles().delete(RoleDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/users/{user_id}/roles/{role_id}`

Unassigns an organization role from a user within the organization.

### Parameters

- `RoleDeleteParams params`

  - `String userId`

  - `Optional<String> roleId`

### Returns

- `class RoleDeleteResponse:`

  Confirmation payload returned after unassigning a role.

  - `boolean deleted`

    Whether the assignment was removed.

  - `String object_`

    Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.users.roles.RoleDeleteParams;
import com.openai.models.admin.organization.users.roles.RoleDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleDeleteParams params = RoleDeleteParams.builder()
            .userId("user_id")
            .roleId("role_id")
            .build();
        RoleDeleteResponse role = client.admin().organization().users().roles().delete(params);
    }
}
```

#### Response

```json
{
  "deleted": true,
  "object": "object"
}
```

# Groups

## List groups

`GroupListPage admin().organization().groups().list(GroupListParamsparams = GroupListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/groups`

Lists all groups in the organization.

### Parameters

- `GroupListParams params`

  - `Optional<String> after`

    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.

  - `Optional<Long> limit`

    A limit on the number of groups to be returned. Limit can range between 0 and 1000, and the default is 100.

  - `Optional<Order> order`

    Specifies the sort order of the returned groups.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class Group:`

  Details about an organization group.

  - `String id`

    Identifier for the group.

  - `long createdAt`

    Unix timestamp (in seconds) when the group was created.

  - `String groupType`

    The type of the group.

  - `boolean isScimManaged`

    Whether the group is managed through SCIM and controlled by your identity provider.

  - `String name`

    Display name of the group.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.GroupListPage;
import com.openai.models.admin.organization.groups.GroupListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        GroupListPage page = client.admin().organization().groups().list();
    }
}
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "group_type": "group_type",
      "is_scim_managed": true,
      "name": "name"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}
```

## Create group

`Group admin().organization().groups().create(GroupCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/groups`

Creates a new group in the organization.

### Parameters

- `GroupCreateParams params`

  - `String name`

    Human readable name for the group.

### Returns

- `class Group:`

  Details about an organization group.

  - `String id`

    Identifier for the group.

  - `long createdAt`

    Unix timestamp (in seconds) when the group was created.

  - `String groupType`

    The type of the group.

  - `boolean isScimManaged`

    Whether the group is managed through SCIM and controlled by your identity provider.

  - `String name`

    Display name of the group.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.Group;
import com.openai.models.admin.organization.groups.GroupCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        GroupCreateParams params = GroupCreateParams.builder()
            .name("x")
            .build();
        Group group = client.admin().organization().groups().create(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "created_at": 0,
  "group_type": "group_type",
  "is_scim_managed": true,
  "name": "name"
}
```

## Update group

`GroupUpdateResponse admin().organization().groups().update(GroupUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/groups/{group_id}`

Updates a group's information.

### Parameters

- `GroupUpdateParams params`

  - `Optional<String> groupId`

  - `String name`

    New display name for the group.

### Returns

- `class GroupUpdateResponse:`

  Response returned after updating a group.

  - `String id`

    Identifier for the group.

  - `long createdAt`

    Unix timestamp (in seconds) when the group was created.

  - `boolean isScimManaged`

    Whether the group is managed through SCIM and controlled by your identity provider.

  - `String name`

    Updated display name for the group.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.GroupUpdateParams;
import com.openai.models.admin.organization.groups.GroupUpdateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        GroupUpdateParams params = GroupUpdateParams.builder()
            .groupId("group_id")
            .name("x")
            .build();
        GroupUpdateResponse group = client.admin().organization().groups().update(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "created_at": 0,
  "is_scim_managed": true,
  "name": "name"
}
```

## Delete group

`GroupDeleteResponse admin().organization().groups().delete(GroupDeleteParamsparams = GroupDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/groups/{group_id}`

Deletes a group from the organization.

### Parameters

- `GroupDeleteParams params`

  - `Optional<String> groupId`

### Returns

- `class GroupDeleteResponse:`

  Confirmation payload returned after deleting a group.

  - `String id`

    Identifier of the deleted group.

  - `boolean deleted`

    Whether the group was deleted.

  - `JsonValue; object_ "group.deleted"constant`

    Always `group.deleted`.

    - `GROUP_DELETED("group.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.GroupDeleteParams;
import com.openai.models.admin.organization.groups.GroupDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        GroupDeleteResponse group = client.admin().organization().groups().delete("group_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "deleted": true,
  "object": "group.deleted"
}
```

## Domain Types

### Group

- `class Group:`

  Details about an organization group.

  - `String id`

    Identifier for the group.

  - `long createdAt`

    Unix timestamp (in seconds) when the group was created.

  - `String groupType`

    The type of the group.

  - `boolean isScimManaged`

    Whether the group is managed through SCIM and controlled by your identity provider.

  - `String name`

    Display name of the group.

# Users

## List group users

`UserListPage admin().organization().groups().users().list(UserListParamsparams = UserListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/groups/{group_id}/users`

Lists the users assigned to a group.

### Parameters

- `UserListParams params`

  - `Optional<String> groupId`

  - `Optional<String> after`

    A cursor for use in pagination. Provide the ID of the last user from the previous list response to retrieve the next page.

  - `Optional<Long> limit`

    A limit on the number of users to be returned. Limit can range between 0 and 1000, and the default is 100.

  - `Optional<Order> order`

    Specifies the sort order of users in the list.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class OrganizationGroupUser:`

  Represents an individual user returned when inspecting group membership.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `Optional<String> email`

    The email address of the user.

  - `String name`

    The name of the user.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.users.UserListPage;
import com.openai.models.admin.organization.groups.users.UserListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserListPage page = client.admin().organization().groups().users().list("group_id");
    }
}
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "email": "email",
      "name": "name"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}
```

## Add group user

`UserCreateResponse admin().organization().groups().users().create(UserCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/groups/{group_id}/users`

Adds a user to a group.

### Parameters

- `UserCreateParams params`

  - `Optional<String> groupId`

  - `String userId`

    Identifier of the user to add to the group.

### Returns

- `class UserCreateResponse:`

  Confirmation payload returned after adding a user to a group.

  - `String groupId`

    Identifier of the group the user was added to.

  - `JsonValue; object_ "group.user"constant`

    Always `group.user`.

    - `GROUP_USER("group.user")`

  - `String userId`

    Identifier of the user that was added.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.users.UserCreateParams;
import com.openai.models.admin.organization.groups.users.UserCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserCreateParams params = UserCreateParams.builder()
            .groupId("group_id")
            .userId("user_id")
            .build();
        UserCreateResponse user = client.admin().organization().groups().users().create(params);
    }
}
```

#### Response

```json
{
  "group_id": "group_id",
  "object": "group.user",
  "user_id": "user_id"
}
```

## Remove group user

`UserDeleteResponse admin().organization().groups().users().delete(UserDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/groups/{group_id}/users/{user_id}`

Removes a user from a group.

### Parameters

- `UserDeleteParams params`

  - `String groupId`

  - `Optional<String> userId`

### Returns

- `class UserDeleteResponse:`

  Confirmation payload returned after removing a user from a group.

  - `boolean deleted`

    Whether the group membership was removed.

  - `JsonValue; object_ "group.user.deleted"constant`

    Always `group.user.deleted`.

    - `GROUP_USER_DELETED("group.user.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.users.UserDeleteParams;
import com.openai.models.admin.organization.groups.users.UserDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserDeleteParams params = UserDeleteParams.builder()
            .groupId("group_id")
            .userId("user_id")
            .build();
        UserDeleteResponse user = client.admin().organization().groups().users().delete(params);
    }
}
```

#### Response

```json
{
  "deleted": true,
  "object": "group.user.deleted"
}
```

## Domain Types

### Organization Group User

- `class OrganizationGroupUser:`

  Represents an individual user returned when inspecting group membership.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `Optional<String> email`

    The email address of the user.

  - `String name`

    The name of the user.

# Roles

## List group organization role assignments

`RoleListPage admin().organization().groups().roles().list(RoleListParamsparams = RoleListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/groups/{group_id}/roles`

Lists the organization roles assigned to a group within the organization.

### Parameters

- `RoleListParams params`

  - `Optional<String> groupId`

  - `Optional<String> after`

    Cursor for pagination. Provide the value from the previous response's `next` field to continue listing organization roles.

  - `Optional<Long> limit`

    A limit on the number of organization role assignments to return.

  - `Optional<Order> order`

    Sort order for the returned organization roles.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class RoleListResponse:`

  Detailed information about a role assignment entry returned when listing assignments.

  - `String id`

    Identifier for the role.

  - `Optional<Long> createdAt`

    When the role was created.

  - `Optional<String> createdBy`

    Identifier of the actor who created the role.

  - `Optional<CreatedByUserObj> createdByUserObj`

    User details for the actor that created the role, when available.

  - `Optional<String> description`

    Description of the role.

  - `Optional<Metadata> metadata`

    Arbitrary metadata stored on the role.

  - `String name`

    Name of the role.

  - `List<String> permissions`

    Permissions associated with the role.

  - `boolean predefinedRole`

    Whether the role is predefined by OpenAI.

  - `String resourceType`

    Resource type the role applies to.

  - `Optional<Long> updatedAt`

    When the role was last updated.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.roles.RoleListPage;
import com.openai.models.admin.organization.groups.roles.RoleListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleListPage page = client.admin().organization().groups().roles().list("group_id");
    }
}
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "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

`RoleCreateResponse admin().organization().groups().roles().create(RoleCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/groups/{group_id}/roles`

Assigns an organization role to a group within the organization.

### Parameters

- `RoleCreateParams params`

  - `Optional<String> groupId`

  - `String roleId`

    Identifier of the role to assign.

### Returns

- `class RoleCreateResponse:`

  Role assignment linking a group to a role.

  - `Group group`

    Summary information about a group returned in role assignment responses.

    - `String id`

      Identifier for the group.

    - `long createdAt`

      Unix timestamp (in seconds) when the group was created.

    - `String name`

      Display name of the group.

    - `JsonValue; object_ "group"constant`

      Always `group`.

      - `GROUP("group")`

    - `boolean scimManaged`

      Whether the group is managed through SCIM.

  - `JsonValue; object_ "group.role"constant`

    Always `group.role`.

    - `GROUP_ROLE("group.role")`

  - `Role role`

    Details about a role that can be assigned through the public Roles API.

    - `String id`

      Identifier for the role.

    - `Optional<String> description`

      Optional description of the role.

    - `String name`

      Unique name for the role.

    - `JsonValue; object_ "role"constant`

      Always `role`.

      - `ROLE("role")`

    - `List<String> permissions`

      Permissions granted by the role.

    - `boolean predefinedRole`

      Whether the role is predefined and managed by OpenAI.

    - `String resourceType`

      Resource type the role is bound to (for example `api.organization` or `api.project`).

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.roles.RoleCreateParams;
import com.openai.models.admin.organization.groups.roles.RoleCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleCreateParams params = RoleCreateParams.builder()
            .groupId("group_id")
            .roleId("role_id")
            .build();
        RoleCreateResponse role = client.admin().organization().groups().roles().create(params);
    }
}
```

#### Response

```json
{
  "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"
  }
}
```

## Unassign organization role from group

`RoleDeleteResponse admin().organization().groups().roles().delete(RoleDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/groups/{group_id}/roles/{role_id}`

Unassigns an organization role from a group within the organization.

### Parameters

- `RoleDeleteParams params`

  - `String groupId`

  - `Optional<String> roleId`

### Returns

- `class RoleDeleteResponse:`

  Confirmation payload returned after unassigning a role.

  - `boolean deleted`

    Whether the assignment was removed.

  - `String object_`

    Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.groups.roles.RoleDeleteParams;
import com.openai.models.admin.organization.groups.roles.RoleDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleDeleteParams params = RoleDeleteParams.builder()
            .groupId("group_id")
            .roleId("role_id")
            .build();
        RoleDeleteResponse role = client.admin().organization().groups().roles().delete(params);
    }
}
```

#### Response

```json
{
  "deleted": true,
  "object": "object"
}
```

# Roles

## List organization roles

`RoleListPage admin().organization().roles().list(RoleListParamsparams = RoleListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/roles`

Lists the roles configured for the organization.

### Parameters

- `RoleListParams params`

  - `Optional<String> after`

    Cursor for pagination. Provide the value from the previous response's `next` field to continue listing roles.

  - `Optional<Long> limit`

    A limit on the number of roles to return. Defaults to 1000.

  - `Optional<Order> order`

    Sort order for the returned roles.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class Role:`

  Details about a role that can be assigned through the public Roles API.

  - `String id`

    Identifier for the role.

  - `Optional<String> description`

    Optional description of the role.

  - `String name`

    Unique name for the role.

  - `JsonValue; object_ "role"constant`

    Always `role`.

    - `ROLE("role")`

  - `List<String> permissions`

    Permissions granted by the role.

  - `boolean predefinedRole`

    Whether the role is predefined and managed by OpenAI.

  - `String resourceType`

    Resource type the role is bound to (for example `api.organization` or `api.project`).

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.roles.RoleListPage;
import com.openai.models.admin.organization.roles.RoleListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleListPage page = client.admin().organization().roles().list();
    }
}
```

#### Response

```json
{
  "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

`Role admin().organization().roles().create(RoleCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/roles`

Creates a custom role for the organization.

### Parameters

- `RoleCreateParams params`

  - `List<String> permissions`

    Permissions to grant to the role.

  - `String roleName`

    Unique name for the role.

  - `Optional<String> description`

    Optional description of the role.

### Returns

- `class Role:`

  Details about a role that can be assigned through the public Roles API.

  - `String id`

    Identifier for the role.

  - `Optional<String> description`

    Optional description of the role.

  - `String name`

    Unique name for the role.

  - `JsonValue; object_ "role"constant`

    Always `role`.

    - `ROLE("role")`

  - `List<String> permissions`

    Permissions granted by the role.

  - `boolean predefinedRole`

    Whether the role is predefined and managed by OpenAI.

  - `String resourceType`

    Resource type the role is bound to (for example `api.organization` or `api.project`).

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.roles.Role;
import com.openai.models.admin.organization.roles.RoleCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleCreateParams params = RoleCreateParams.builder()
            .addPermission("string")
            .roleName("role_name")
            .build();
        Role role = client.admin().organization().roles().create(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}
```

## Update organization role

`Role admin().organization().roles().update(RoleUpdateParamsparams = RoleUpdateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/roles/{role_id}`

Updates an existing organization role.

### Parameters

- `RoleUpdateParams params`

  - `Optional<String> roleId`

  - `Optional<String> description`

    New description for the role.

  - `Optional<List<String>> permissions`

    Updated set of permissions for the role.

  - `Optional<String> roleName`

    New name for the role.

### Returns

- `class Role:`

  Details about a role that can be assigned through the public Roles API.

  - `String id`

    Identifier for the role.

  - `Optional<String> description`

    Optional description of the role.

  - `String name`

    Unique name for the role.

  - `JsonValue; object_ "role"constant`

    Always `role`.

    - `ROLE("role")`

  - `List<String> permissions`

    Permissions granted by the role.

  - `boolean predefinedRole`

    Whether the role is predefined and managed by OpenAI.

  - `String resourceType`

    Resource type the role is bound to (for example `api.organization` or `api.project`).

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.roles.Role;
import com.openai.models.admin.organization.roles.RoleUpdateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        Role role = client.admin().organization().roles().update("role_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}
```

## Delete organization role

`RoleDeleteResponse admin().organization().roles().delete(RoleDeleteParamsparams = RoleDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/roles/{role_id}`

Deletes a custom role from the organization.

### Parameters

- `RoleDeleteParams params`

  - `Optional<String> roleId`

### Returns

- `class RoleDeleteResponse:`

  Confirmation payload returned after deleting a role.

  - `String id`

    Identifier of the deleted role.

  - `boolean deleted`

    Whether the role was deleted.

  - `JsonValue; object_ "role.deleted"constant`

    Always `role.deleted`.

    - `ROLE_DELETED("role.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.roles.RoleDeleteParams;
import com.openai.models.admin.organization.roles.RoleDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleDeleteResponse role = client.admin().organization().roles().delete("role_id");
    }
}
```

#### Response

```json
{
  "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.

  - `String id`

    Identifier for the role.

  - `Optional<String> description`

    Optional description of the role.

  - `String name`

    Unique name for the role.

  - `JsonValue; object_ "role"constant`

    Always `role`.

    - `ROLE("role")`

  - `List<String> permissions`

    Permissions granted by the role.

  - `boolean predefinedRole`

    Whether the role is predefined and managed by OpenAI.

  - `String resourceType`

    Resource type the role is bound to (for example `api.organization` or `api.project`).

# Certificates

## List organization certificates

`CertificateListPage admin().organization().certificates().list(CertificateListParamsparams = CertificateListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/certificates`

List uploaded certificates for this organization.

### Parameters

- `CertificateListParams params`

  - `Optional<String> after`

    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.

  - `Optional<Long> limit`

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

  - `Optional<Order> order`

    Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class CertificateListResponse:`

  Represents an individual certificate configured at the organization level.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `boolean active`

    Whether the certificate is currently active at the organization level.

  - `CertificateDetails certificateDetails`

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `JsonValue; object_ "organization.certificate"constant`

    The object type, which is always `organization.certificate`.

    - `ORGANIZATION_CERTIFICATE("organization.certificate")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.certificates.CertificateListPage;
import com.openai.models.admin.organization.certificates.CertificateListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        CertificateListPage page = client.admin().organization().certificates().list();
    }
}
```

#### Response

```json
{
  "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

`Certificate admin().organization().certificates().create(CertificateCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/certificates`

Upload a certificate to the organization. This does **not** automatically activate the certificate.

Organizations can upload up to 50 certificates.

### Parameters

- `CertificateCreateParams params`

  - `String certificate`

    The certificate content in PEM format

  - `Optional<String> name`

    An optional name for the certificate

### Returns

- `class Certificate:`

  Represents an individual `certificate` uploaded to the organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `CertificateDetails certificateDetails`

    - `Optional<String> content`

      The content of the certificate in PEM format.

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `Object object_`

    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("certificate")`

    - `ORGANIZATION_CERTIFICATE("organization.certificate")`

    - `ORGANIZATION_PROJECT_CERTIFICATE("organization.project.certificate")`

  - `Optional<Boolean> active`

    Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.certificates.Certificate;
import com.openai.models.admin.organization.certificates.CertificateCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        CertificateCreateParams params = CertificateCreateParams.builder()
            .certificate("certificate")
            .build();
        Certificate certificate = client.admin().organization().certificates().create(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}
```

## Get certificate

`Certificate admin().organization().certificates().retrieve(CertificateRetrieveParamsparams = CertificateRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/certificates/{certificate_id}`

Get a certificate that has been uploaded to the organization.

You can get a certificate regardless of whether it is active or not.

### Parameters

- `CertificateRetrieveParams params`

  - `Optional<String> certificateId`

  - `Optional<List<Include>> include`

    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("content")`

### Returns

- `class Certificate:`

  Represents an individual `certificate` uploaded to the organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `CertificateDetails certificateDetails`

    - `Optional<String> content`

      The content of the certificate in PEM format.

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `Object object_`

    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("certificate")`

    - `ORGANIZATION_CERTIFICATE("organization.certificate")`

    - `ORGANIZATION_PROJECT_CERTIFICATE("organization.project.certificate")`

  - `Optional<Boolean> active`

    Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.certificates.Certificate;
import com.openai.models.admin.organization.certificates.CertificateRetrieveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        Certificate certificate = client.admin().organization().certificates().retrieve("certificate_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}
```

## Modify certificate

`Certificate admin().organization().certificates().update(CertificateUpdateParamsparams = CertificateUpdateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/certificates/{certificate_id}`

Modify a certificate. Note that only the name can be modified.

### Parameters

- `CertificateUpdateParams params`

  - `Optional<String> certificateId`

  - `Optional<String> name`

    The updated name for the certificate

### Returns

- `class Certificate:`

  Represents an individual `certificate` uploaded to the organization.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `CertificateDetails certificateDetails`

    - `Optional<String> content`

      The content of the certificate in PEM format.

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `Object object_`

    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("certificate")`

    - `ORGANIZATION_CERTIFICATE("organization.certificate")`

    - `ORGANIZATION_PROJECT_CERTIFICATE("organization.project.certificate")`

  - `Optional<Boolean> active`

    Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.certificates.Certificate;
import com.openai.models.admin.organization.certificates.CertificateUpdateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        Certificate certificate = client.admin().organization().certificates().update("certificate_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}
```

## Delete certificate

`CertificateDeleteResponse admin().organization().certificates().delete(CertificateDeleteParamsparams = CertificateDeleteParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/certificates/{certificate_id}`

Delete a certificate from the organization.

The certificate must be inactive for the organization and all projects.

### Parameters

- `CertificateDeleteParams params`

  - `Optional<String> certificateId`

### Returns

- `class CertificateDeleteResponse:`

  - `String id`

    The ID of the certificate that was deleted.

  - `JsonValue; object_ "certificate.deleted"constant`

    The object type, must be `certificate.deleted`.

    - `CERTIFICATE_DELETED("certificate.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.certificates.CertificateDeleteParams;
import com.openai.models.admin.organization.certificates.CertificateDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        CertificateDeleteResponse certificate = client.admin().organization().certificates().delete("certificate_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "object": "certificate.deleted"
}
```

## Activate certificates for organization

`CertificateActivatePage admin().organization().certificates().activate(CertificateActivateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/certificates/activate`

Activate certificates at the organization level.

You can atomically and idempotently activate up to 10 certificates at a time.

### Parameters

- `CertificateActivateParams params`

  - `List<String> certificateIds`

### Returns

- `class CertificateActivateResponse:`

  Represents an individual certificate configured at the organization level.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `boolean active`

    Whether the certificate is currently active at the organization level.

  - `CertificateDetails certificateDetails`

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `JsonValue; object_ "organization.certificate"constant`

    The object type, which is always `organization.certificate`.

    - `ORGANIZATION_CERTIFICATE("organization.certificate")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.certificates.CertificateActivatePage;
import com.openai.models.admin.organization.certificates.CertificateActivateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        CertificateActivateParams params = CertificateActivateParams.builder()
            .addCertificateId("cert_abc")
            .build();
        CertificateActivatePage page = client.admin().organization().certificates().activate(params);
    }
}
```

#### Response

```json
{
  "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

`CertificateDeactivatePage admin().organization().certificates().deactivate(CertificateDeactivateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/certificates/deactivate`

Deactivate certificates at the organization level.

You can atomically and idempotently deactivate up to 10 certificates at a time.

### Parameters

- `CertificateDeactivateParams params`

  - `List<String> certificateIds`

### Returns

- `class CertificateDeactivateResponse:`

  Represents an individual certificate configured at the organization level.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `boolean active`

    Whether the certificate is currently active at the organization level.

  - `CertificateDetails certificateDetails`

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `JsonValue; object_ "organization.certificate"constant`

    The object type, which is always `organization.certificate`.

    - `ORGANIZATION_CERTIFICATE("organization.certificate")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.certificates.CertificateDeactivatePage;
import com.openai.models.admin.organization.certificates.CertificateDeactivateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        CertificateDeactivateParams params = CertificateDeactivateParams.builder()
            .addCertificateId("cert_abc")
            .build();
        CertificateDeactivatePage page = client.admin().organization().certificates().deactivate(params);
    }
}
```

#### Response

```json
{
  "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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `CertificateDetails certificateDetails`

    - `Optional<String> content`

      The content of the certificate in PEM format.

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `Object object_`

    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("certificate")`

    - `ORGANIZATION_CERTIFICATE("organization.certificate")`

    - `ORGANIZATION_PROJECT_CERTIFICATE("organization.project.certificate")`

  - `Optional<Boolean> active`

    Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

# Projects

## List projects

`ProjectListPage admin().organization().projects().list(ProjectListParamsparams = ProjectListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects`

Returns a list of projects.

### Parameters

- `ProjectListParams params`

  - `Optional<String> after`

    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.

  - `Optional<Boolean> includeArchived`

    If `true` returns all projects including those that have been `archived`. Archived projects are not included by default.

  - `Optional<Long> limit`

    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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.project"constant`

    The object type, which is always `organization.project`

    - `ORGANIZATION_PROJECT("organization.project")`

  - `Optional<Long> archivedAt`

    The Unix timestamp (in seconds) of when the project was archived or `null`.

  - `Optional<String> externalKeyId`

    The external key associated with the project.

  - `Optional<String> name`

    The name of the project. This appears in reporting.

  - `Optional<String> status`

    `active` or `archived`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.ProjectListPage;
import com.openai.models.admin.organization.projects.ProjectListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ProjectListPage page = client.admin().organization().projects().list();
    }
}
```

#### Response

```json
{
  "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

`Project admin().organization().projects().create(ProjectCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects`

Create a new project in the organization. Projects can be created and archived, but cannot be deleted.

### Parameters

- `ProjectCreateParams params`

  - `String name`

    The friendly name of the project, this name appears in reports.

  - `Optional<String> externalKeyId`

    External key ID to associate with the project.

  - `Optional<String> geography`

    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](https://platform.openai.com/docs/guides/your-data#data-residency-controls) to review the functionality and limitations of setting this field.

### Returns

- `class Project:`

  Represents an individual project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.project"constant`

    The object type, which is always `organization.project`

    - `ORGANIZATION_PROJECT("organization.project")`

  - `Optional<Long> archivedAt`

    The Unix timestamp (in seconds) of when the project was archived or `null`.

  - `Optional<String> externalKeyId`

    The external key associated with the project.

  - `Optional<String> name`

    The name of the project. This appears in reporting.

  - `Optional<String> status`

    `active` or `archived`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.Project;
import com.openai.models.admin.organization.projects.ProjectCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ProjectCreateParams params = ProjectCreateParams.builder()
            .name("name")
            .build();
        Project project = client.admin().organization().projects().create(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}
```

## Retrieve project

`Project admin().organization().projects().retrieve(ProjectRetrieveParamsparams = ProjectRetrieveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}`

Retrieves a project.

### Parameters

- `ProjectRetrieveParams params`

  - `Optional<String> projectId`

### Returns

- `class Project:`

  Represents an individual project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.project"constant`

    The object type, which is always `organization.project`

    - `ORGANIZATION_PROJECT("organization.project")`

  - `Optional<Long> archivedAt`

    The Unix timestamp (in seconds) of when the project was archived or `null`.

  - `Optional<String> externalKeyId`

    The external key associated with the project.

  - `Optional<String> name`

    The name of the project. This appears in reporting.

  - `Optional<String> status`

    `active` or `archived`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.Project;
import com.openai.models.admin.organization.projects.ProjectRetrieveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        Project project = client.admin().organization().projects().retrieve("project_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}
```

## Modify project

`Project admin().organization().projects().update(ProjectUpdateParamsparams = ProjectUpdateParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}`

Modifies a project in the organization.

### Parameters

- `ProjectUpdateParams params`

  - `Optional<String> projectId`

  - `Optional<String> externalKeyId`

    External key ID to associate with the project.

  - `Optional<String> geography`

    Geography for the project.

  - `Optional<String> name`

    The updated name of the project, this name appears in reports.

### Returns

- `class Project:`

  Represents an individual project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.project"constant`

    The object type, which is always `organization.project`

    - `ORGANIZATION_PROJECT("organization.project")`

  - `Optional<Long> archivedAt`

    The Unix timestamp (in seconds) of when the project was archived or `null`.

  - `Optional<String> externalKeyId`

    The external key associated with the project.

  - `Optional<String> name`

    The name of the project. This appears in reporting.

  - `Optional<String> status`

    `active` or `archived`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.Project;
import com.openai.models.admin.organization.projects.ProjectUpdateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        Project project = client.admin().organization().projects().update("project_id");
    }
}
```

#### Response

```json
{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}
```

## Archive project

`Project admin().organization().projects().archive(ProjectArchiveParamsparams = ProjectArchiveParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}/archive`

Archives a project in the organization. Archived projects cannot be used or updated.

### Parameters

- `ProjectArchiveParams params`

  - `Optional<String> projectId`

### Returns

- `class Project:`

  Represents an individual project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.project"constant`

    The object type, which is always `organization.project`

    - `ORGANIZATION_PROJECT("organization.project")`

  - `Optional<Long> archivedAt`

    The Unix timestamp (in seconds) of when the project was archived or `null`.

  - `Optional<String> externalKeyId`

    The external key associated with the project.

  - `Optional<String> name`

    The name of the project. This appears in reporting.

  - `Optional<String> status`

    `active` or `archived`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.Project;
import com.openai.models.admin.organization.projects.ProjectArchiveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        Project project = client.admin().organization().projects().archive("project_id");
    }
}
```

#### Response

```json
{
  "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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `JsonValue; object_ "organization.project"constant`

    The object type, which is always `organization.project`

    - `ORGANIZATION_PROJECT("organization.project")`

  - `Optional<Long> archivedAt`

    The Unix timestamp (in seconds) of when the project was archived or `null`.

  - `Optional<String> externalKeyId`

    The external key associated with the project.

  - `Optional<String> name`

    The name of the project. This appears in reporting.

  - `Optional<String> status`

    `active` or `archived`

# Users

## List project users

`UserListPage admin().organization().projects().users().list(UserListParamsparams = UserListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/users`

Returns a list of users in the project.

### Parameters

- `UserListParams params`

  - `Optional<String> projectId`

  - `Optional<String> after`

    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.

  - `Optional<Long> limit`

    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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

    The Unix timestamp (in seconds) of when the project was added.

  - `JsonValue; object_ "organization.project.user"constant`

    The object type, which is always `organization.project.user`

    - `ORGANIZATION_PROJECT_USER("organization.project.user")`

  - `String role`

    `owner` or `member`

  - `Optional<String> email`

    The email address of the user

  - `Optional<String> name`

    The name of the user

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.users.UserListPage;
import com.openai.models.admin.organization.projects.users.UserListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserListPage page = client.admin().organization().projects().users().list("project_id");
    }
}
```

#### Response

```json
{
  "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

`ProjectUser admin().organization().projects().users().create(UserCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}/users`

Adds a user to the project. Users must already be members of the organization to be added to a project.

### Parameters

- `UserCreateParams params`

  - `Optional<String> projectId`

  - `String role`

    `owner` or `member`

  - `Optional<String> email`

    Email of the user to add.

  - `Optional<String> userId`

    The ID of the user.

### Returns

- `class ProjectUser:`

  Represents an individual user in a project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

    The Unix timestamp (in seconds) of when the project was added.

  - `JsonValue; object_ "organization.project.user"constant`

    The object type, which is always `organization.project.user`

    - `ORGANIZATION_PROJECT_USER("organization.project.user")`

  - `String role`

    `owner` or `member`

  - `Optional<String> email`

    The email address of the user

  - `Optional<String> name`

    The name of the user

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.users.ProjectUser;
import com.openai.models.admin.organization.projects.users.UserCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserCreateParams params = UserCreateParams.builder()
            .projectId("project_id")
            .role("role")
            .build();
        ProjectUser projectUser = client.admin().organization().projects().users().create(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}
```

## Retrieve project user

`ProjectUser admin().organization().projects().users().retrieve(UserRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/users/{user_id}`

Retrieves a user in the project.

### Parameters

- `UserRetrieveParams params`

  - `String projectId`

  - `Optional<String> userId`

### Returns

- `class ProjectUser:`

  Represents an individual user in a project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

    The Unix timestamp (in seconds) of when the project was added.

  - `JsonValue; object_ "organization.project.user"constant`

    The object type, which is always `organization.project.user`

    - `ORGANIZATION_PROJECT_USER("organization.project.user")`

  - `String role`

    `owner` or `member`

  - `Optional<String> email`

    The email address of the user

  - `Optional<String> name`

    The name of the user

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.users.ProjectUser;
import com.openai.models.admin.organization.projects.users.UserRetrieveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserRetrieveParams params = UserRetrieveParams.builder()
            .projectId("project_id")
            .userId("user_id")
            .build();
        ProjectUser projectUser = client.admin().organization().projects().users().retrieve(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}
```

## Modify project user

`ProjectUser admin().organization().projects().users().update(UserUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}/users/{user_id}`

Modifies a user's role in the project.

### Parameters

- `UserUpdateParams params`

  - `String projectId`

  - `Optional<String> userId`

  - `Optional<String> role`

    `owner` or `member`

### Returns

- `class ProjectUser:`

  Represents an individual user in a project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

    The Unix timestamp (in seconds) of when the project was added.

  - `JsonValue; object_ "organization.project.user"constant`

    The object type, which is always `organization.project.user`

    - `ORGANIZATION_PROJECT_USER("organization.project.user")`

  - `String role`

    `owner` or `member`

  - `Optional<String> email`

    The email address of the user

  - `Optional<String> name`

    The name of the user

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.users.ProjectUser;
import com.openai.models.admin.organization.projects.users.UserUpdateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserUpdateParams params = UserUpdateParams.builder()
            .projectId("project_id")
            .userId("user_id")
            .build();
        ProjectUser projectUser = client.admin().organization().projects().users().update(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}
```

## Delete project user

`UserDeleteResponse admin().organization().projects().users().delete(UserDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/projects/{project_id}/users/{user_id}`

Deletes a user from the project.

Returns confirmation of project user deletion, or an error if the project is
archived (archived projects have no users).

### Parameters

- `UserDeleteParams params`

  - `String projectId`

  - `Optional<String> userId`

### Returns

- `class UserDeleteResponse:`

  - `String id`

  - `boolean deleted`

  - `JsonValue; object_ "organization.project.user.deleted"constant`

    - `ORGANIZATION_PROJECT_USER_DELETED("organization.project.user.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.users.UserDeleteParams;
import com.openai.models.admin.organization.projects.users.UserDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        UserDeleteParams params = UserDeleteParams.builder()
            .projectId("project_id")
            .userId("user_id")
            .build();
        UserDeleteResponse user = client.admin().organization().projects().users().delete(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "deleted": true,
  "object": "organization.project.user.deleted"
}
```

## Domain Types

### Project User

- `class ProjectUser:`

  Represents an individual user in a project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long addedAt`

    The Unix timestamp (in seconds) of when the project was added.

  - `JsonValue; object_ "organization.project.user"constant`

    The object type, which is always `organization.project.user`

    - `ORGANIZATION_PROJECT_USER("organization.project.user")`

  - `String role`

    `owner` or `member`

  - `Optional<String> email`

    The email address of the user

  - `Optional<String> name`

    The name of the user

# Roles

## List project user role assignments

`RoleListPage admin().organization().projects().users().roles().list(RoleListParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/projects/{project_id}/users/{user_id}/roles`

Lists the project roles assigned to a user within a project.

### Parameters

- `RoleListParams params`

  - `String projectId`

  - `Optional<String> userId`

  - `Optional<String> after`

    Cursor for pagination. Provide the value from the previous response's `next` field to continue listing project roles.

  - `Optional<Long> limit`

    A limit on the number of project role assignments to return.

  - `Optional<Order> order`

    Sort order for the returned project roles.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class RoleListResponse:`

  Detailed information about a role assignment entry returned when listing assignments.

  - `String id`

    Identifier for the role.

  - `Optional<Long> createdAt`

    When the role was created.

  - `Optional<String> createdBy`

    Identifier of the actor who created the role.

  - `Optional<CreatedByUserObj> createdByUserObj`

    User details for the actor that created the role, when available.

  - `Optional<String> description`

    Description of the role.

  - `Optional<Metadata> metadata`

    Arbitrary metadata stored on the role.

  - `String name`

    Name of the role.

  - `List<String> permissions`

    Permissions associated with the role.

  - `boolean predefinedRole`

    Whether the role is predefined by OpenAI.

  - `String resourceType`

    Resource type the role applies to.

  - `Optional<Long> updatedAt`

    When the role was last updated.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.users.roles.RoleListPage;
import com.openai.models.admin.organization.projects.users.roles.RoleListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleListParams params = RoleListParams.builder()
            .projectId("project_id")
            .userId("user_id")
            .build();
        RoleListPage page = client.admin().organization().projects().users().roles().list(params);
    }
}
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "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

`RoleCreateResponse admin().organization().projects().users().roles().create(RoleCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/projects/{project_id}/users/{user_id}/roles`

Assigns a project role to a user within a project.

### Parameters

- `RoleCreateParams params`

  - `String projectId`

  - `Optional<String> userId`

  - `String roleId`

    Identifier of the role to assign.

### Returns

- `class RoleCreateResponse:`

  Role assignment linking a user to a role.

  - `JsonValue; object_ "user.role"constant`

    Always `user.role`.

    - `USER_ROLE("user.role")`

  - `Role role`

    Details about a role that can be assigned through the public Roles API.

    - `String id`

      Identifier for the role.

    - `Optional<String> description`

      Optional description of the role.

    - `String name`

      Unique name for the role.

    - `JsonValue; object_ "role"constant`

      Always `role`.

      - `ROLE("role")`

    - `List<String> permissions`

      Permissions granted by the role.

    - `boolean predefinedRole`

      Whether the role is predefined and managed by OpenAI.

    - `String resourceType`

      Resource type the role is bound to (for example `api.organization` or `api.project`).

  - `OrganizationUser user`

    Represents an individual `user` within an organization.

    - `String id`

      The identifier, which can be referenced in API endpoints

    - `long addedAt`

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

    - `JsonValue; object_ "organization.user"constant`

      The object type, which is always `organization.user`

      - `ORGANIZATION_USER("organization.user")`

    - `Optional<Long> apiKeyLastUsedAt`

      The Unix timestamp (in seconds) of the user's last API key usage.

    - `Optional<Long> created`

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

    - `Optional<String> developerPersona`

      The developer persona metadata for the user.

    - `Optional<String> email`

      The email address of the user

    - `Optional<Boolean> isDefault`

      Whether this is the organization's default user.

    - `Optional<Boolean> isScaleTierAuthorizedPurchaser`

      Whether the user is an authorized purchaser for Scale Tier.

    - `Optional<Boolean> isScimManaged`

      Whether the user is managed through SCIM.

    - `Optional<Boolean> isServiceAccount`

      Whether the user is a service account.

    - `Optional<String> name`

      The name of the user

    - `Optional<Projects> projects`

      Projects associated with the user, if included.

      - `List<Data> data`

        - `Optional<String> id`

        - `Optional<String> name`

        - `Optional<String> role`

      - `JsonValue; object_ "list"constant`

        - `LIST("list")`

    - `Optional<String> role`

      `owner` or `reader`

    - `Optional<String> technicalLevel`

      The technical level metadata for the user.

    - `Optional<User> user`

      Nested user details.

      - `String id`

      - `JsonValue; object_ "user"constant`

        - `USER("user")`

      - `Optional<Boolean> banned`

      - `Optional<Long> bannedAt`

      - `Optional<String> email`

      - `Optional<Boolean> enabled`

      - `Optional<String> name`

      - `Optional<String> picture`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.users.roles.RoleCreateParams;
import com.openai.models.admin.organization.projects.users.roles.RoleCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleCreateParams params = RoleCreateParams.builder()
            .projectId("project_id")
            .userId("user_id")
            .roleId("role_id")
            .build();
        RoleCreateResponse role = client.admin().organization().projects().users().roles().create(params);
    }
}
```

#### Response

```json
{
  "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"
    }
  }
}
```

## Unassign project role from user

`RoleDeleteResponse admin().organization().projects().users().roles().delete(RoleDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/projects/{project_id}/users/{user_id}/roles/{role_id}`

Unassigns a project role from a user within a project.

### Parameters

- `RoleDeleteParams params`

  - `String projectId`

  - `String userId`

  - `Optional<String> roleId`

### Returns

- `class RoleDeleteResponse:`

  Confirmation payload returned after unassigning a role.

  - `boolean deleted`

    Whether the assignment was removed.

  - `String object_`

    Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.users.roles.RoleDeleteParams;
import com.openai.models.admin.organization.projects.users.roles.RoleDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleDeleteParams params = RoleDeleteParams.builder()
            .projectId("project_id")
            .userId("user_id")
            .roleId("role_id")
            .build();
        RoleDeleteResponse role = client.admin().organization().projects().users().roles().delete(params);
    }
}
```

#### Response

```json
{
  "deleted": true,
  "object": "object"
}
```

# Service Accounts

## List project service accounts

`ServiceAccountListPage admin().organization().projects().serviceAccounts().list(ServiceAccountListParamsparams = ServiceAccountListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/service_accounts`

Returns a list of service accounts in the project.

### Parameters

- `ServiceAccountListParams params`

  - `Optional<String> projectId`

  - `Optional<String> after`

    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.

  - `Optional<Long> limit`

    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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `String name`

    The name of the service account

  - `JsonValue; object_ "organization.project.service_account"constant`

    The object type, which is always `organization.project.service_account`

    - `ORGANIZATION_PROJECT_SERVICE_ACCOUNT("organization.project.service_account")`

  - `Role role`

    `owner` or `member`

    - `OWNER("owner")`

    - `MEMBER("member")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountListPage;
import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ServiceAccountListPage page = client.admin().organization().projects().serviceAccounts().list("project_id");
    }
}
```

#### Response

```json
{
  "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

`ServiceAccountCreateResponse admin().organization().projects().serviceAccounts().create(ServiceAccountCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}/service_accounts`

Creates a new service account in the project. This also returns an unredacted API key for the service account.

### Parameters

- `ServiceAccountCreateParams params`

  - `Optional<String> projectId`

  - `String name`

    The name of the service account being created.

### Returns

- `class ServiceAccountCreateResponse:`

  - `String id`

  - `Optional<ApiKey> apiKey`

    - `String id`

    - `long createdAt`

    - `String name`

    - `JsonValue; object_ "organization.project.service_account.api_key"constant`

      The object type, which is always `organization.project.service_account.api_key`

      - `ORGANIZATION_PROJECT_SERVICE_ACCOUNT_API_KEY("organization.project.service_account.api_key")`

    - `String value`

  - `long createdAt`

  - `String name`

  - `JsonValue; object_ "organization.project.service_account"constant`

    - `ORGANIZATION_PROJECT_SERVICE_ACCOUNT("organization.project.service_account")`

  - `JsonValue; role "member"constant`

    Service accounts can only have one role of type `member`

    - `MEMBER("member")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountCreateParams;
import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ServiceAccountCreateParams params = ServiceAccountCreateParams.builder()
            .projectId("project_id")
            .name("name")
            .build();
        ServiceAccountCreateResponse serviceAccount = client.admin().organization().projects().serviceAccounts().create(params);
    }
}
```

#### Response

```json
{
  "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

`ProjectServiceAccount admin().organization().projects().serviceAccounts().retrieve(ServiceAccountRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/service_accounts/{service_account_id}`

Retrieves a service account in the project.

### Parameters

- `ServiceAccountRetrieveParams params`

  - `String projectId`

  - `Optional<String> serviceAccountId`

### Returns

- `class ProjectServiceAccount:`

  Represents an individual service account in a project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `String name`

    The name of the service account

  - `JsonValue; object_ "organization.project.service_account"constant`

    The object type, which is always `organization.project.service_account`

    - `ORGANIZATION_PROJECT_SERVICE_ACCOUNT("organization.project.service_account")`

  - `Role role`

    `owner` or `member`

    - `OWNER("owner")`

    - `MEMBER("member")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.serviceaccounts.ProjectServiceAccount;
import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountRetrieveParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ServiceAccountRetrieveParams params = ServiceAccountRetrieveParams.builder()
            .projectId("project_id")
            .serviceAccountId("service_account_id")
            .build();
        ProjectServiceAccount projectServiceAccount = client.admin().organization().projects().serviceAccounts().retrieve(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "created_at": 0,
  "name": "name",
  "object": "organization.project.service_account",
  "role": "owner"
}
```

## Delete project service account

`ServiceAccountDeleteResponse admin().organization().projects().serviceAccounts().delete(ServiceAccountDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/projects/{project_id}/service_accounts/{service_account_id}`

Deletes a service account from the project.

Returns confirmation of service account deletion, or an error if the project
is archived (archived projects have no service accounts).

### Parameters

- `ServiceAccountDeleteParams params`

  - `String projectId`

  - `Optional<String> serviceAccountId`

### Returns

- `class ServiceAccountDeleteResponse:`

  - `String id`

  - `boolean deleted`

  - `JsonValue; object_ "organization.project.service_account.deleted"constant`

    - `ORGANIZATION_PROJECT_SERVICE_ACCOUNT_DELETED("organization.project.service_account.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountDeleteParams;
import com.openai.models.admin.organization.projects.serviceaccounts.ServiceAccountDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ServiceAccountDeleteParams params = ServiceAccountDeleteParams.builder()
            .projectId("project_id")
            .serviceAccountId("service_account_id")
            .build();
        ServiceAccountDeleteResponse serviceAccount = client.admin().organization().projects().serviceAccounts().delete(params);
    }
}
```

#### Response

```json
{
  "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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `String name`

    The name of the service account

  - `JsonValue; object_ "organization.project.service_account"constant`

    The object type, which is always `organization.project.service_account`

    - `ORGANIZATION_PROJECT_SERVICE_ACCOUNT("organization.project.service_account")`

  - `Role role`

    `owner` or `member`

    - `OWNER("owner")`

    - `MEMBER("member")`

# API Keys

## List project API keys

`ApiKeyListPage admin().organization().projects().apiKeys().list(ApiKeyListParamsparams = ApiKeyListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/api_keys`

Returns a list of API keys in the project.

### Parameters

- `ApiKeyListParams params`

  - `Optional<String> projectId`

  - `Optional<String> after`

    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.

  - `Optional<Long> limit`

    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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `Optional<Long> lastUsedAt`

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

  - `String name`

    The name of the API key

  - `JsonValue; object_ "organization.project.api_key"constant`

    The object type, which is always `organization.project.api_key`

    - `ORGANIZATION_PROJECT_API_KEY("organization.project.api_key")`

  - `Owner owner`

    - `Optional<ServiceAccount> serviceAccount`

      The service account that owns a project API key.

      - `String id`

        The identifier, which can be referenced in API endpoints

      - `long createdAt`

        The Unix timestamp (in seconds) of when the service account was created.

      - `String name`

        The name of the service account.

      - `String role`

        The service account's project role.

    - `Optional<Type> type`

      `user` or `service_account`

      - `USER("user")`

      - `SERVICE_ACCOUNT("service_account")`

    - `Optional<User> user`

      The user that owns a project API key.

      - `String id`

        The identifier, which can be referenced in API endpoints

      - `long createdAt`

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

      - `String email`

        The email address of the user.

      - `String name`

        The name of the user.

      - `String role`

        The user's project role.

  - `String redactedValue`

    The redacted value of the API key

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.apikeys.ApiKeyListPage;
import com.openai.models.admin.organization.projects.apikeys.ApiKeyListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ApiKeyListPage page = client.admin().organization().projects().apiKeys().list("project_id");
    }
}
```

#### Response

```json
{
  "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

`ProjectApiKey admin().organization().projects().apiKeys().retrieve(ApiKeyRetrieveParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/api_keys/{api_key_id}`

Retrieves an API key in the project.

### Parameters

- `ApiKeyRetrieveParams params`

  - `String projectId`

  - `Optional<String> apiKeyId`

### Returns

- `class ProjectApiKey:`

  Represents an individual API key in a project.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `Optional<Long> lastUsedAt`

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

  - `String name`

    The name of the API key

  - `JsonValue; object_ "organization.project.api_key"constant`

    The object type, which is always `organization.project.api_key`

    - `ORGANIZATION_PROJECT_API_KEY("organization.project.api_key")`

  - `Owner owner`

    - `Optional<ServiceAccount> serviceAccount`

      The service account that owns a project API key.

      - `String id`

        The identifier, which can be referenced in API endpoints

      - `long createdAt`

        The Unix timestamp (in seconds) of when the service account was created.

      - `String name`

        The name of the service account.

      - `String role`

        The service account's project role.

    - `Optional<Type> type`

      `user` or `service_account`

      - `USER("user")`

      - `SERVICE_ACCOUNT("service_account")`

    - `Optional<User> user`

      The user that owns a project API key.

      - `String id`

        The identifier, which can be referenced in API endpoints

      - `long createdAt`

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

      - `String email`

        The email address of the user.

      - `String name`

        The name of the user.

      - `String role`

        The user's project role.

  - `String redactedValue`

    The redacted value of the API key

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.apikeys.ApiKeyRetrieveParams;
import com.openai.models.admin.organization.projects.apikeys.ProjectApiKey;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ApiKeyRetrieveParams params = ApiKeyRetrieveParams.builder()
            .projectId("project_id")
            .apiKeyId("api_key_id")
            .build();
        ProjectApiKey projectApiKey = client.admin().organization().projects().apiKeys().retrieve(params);
    }
}
```

#### Response

```json
{
  "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

`ApiKeyDeleteResponse admin().organization().projects().apiKeys().delete(ApiKeyDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/projects/{project_id}/api_keys/{api_key_id}`

Deletes an API key from the project.

Returns confirmation of the key deletion, or an error if the key belonged to
a service account.

### Parameters

- `ApiKeyDeleteParams params`

  - `String projectId`

  - `Optional<String> apiKeyId`

### Returns

- `class ApiKeyDeleteResponse:`

  - `String id`

  - `boolean deleted`

  - `JsonValue; object_ "organization.project.api_key.deleted"constant`

    - `ORGANIZATION_PROJECT_API_KEY_DELETED("organization.project.api_key.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.apikeys.ApiKeyDeleteParams;
import com.openai.models.admin.organization.projects.apikeys.ApiKeyDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        ApiKeyDeleteParams params = ApiKeyDeleteParams.builder()
            .projectId("project_id")
            .apiKeyId("api_key_id")
            .build();
        ApiKeyDeleteResponse apiKey = client.admin().organization().projects().apiKeys().delete(params);
    }
}
```

#### Response

```json
{
  "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.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `long createdAt`

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

  - `Optional<Long> lastUsedAt`

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

  - `String name`

    The name of the API key

  - `JsonValue; object_ "organization.project.api_key"constant`

    The object type, which is always `organization.project.api_key`

    - `ORGANIZATION_PROJECT_API_KEY("organization.project.api_key")`

  - `Owner owner`

    - `Optional<ServiceAccount> serviceAccount`

      The service account that owns a project API key.

      - `String id`

        The identifier, which can be referenced in API endpoints

      - `long createdAt`

        The Unix timestamp (in seconds) of when the service account was created.

      - `String name`

        The name of the service account.

      - `String role`

        The service account's project role.

    - `Optional<Type> type`

      `user` or `service_account`

      - `USER("user")`

      - `SERVICE_ACCOUNT("service_account")`

    - `Optional<User> user`

      The user that owns a project API key.

      - `String id`

        The identifier, which can be referenced in API endpoints

      - `long createdAt`

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

      - `String email`

        The email address of the user.

      - `String name`

        The name of the user.

      - `String role`

        The user's project role.

  - `String redactedValue`

    The redacted value of the API key

# Rate Limits

## List project rate limits

`RateLimitListRateLimitsPage admin().organization().projects().rateLimits().listRateLimits(RateLimitListRateLimitsParamsparams = RateLimitListRateLimitsParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/rate_limits`

Returns the rate limits per model for a project.

### Parameters

- `RateLimitListRateLimitsParams params`

  - `Optional<String> projectId`

  - `Optional<String> after`

    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.

  - `Optional<String> before`

    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.

  - `Optional<Long> limit`

    A limit on the number of objects to be returned. The default is 100.

### Returns

- `class ProjectRateLimit:`

  Represents a project rate limit config.

  - `String id`

    The identifier, which can be referenced in API endpoints.

  - `long maxRequestsPer1Minute`

    The maximum requests per minute.

  - `long maxTokensPer1Minute`

    The maximum tokens per minute.

  - `String model`

    The model this rate limit applies to.

  - `JsonValue; object_ "project.rate_limit"constant`

    The object type, which is always `project.rate_limit`

    - `PROJECT_RATE_LIMIT("project.rate_limit")`

  - `Optional<Long> batch1DayMaxInputTokens`

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

  - `Optional<Long> maxAudioMegabytesPer1Minute`

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

  - `Optional<Long> maxImagesPer1Minute`

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

  - `Optional<Long> maxRequestsPer1Day`

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

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.ratelimits.RateLimitListRateLimitsPage;
import com.openai.models.admin.organization.projects.ratelimits.RateLimitListRateLimitsParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RateLimitListRateLimitsPage page = client.admin().organization().projects().rateLimits().listRateLimits("project_id");
    }
}
```

#### Response

```json
{
  "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

`ProjectRateLimit admin().organization().projects().rateLimits().updateRateLimit(RateLimitUpdateRateLimitParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}/rate_limits/{rate_limit_id}`

Updates a project rate limit.

### Parameters

- `RateLimitUpdateRateLimitParams params`

  - `String projectId`

  - `Optional<String> rateLimitId`

  - `Optional<Long> batch1DayMaxInputTokens`

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

  - `Optional<Long> maxAudioMegabytesPer1Minute`

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

  - `Optional<Long> maxImagesPer1Minute`

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

  - `Optional<Long> maxRequestsPer1Day`

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

  - `Optional<Long> maxRequestsPer1Minute`

    The maximum requests per minute.

  - `Optional<Long> maxTokensPer1Minute`

    The maximum tokens per minute.

### Returns

- `class ProjectRateLimit:`

  Represents a project rate limit config.

  - `String id`

    The identifier, which can be referenced in API endpoints.

  - `long maxRequestsPer1Minute`

    The maximum requests per minute.

  - `long maxTokensPer1Minute`

    The maximum tokens per minute.

  - `String model`

    The model this rate limit applies to.

  - `JsonValue; object_ "project.rate_limit"constant`

    The object type, which is always `project.rate_limit`

    - `PROJECT_RATE_LIMIT("project.rate_limit")`

  - `Optional<Long> batch1DayMaxInputTokens`

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

  - `Optional<Long> maxAudioMegabytesPer1Minute`

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

  - `Optional<Long> maxImagesPer1Minute`

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

  - `Optional<Long> maxRequestsPer1Day`

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

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.ratelimits.ProjectRateLimit;
import com.openai.models.admin.organization.projects.ratelimits.RateLimitUpdateRateLimitParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RateLimitUpdateRateLimitParams params = RateLimitUpdateRateLimitParams.builder()
            .projectId("project_id")
            .rateLimitId("rate_limit_id")
            .build();
        ProjectRateLimit projectRateLimit = client.admin().organization().projects().rateLimits().updateRateLimit(params);
    }
}
```

#### Response

```json
{
  "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.

  - `String id`

    The identifier, which can be referenced in API endpoints.

  - `long maxRequestsPer1Minute`

    The maximum requests per minute.

  - `long maxTokensPer1Minute`

    The maximum tokens per minute.

  - `String model`

    The model this rate limit applies to.

  - `JsonValue; object_ "project.rate_limit"constant`

    The object type, which is always `project.rate_limit`

    - `PROJECT_RATE_LIMIT("project.rate_limit")`

  - `Optional<Long> batch1DayMaxInputTokens`

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

  - `Optional<Long> maxAudioMegabytesPer1Minute`

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

  - `Optional<Long> maxImagesPer1Minute`

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

  - `Optional<Long> maxRequestsPer1Day`

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

# Groups

## List project groups

`GroupListPage admin().organization().projects().groups().list(GroupListParamsparams = GroupListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/groups`

Lists the groups that have access to a project.

### Parameters

- `GroupListParams params`

  - `Optional<String> projectId`

  - `Optional<String> after`

    Cursor for pagination. Provide the ID of the last group from the previous response to fetch the next page.

  - `Optional<Long> limit`

    A limit on the number of project groups to return. Defaults to 20.

  - `Optional<Order> order`

    Sort order for the returned groups.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class ProjectGroup:`

  Details about a group's membership in a project.

  - `long createdAt`

    Unix timestamp (in seconds) when the group was granted project access.

  - `String groupId`

    Identifier of the group that has access to the project.

  - `String groupName`

    Display name of the group.

  - `String groupType`

    The type of the group.

  - `JsonValue; object_ "project.group"constant`

    Always `project.group`.

    - `PROJECT_GROUP("project.group")`

  - `String projectId`

    Identifier of the project.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.groups.GroupListPage;
import com.openai.models.admin.organization.projects.groups.GroupListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        GroupListPage page = client.admin().organization().projects().groups().list("project_id");
    }
}
```

#### Response

```json
{
  "data": [
    {
      "created_at": 0,
      "group_id": "group_id",
      "group_name": "group_name",
      "group_type": "group_type",
      "object": "project.group",
      "project_id": "project_id"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}
```

## Add project group

`ProjectGroup admin().organization().projects().groups().create(GroupCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}/groups`

Grants a group access to a project.

### Parameters

- `GroupCreateParams params`

  - `Optional<String> projectId`

  - `String groupId`

    Identifier of the group to add to the project.

  - `String role`

    Identifier of the project role to grant to the group.

### Returns

- `class ProjectGroup:`

  Details about a group's membership in a project.

  - `long createdAt`

    Unix timestamp (in seconds) when the group was granted project access.

  - `String groupId`

    Identifier of the group that has access to the project.

  - `String groupName`

    Display name of the group.

  - `String groupType`

    The type of the group.

  - `JsonValue; object_ "project.group"constant`

    Always `project.group`.

    - `PROJECT_GROUP("project.group")`

  - `String projectId`

    Identifier of the project.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.groups.GroupCreateParams;
import com.openai.models.admin.organization.projects.groups.ProjectGroup;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        GroupCreateParams params = GroupCreateParams.builder()
            .projectId("project_id")
            .groupId("group_id")
            .role("role")
            .build();
        ProjectGroup projectGroup = client.admin().organization().projects().groups().create(params);
    }
}
```

#### Response

```json
{
  "created_at": 0,
  "group_id": "group_id",
  "group_name": "group_name",
  "group_type": "group_type",
  "object": "project.group",
  "project_id": "project_id"
}
```

## Remove project group

`GroupDeleteResponse admin().organization().projects().groups().delete(GroupDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/organization/projects/{project_id}/groups/{group_id}`

Revokes a group's access to a project.

### Parameters

- `GroupDeleteParams params`

  - `String projectId`

  - `Optional<String> groupId`

### Returns

- `class GroupDeleteResponse:`

  Confirmation payload returned after removing a group from a project.

  - `boolean deleted`

    Whether the group membership in the project was removed.

  - `JsonValue; object_ "project.group.deleted"constant`

    Always `project.group.deleted`.

    - `PROJECT_GROUP_DELETED("project.group.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.groups.GroupDeleteParams;
import com.openai.models.admin.organization.projects.groups.GroupDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        GroupDeleteParams params = GroupDeleteParams.builder()
            .projectId("project_id")
            .groupId("group_id")
            .build();
        GroupDeleteResponse group = client.admin().organization().projects().groups().delete(params);
    }
}
```

#### Response

```json
{
  "deleted": true,
  "object": "project.group.deleted"
}
```

## Domain Types

### Project Group

- `class ProjectGroup:`

  Details about a group's membership in a project.

  - `long createdAt`

    Unix timestamp (in seconds) when the group was granted project access.

  - `String groupId`

    Identifier of the group that has access to the project.

  - `String groupName`

    Display name of the group.

  - `String groupType`

    The type of the group.

  - `JsonValue; object_ "project.group"constant`

    Always `project.group`.

    - `PROJECT_GROUP("project.group")`

  - `String projectId`

    Identifier of the project.

# Roles

## List project group role assignments

`RoleListPage admin().organization().projects().groups().roles().list(RoleListParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/projects/{project_id}/groups/{group_id}/roles`

Lists the project roles assigned to a group within a project.

### Parameters

- `RoleListParams params`

  - `String projectId`

  - `Optional<String> groupId`

  - `Optional<String> after`

    Cursor for pagination. Provide the value from the previous response's `next` field to continue listing project roles.

  - `Optional<Long> limit`

    A limit on the number of project role assignments to return.

  - `Optional<Order> order`

    Sort order for the returned project roles.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class RoleListResponse:`

  Detailed information about a role assignment entry returned when listing assignments.

  - `String id`

    Identifier for the role.

  - `Optional<Long> createdAt`

    When the role was created.

  - `Optional<String> createdBy`

    Identifier of the actor who created the role.

  - `Optional<CreatedByUserObj> createdByUserObj`

    User details for the actor that created the role, when available.

  - `Optional<String> description`

    Description of the role.

  - `Optional<Metadata> metadata`

    Arbitrary metadata stored on the role.

  - `String name`

    Name of the role.

  - `List<String> permissions`

    Permissions associated with the role.

  - `boolean predefinedRole`

    Whether the role is predefined by OpenAI.

  - `String resourceType`

    Resource type the role applies to.

  - `Optional<Long> updatedAt`

    When the role was last updated.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.groups.roles.RoleListPage;
import com.openai.models.admin.organization.projects.groups.roles.RoleListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleListParams params = RoleListParams.builder()
            .projectId("project_id")
            .groupId("group_id")
            .build();
        RoleListPage page = client.admin().organization().projects().groups().roles().list(params);
    }
}
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "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

`RoleCreateResponse admin().organization().projects().groups().roles().create(RoleCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/projects/{project_id}/groups/{group_id}/roles`

Assigns a project role to a group within a project.

### Parameters

- `RoleCreateParams params`

  - `String projectId`

  - `Optional<String> groupId`

  - `String roleId`

    Identifier of the role to assign.

### Returns

- `class RoleCreateResponse:`

  Role assignment linking a group to a role.

  - `Group group`

    Summary information about a group returned in role assignment responses.

    - `String id`

      Identifier for the group.

    - `long createdAt`

      Unix timestamp (in seconds) when the group was created.

    - `String name`

      Display name of the group.

    - `JsonValue; object_ "group"constant`

      Always `group`.

      - `GROUP("group")`

    - `boolean scimManaged`

      Whether the group is managed through SCIM.

  - `JsonValue; object_ "group.role"constant`

    Always `group.role`.

    - `GROUP_ROLE("group.role")`

  - `Role role`

    Details about a role that can be assigned through the public Roles API.

    - `String id`

      Identifier for the role.

    - `Optional<String> description`

      Optional description of the role.

    - `String name`

      Unique name for the role.

    - `JsonValue; object_ "role"constant`

      Always `role`.

      - `ROLE("role")`

    - `List<String> permissions`

      Permissions granted by the role.

    - `boolean predefinedRole`

      Whether the role is predefined and managed by OpenAI.

    - `String resourceType`

      Resource type the role is bound to (for example `api.organization` or `api.project`).

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.groups.roles.RoleCreateParams;
import com.openai.models.admin.organization.projects.groups.roles.RoleCreateResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleCreateParams params = RoleCreateParams.builder()
            .projectId("project_id")
            .groupId("group_id")
            .roleId("role_id")
            .build();
        RoleCreateResponse role = client.admin().organization().projects().groups().roles().create(params);
    }
}
```

#### Response

```json
{
  "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"
  }
}
```

## Unassign project role from group

`RoleDeleteResponse admin().organization().projects().groups().roles().delete(RoleDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/projects/{project_id}/groups/{group_id}/roles/{role_id}`

Unassigns a project role from a group within a project.

### Parameters

- `RoleDeleteParams params`

  - `String projectId`

  - `String groupId`

  - `Optional<String> roleId`

### Returns

- `class RoleDeleteResponse:`

  Confirmation payload returned after unassigning a role.

  - `boolean deleted`

    Whether the assignment was removed.

  - `String object_`

    Identifier for the deleted assignment, such as `group.role.deleted` or `user.role.deleted`.

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.groups.roles.RoleDeleteParams;
import com.openai.models.admin.organization.projects.groups.roles.RoleDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleDeleteParams params = RoleDeleteParams.builder()
            .projectId("project_id")
            .groupId("group_id")
            .roleId("role_id")
            .build();
        RoleDeleteResponse role = client.admin().organization().projects().groups().roles().delete(params);
    }
}
```

#### Response

```json
{
  "deleted": true,
  "object": "object"
}
```

# Roles

## List project roles

`RoleListPage admin().organization().projects().roles().list(RoleListParamsparams = RoleListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/projects/{project_id}/roles`

Lists the roles configured for a project.

### Parameters

- `RoleListParams params`

  - `Optional<String> projectId`

  - `Optional<String> after`

    Cursor for pagination. Provide the value from the previous response's `next` field to continue listing roles.

  - `Optional<Long> limit`

    A limit on the number of roles to return. Defaults to 1000.

  - `Optional<Order> order`

    Sort order for the returned roles.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class Role:`

  Details about a role that can be assigned through the public Roles API.

  - `String id`

    Identifier for the role.

  - `Optional<String> description`

    Optional description of the role.

  - `String name`

    Unique name for the role.

  - `JsonValue; object_ "role"constant`

    Always `role`.

    - `ROLE("role")`

  - `List<String> permissions`

    Permissions granted by the role.

  - `boolean predefinedRole`

    Whether the role is predefined and managed by OpenAI.

  - `String resourceType`

    Resource type the role is bound to (for example `api.organization` or `api.project`).

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.roles.RoleListPage;
import com.openai.models.admin.organization.projects.roles.RoleListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleListPage page = client.admin().organization().projects().roles().list("project_id");
    }
}
```

#### Response

```json
{
  "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

`Role admin().organization().projects().roles().create(RoleCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/projects/{project_id}/roles`

Creates a custom role for a project.

### Parameters

- `RoleCreateParams params`

  - `Optional<String> projectId`

  - `List<String> permissions`

    Permissions to grant to the role.

  - `String roleName`

    Unique name for the role.

  - `Optional<String> description`

    Optional description of the role.

### Returns

- `class Role:`

  Details about a role that can be assigned through the public Roles API.

  - `String id`

    Identifier for the role.

  - `Optional<String> description`

    Optional description of the role.

  - `String name`

    Unique name for the role.

  - `JsonValue; object_ "role"constant`

    Always `role`.

    - `ROLE("role")`

  - `List<String> permissions`

    Permissions granted by the role.

  - `boolean predefinedRole`

    Whether the role is predefined and managed by OpenAI.

  - `String resourceType`

    Resource type the role is bound to (for example `api.organization` or `api.project`).

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.roles.RoleCreateParams;
import com.openai.models.admin.organization.roles.Role;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleCreateParams params = RoleCreateParams.builder()
            .projectId("project_id")
            .addPermission("string")
            .roleName("role_name")
            .build();
        Role role = client.admin().organization().projects().roles().create(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}
```

## Update project role

`Role admin().organization().projects().roles().update(RoleUpdateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/projects/{project_id}/roles/{role_id}`

Updates an existing project role.

### Parameters

- `RoleUpdateParams params`

  - `String projectId`

  - `Optional<String> roleId`

  - `Optional<String> description`

    New description for the role.

  - `Optional<List<String>> permissions`

    Updated set of permissions for the role.

  - `Optional<String> roleName`

    New name for the role.

### Returns

- `class Role:`

  Details about a role that can be assigned through the public Roles API.

  - `String id`

    Identifier for the role.

  - `Optional<String> description`

    Optional description of the role.

  - `String name`

    Unique name for the role.

  - `JsonValue; object_ "role"constant`

    Always `role`.

    - `ROLE("role")`

  - `List<String> permissions`

    Permissions granted by the role.

  - `boolean predefinedRole`

    Whether the role is predefined and managed by OpenAI.

  - `String resourceType`

    Resource type the role is bound to (for example `api.organization` or `api.project`).

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.roles.RoleUpdateParams;
import com.openai.models.admin.organization.roles.Role;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleUpdateParams params = RoleUpdateParams.builder()
            .projectId("project_id")
            .roleId("role_id")
            .build();
        Role role = client.admin().organization().projects().roles().update(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}
```

## Delete project role

`RoleDeleteResponse admin().organization().projects().roles().delete(RoleDeleteParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**delete** `/projects/{project_id}/roles/{role_id}`

Deletes a custom role from a project.

### Parameters

- `RoleDeleteParams params`

  - `String projectId`

  - `Optional<String> roleId`

### Returns

- `class RoleDeleteResponse:`

  Confirmation payload returned after deleting a role.

  - `String id`

    Identifier of the deleted role.

  - `boolean deleted`

    Whether the role was deleted.

  - `JsonValue; object_ "role.deleted"constant`

    Always `role.deleted`.

    - `ROLE_DELETED("role.deleted")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.roles.RoleDeleteParams;
import com.openai.models.admin.organization.projects.roles.RoleDeleteResponse;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        RoleDeleteParams params = RoleDeleteParams.builder()
            .projectId("project_id")
            .roleId("role_id")
            .build();
        RoleDeleteResponse role = client.admin().organization().projects().roles().delete(params);
    }
}
```

#### Response

```json
{
  "id": "id",
  "deleted": true,
  "object": "role.deleted"
}
```

# Certificates

## List project certificates

`CertificateListPage admin().organization().projects().certificates().list(CertificateListParamsparams = CertificateListParams.none(), RequestOptionsrequestOptions = RequestOptions.none())`

**get** `/organization/projects/{project_id}/certificates`

List certificates for this project.

### Parameters

- `CertificateListParams params`

  - `Optional<String> projectId`

  - `Optional<String> after`

    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.

  - `Optional<Long> limit`

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

  - `Optional<Order> order`

    Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order.

    - `ASC("asc")`

    - `DESC("desc")`

### Returns

- `class CertificateListResponse:`

  Represents an individual certificate configured at the project level.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `boolean active`

    Whether the certificate is currently active at the project level.

  - `CertificateDetails certificateDetails`

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `JsonValue; object_ "organization.project.certificate"constant`

    The object type, which is always `organization.project.certificate`.

    - `ORGANIZATION_PROJECT_CERTIFICATE("organization.project.certificate")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.certificates.CertificateListPage;
import com.openai.models.admin.organization.projects.certificates.CertificateListParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        CertificateListPage page = client.admin().organization().projects().certificates().list("project_id");
    }
}
```

#### Response

```json
{
  "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

`CertificateActivatePage admin().organization().projects().certificates().activate(CertificateActivateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}/certificates/activate`

Activate certificates at the project level.

You can atomically and idempotently activate up to 10 certificates at a time.

### Parameters

- `CertificateActivateParams params`

  - `Optional<String> projectId`

  - `List<String> certificateIds`

### Returns

- `class CertificateActivateResponse:`

  Represents an individual certificate configured at the project level.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `boolean active`

    Whether the certificate is currently active at the project level.

  - `CertificateDetails certificateDetails`

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `JsonValue; object_ "organization.project.certificate"constant`

    The object type, which is always `organization.project.certificate`.

    - `ORGANIZATION_PROJECT_CERTIFICATE("organization.project.certificate")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.certificates.CertificateActivatePage;
import com.openai.models.admin.organization.projects.certificates.CertificateActivateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        CertificateActivateParams params = CertificateActivateParams.builder()
            .projectId("project_id")
            .addCertificateId("cert_abc")
            .build();
        CertificateActivatePage page = client.admin().organization().projects().certificates().activate(params);
    }
}
```

#### Response

```json
{
  "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

`CertificateDeactivatePage admin().organization().projects().certificates().deactivate(CertificateDeactivateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())`

**post** `/organization/projects/{project_id}/certificates/deactivate`

Deactivate certificates at the project level. You can atomically and
idempotently deactivate up to 10 certificates at a time.

### Parameters

- `CertificateDeactivateParams params`

  - `Optional<String> projectId`

  - `List<String> certificateIds`

### Returns

- `class CertificateDeactivateResponse:`

  Represents an individual certificate configured at the project level.

  - `String id`

    The identifier, which can be referenced in API endpoints

  - `boolean active`

    Whether the certificate is currently active at the project level.

  - `CertificateDetails certificateDetails`

    - `Optional<Long> expiresAt`

      The Unix timestamp (in seconds) of when the certificate expires.

    - `Optional<Long> validAt`

      The Unix timestamp (in seconds) of when the certificate becomes valid.

  - `long createdAt`

    The Unix timestamp (in seconds) of when the certificate was uploaded.

  - `Optional<String> name`

    The name of the certificate.

  - `JsonValue; object_ "organization.project.certificate"constant`

    The object type, which is always `organization.project.certificate`.

    - `ORGANIZATION_PROJECT_CERTIFICATE("organization.project.certificate")`

### Example

```java
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.admin.organization.projects.certificates.CertificateDeactivatePage;
import com.openai.models.admin.organization.projects.certificates.CertificateDeactivateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        CertificateDeactivateParams params = CertificateDeactivateParams.builder()
            .projectId("project_id")
            .addCertificateId("cert_abc")
            .build();
        CertificateDeactivatePage page = client.admin().organization().projects().certificates().deactivate(params);
    }
}
```

#### Response

```json
{
  "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"
}
```
