diff --git a/.github/workflows/create-releases.yml b/.github/workflows/create-releases.yml
index deaebf1b54..77cbe7f7b9 100644
--- a/.github/workflows/create-releases.yml
+++ b/.github/workflows/create-releases.yml
@@ -19,7 +19,7 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- - uses: stainless-api/trigger-release-please@bb6677c5a04578eec1ccfd9e1913b5b78ed64c61 # v1
+ - uses: stainless-api/trigger-release-please@bb6677c5a04578eec1ccfd9e1913b5b78ed64c61 # v1.4.0
id: release
with:
repo: ${{ github.event.repository.full_name }}
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index aa10fdd48f..58e7426547 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "6.35.0"
+ ".": "6.36.0"
}
diff --git a/.stats.yml b/.stats.yml
index 731b1275ee..a29f8ce35a 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 151
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-bbf1d88b9b565b893dcae280be68848dc1518ecb65e009d1e94c9f0e5ecaacb2.yml
-openapi_spec_hash: 0757a960c980e26cc813615d6823bfd5
-config_hash: 1d3eb2a6fc36f206d2d67bfcf1a7080d
+configured_endpoints: 232
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai/openai-ea3c8bfb9cc34e798c5a473bb68ab5012344b1c99ab95377d0af4d908eb32a5d.yml
+openapi_spec_hash: dbab3fdd7781b449ba3e9e1b5180c6ed
+config_hash: 5d8a716125a61761563abbfc0d34e57c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6b573adfa5..213f4e2b0e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,29 @@
# Changelog
+## 6.36.0 (2026-05-01)
+
+Full Changelog: [v6.35.0...v6.36.0](https://github.com/openai/openai-node/compare/v6.35.0...v6.36.0)
+
+### Features
+
+* **api:** add support for Admin API Keys per endpoint ([770d187](https://github.com/openai/openai-node/commit/770d187be1d6c0419002a9b01e7dec6a99761f94))
+* **api:** admin API updates ([ee2bd2d](https://github.com/openai/openai-node/commit/ee2bd2d8e66a5b90f80e6ca8ab4544385d9a5de3))
+* **api:** manual updates ([6af2b6d](https://github.com/openai/openai-node/commit/6af2b6dfd86e4d7e7a2cb5afb1275217fcd5d242))
+* **api:** manual updates ([f2dceda](https://github.com/openai/openai-node/commit/f2dceda58fce6e44e740b56b9337597275d25e5b))
+
+
+### Bug Fixes
+
+* **api:** support admin api key auth ([e3862a3](https://github.com/openai/openai-node/commit/e3862a3d415ba3cedb178718e2c9bc0c2d09e01e))
+* **api:** tighten auth header selection ([f1203bd](https://github.com/openai/openai-node/commit/f1203bd884fb4131c54d9d7b8f89e9db3f4fc57c))
+
+
+### Chores
+
+* **format:** run eslint and prettier separately ([104543a](https://github.com/openai/openai-node/commit/104543a4daa138698006b1785ef7845d5ae0be27))
+* **internal:** codegen related update ([05d86da](https://github.com/openai/openai-node/commit/05d86dac705c75f8b8c6e6d5630973451f798e75))
+* **internal:** codegen related update ([f184586](https://github.com/openai/openai-node/commit/f184586fbcb8c7c07bf439455d6317aba62719ec))
+
## 6.35.0 (2026-04-28)
Full Changelog: [v6.34.0...v6.35.0](https://github.com/openai/openai-node/compare/v6.34.0...v6.35.0)
diff --git a/MIGRATION.md b/MIGRATION.md
index 79e95f6f72..6a039853bd 100644
--- a/MIGRATION.md
+++ b/MIGRATION.md
@@ -73,6 +73,26 @@ client.parents.children.retrieve('c_456', { parent_id: 'p_123' });
- `client.beta.threads.messages.retrieve()`
- `client.beta.threads.messages.update()`
- `client.beta.threads.messages.delete()`
+- `client.admin.organization.users.roles.delete()`
+- `client.admin.organization.groups.users.delete()`
+- `client.admin.organization.groups.roles.delete()`
+- `client.admin.organization.projects.users.retrieve()`
+- `client.admin.organization.projects.users.update()`
+- `client.admin.organization.projects.users.delete()`
+- `client.admin.organization.projects.users.roles.create()`
+- `client.admin.organization.projects.users.roles.list()`
+- `client.admin.organization.projects.users.roles.delete()`
+- `client.admin.organization.projects.serviceAccounts.retrieve()`
+- `client.admin.organization.projects.serviceAccounts.delete()`
+- `client.admin.organization.projects.apiKeys.retrieve()`
+- `client.admin.organization.projects.apiKeys.delete()`
+- `client.admin.organization.projects.rateLimits.updateRateLimit()`
+- `client.admin.organization.projects.groups.delete()`
+- `client.admin.organization.projects.groups.roles.create()`
+- `client.admin.organization.projects.groups.roles.list()`
+- `client.admin.organization.projects.groups.roles.delete()`
+- `client.admin.organization.projects.roles.update()`
+- `client.admin.organization.projects.roles.delete()`
- `client.conversations.items.retrieve()`
- `client.conversations.items.delete()`
- `client.evals.runs.retrieve()`
@@ -137,6 +157,25 @@ client.example.list(undefined, { headers: { ... } });
- `client.beta.threads.runs.list()`
- `client.beta.threads.messages.list()`
- `client.batches.list()`
+- `client.admin.organization.auditLogs.list()`
+- `client.admin.organization.adminAPIKeys.list()`
+- `client.admin.organization.invites.list()`
+- `client.admin.organization.users.list()`
+- `client.admin.organization.users.roles.list()`
+- `client.admin.organization.groups.list()`
+- `client.admin.organization.groups.users.list()`
+- `client.admin.organization.groups.roles.list()`
+- `client.admin.organization.roles.list()`
+- `client.admin.organization.certificates.retrieve()`
+- `client.admin.organization.certificates.list()`
+- `client.admin.organization.projects.list()`
+- `client.admin.organization.projects.users.list()`
+- `client.admin.organization.projects.serviceAccounts.list()`
+- `client.admin.organization.projects.apiKeys.list()`
+- `client.admin.organization.projects.rateLimits.listRateLimits()`
+- `client.admin.organization.projects.groups.list()`
+- `client.admin.organization.projects.roles.list()`
+- `client.admin.organization.projects.certificates.list()`
- `client.responses.retrieve()`
- `client.responses.inputItems.list()`
- `client.responses.inputTokens.count()`
diff --git a/api.md b/api.md
index fc41d982db..051ef9ebd8 100644
--- a/api.md
+++ b/api.md
@@ -596,6 +596,316 @@ Methods:
- client.uploads.parts.create(uploadID, { ...params }) -> UploadPart
+# Admin
+
+## Organization
+
+### AuditLogs
+
+Types:
+
+- AuditLogListResponse
+
+Methods:
+
+- client.admin.organization.auditLogs.list({ ...params }) -> AuditLogListResponsesPage
+
+### AdminAPIKeys
+
+Types:
+
+- AdminAPIKey
+- AdminAPIKeyCreateResponse
+- AdminAPIKeyDeleteResponse
+
+Methods:
+
+- client.admin.organization.adminAPIKeys.create({ ...params }) -> AdminAPIKeyCreateResponse
+- client.admin.organization.adminAPIKeys.retrieve(keyID) -> AdminAPIKey
+- client.admin.organization.adminAPIKeys.list({ ...params }) -> AdminAPIKeysPage
+- client.admin.organization.adminAPIKeys.delete(keyID) -> AdminAPIKeyDeleteResponse
+
+### Usage
+
+Types:
+
+- UsageAudioSpeechesResponse
+- UsageAudioTranscriptionsResponse
+- UsageCodeInterpreterSessionsResponse
+- UsageCompletionsResponse
+- UsageCostsResponse
+- UsageEmbeddingsResponse
+- UsageImagesResponse
+- UsageModerationsResponse
+- UsageVectorStoresResponse
+
+Methods:
+
+- client.admin.organization.usage.audioSpeeches({ ...params }) -> UsageAudioSpeechesResponse
+- client.admin.organization.usage.audioTranscriptions({ ...params }) -> UsageAudioTranscriptionsResponse
+- client.admin.organization.usage.codeInterpreterSessions({ ...params }) -> UsageCodeInterpreterSessionsResponse
+- client.admin.organization.usage.completions({ ...params }) -> UsageCompletionsResponse
+- client.admin.organization.usage.costs({ ...params }) -> UsageCostsResponse
+- client.admin.organization.usage.embeddings({ ...params }) -> UsageEmbeddingsResponse
+- client.admin.organization.usage.images({ ...params }) -> UsageImagesResponse
+- client.admin.organization.usage.moderations({ ...params }) -> UsageModerationsResponse
+- client.admin.organization.usage.vectorStores({ ...params }) -> UsageVectorStoresResponse
+
+### Invites
+
+Types:
+
+- Invite
+- InviteDeleteResponse
+
+Methods:
+
+- client.admin.organization.invites.create({ ...params }) -> Invite
+- client.admin.organization.invites.retrieve(inviteID) -> Invite
+- client.admin.organization.invites.list({ ...params }) -> InvitesPage
+- client.admin.organization.invites.delete(inviteID) -> InviteDeleteResponse
+
+### Users
+
+Types:
+
+- OrganizationUser
+- UserDeleteResponse
+
+Methods:
+
+- client.admin.organization.users.retrieve(userID) -> OrganizationUser
+- client.admin.organization.users.update(userID, { ...params }) -> OrganizationUser
+- client.admin.organization.users.list({ ...params }) -> OrganizationUsersPage
+- client.admin.organization.users.delete(userID) -> UserDeleteResponse
+
+#### Roles
+
+Types:
+
+- RoleCreateResponse
+- RoleListResponse
+- RoleDeleteResponse
+
+Methods:
+
+- client.admin.organization.users.roles.create(userID, { ...params }) -> RoleCreateResponse
+- client.admin.organization.users.roles.list(userID, { ...params }) -> RoleListResponsesPage
+- client.admin.organization.users.roles.delete(roleID, { ...params }) -> RoleDeleteResponse
+
+### Groups
+
+Types:
+
+- Group
+- GroupUpdateResponse
+- GroupDeleteResponse
+
+Methods:
+
+- client.admin.organization.groups.create({ ...params }) -> Group
+- client.admin.organization.groups.update(groupID, { ...params }) -> GroupUpdateResponse
+- client.admin.organization.groups.list({ ...params }) -> GroupsPage
+- client.admin.organization.groups.delete(groupID) -> GroupDeleteResponse
+
+#### Users
+
+Types:
+
+- OrganizationGroupUser
+- UserCreateResponse
+- UserDeleteResponse
+
+Methods:
+
+- client.admin.organization.groups.users.create(groupID, { ...params }) -> UserCreateResponse
+- client.admin.organization.groups.users.list(groupID, { ...params }) -> OrganizationGroupUsersPage
+- client.admin.organization.groups.users.delete(userID, { ...params }) -> UserDeleteResponse
+
+#### Roles
+
+Types:
+
+- RoleCreateResponse
+- RoleListResponse
+- RoleDeleteResponse
+
+Methods:
+
+- client.admin.organization.groups.roles.create(groupID, { ...params }) -> RoleCreateResponse
+- client.admin.organization.groups.roles.list(groupID, { ...params }) -> RoleListResponsesPage
+- client.admin.organization.groups.roles.delete(roleID, { ...params }) -> RoleDeleteResponse
+
+### Roles
+
+Types:
+
+- Role
+- RoleDeleteResponse
+
+Methods:
+
+- client.admin.organization.roles.create({ ...params }) -> Role
+- client.admin.organization.roles.update(roleID, { ...params }) -> Role
+- client.admin.organization.roles.list({ ...params }) -> RolesPage
+- client.admin.organization.roles.delete(roleID) -> RoleDeleteResponse
+
+### Certificates
+
+Types:
+
+- Certificate
+- CertificateListResponse
+- CertificateDeleteResponse
+- CertificateActivateResponse
+- CertificateDeactivateResponse
+
+Methods:
+
+- client.admin.organization.certificates.create({ ...params }) -> Certificate
+- client.admin.organization.certificates.retrieve(certificateID, { ...params }) -> Certificate
+- client.admin.organization.certificates.update(certificateID, { ...params }) -> Certificate
+- client.admin.organization.certificates.list({ ...params }) -> CertificateListResponsesPage
+- client.admin.organization.certificates.delete(certificateID) -> CertificateDeleteResponse
+- client.admin.organization.certificates.activate({ ...params }) -> CertificateActivateResponsesPage
+- client.admin.organization.certificates.deactivate({ ...params }) -> CertificateDeactivateResponsesPage
+
+### Projects
+
+Types:
+
+- Project
+
+Methods:
+
+- client.admin.organization.projects.create({ ...params }) -> Project
+- client.admin.organization.projects.retrieve(projectID) -> Project
+- client.admin.organization.projects.update(projectID, { ...params }) -> Project
+- client.admin.organization.projects.list({ ...params }) -> ProjectsPage
+- client.admin.organization.projects.archive(projectID) -> Project
+
+#### Users
+
+Types:
+
+- ProjectUser
+- UserDeleteResponse
+
+Methods:
+
+- client.admin.organization.projects.users.create(projectID, { ...params }) -> ProjectUser
+- client.admin.organization.projects.users.retrieve(userID, { ...params }) -> ProjectUser
+- client.admin.organization.projects.users.update(userID, { ...params }) -> ProjectUser
+- client.admin.organization.projects.users.list(projectID, { ...params }) -> ProjectUsersPage
+- client.admin.organization.projects.users.delete(userID, { ...params }) -> UserDeleteResponse
+
+##### Roles
+
+Types:
+
+- RoleCreateResponse
+- RoleListResponse
+- RoleDeleteResponse
+
+Methods:
+
+- client.admin.organization.projects.users.roles.create(userID, { ...params }) -> RoleCreateResponse
+- client.admin.organization.projects.users.roles.list(userID, { ...params }) -> RoleListResponsesPage
+- client.admin.organization.projects.users.roles.delete(roleID, { ...params }) -> RoleDeleteResponse
+
+#### ServiceAccounts
+
+Types:
+
+- ProjectServiceAccount
+- ServiceAccountCreateResponse
+- ServiceAccountDeleteResponse
+
+Methods:
+
+- client.admin.organization.projects.serviceAccounts.create(projectID, { ...params }) -> ServiceAccountCreateResponse
+- client.admin.organization.projects.serviceAccounts.retrieve(serviceAccountID, { ...params }) -> ProjectServiceAccount
+- client.admin.organization.projects.serviceAccounts.list(projectID, { ...params }) -> ProjectServiceAccountsPage
+- client.admin.organization.projects.serviceAccounts.delete(serviceAccountID, { ...params }) -> ServiceAccountDeleteResponse
+
+#### APIKeys
+
+Types:
+
+- ProjectAPIKey
+- APIKeyDeleteResponse
+
+Methods:
+
+- client.admin.organization.projects.apiKeys.retrieve(apiKeyID, { ...params }) -> ProjectAPIKey
+- client.admin.organization.projects.apiKeys.list(projectID, { ...params }) -> ProjectAPIKeysPage
+- client.admin.organization.projects.apiKeys.delete(apiKeyID, { ...params }) -> APIKeyDeleteResponse
+
+#### RateLimits
+
+Types:
+
+- ProjectRateLimit
+
+Methods:
+
+- client.admin.organization.projects.rateLimits.listRateLimits(projectID, { ...params }) -> ProjectRateLimitsPage
+- client.admin.organization.projects.rateLimits.updateRateLimit(rateLimitID, { ...params }) -> ProjectRateLimit
+
+#### Groups
+
+Types:
+
+- ProjectGroup
+- GroupDeleteResponse
+
+Methods:
+
+- client.admin.organization.projects.groups.create(projectID, { ...params }) -> ProjectGroup
+- client.admin.organization.projects.groups.list(projectID, { ...params }) -> ProjectGroupsPage
+- client.admin.organization.projects.groups.delete(groupID, { ...params }) -> GroupDeleteResponse
+
+##### Roles
+
+Types:
+
+- RoleCreateResponse
+- RoleListResponse
+- RoleDeleteResponse
+
+Methods:
+
+- client.admin.organization.projects.groups.roles.create(groupID, { ...params }) -> RoleCreateResponse
+- client.admin.organization.projects.groups.roles.list(groupID, { ...params }) -> RoleListResponsesPage
+- client.admin.organization.projects.groups.roles.delete(roleID, { ...params }) -> RoleDeleteResponse
+
+#### Roles
+
+Types:
+
+- RoleDeleteResponse
+
+Methods:
+
+- client.admin.organization.projects.roles.create(projectID, { ...params }) -> Role
+- client.admin.organization.projects.roles.update(roleID, { ...params }) -> Role
+- client.admin.organization.projects.roles.list(projectID, { ...params }) -> RolesPage
+- client.admin.organization.projects.roles.delete(roleID, { ...params }) -> RoleDeleteResponse
+
+#### Certificates
+
+Types:
+
+- CertificateListResponse
+- CertificateActivateResponse
+- CertificateDeactivateResponse
+
+Methods:
+
+- client.admin.organization.projects.certificates.list(projectID, { ...params }) -> CertificateListResponsesPage
+- client.admin.organization.projects.certificates.activate(projectID, { ...params }) -> CertificateActivateResponsesPage
+- client.admin.organization.projects.certificates.deactivate(projectID, { ...params }) -> CertificateDeactivateResponsesPage
+
# [Responses](src/resources/responses/api.md)
# [Realtime](src/resources/realtime/api.md)
diff --git a/bin/migration-config.json b/bin/migration-config.json
index 45495a06e0..fd29da1526 100644
--- a/bin/migration-config.json
+++ b/bin/migration-config.json
@@ -650,6 +650,741 @@
"name": "delete",
"oldName": "del"
},
+ {
+ "base": "admin.organization.users.roles",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.groups.users",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.groups.roles",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.users",
+ "name": "retrieve",
+ "params": [
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.users",
+ "name": "update",
+ "params": [
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.users",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.users.roles",
+ "name": "create",
+ "params": [
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.users.roles",
+ "name": "list",
+ "params": [
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": true
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.users.roles",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "user_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.serviceAccounts",
+ "name": "retrieve",
+ "params": [
+ {
+ "type": "param",
+ "key": "service_account_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "service_account_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.serviceAccounts",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "service_account_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "service_account_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.apiKeys",
+ "name": "retrieve",
+ "params": [
+ {
+ "type": "param",
+ "key": "api_key_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "api_key_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.apiKeys",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "api_key_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "api_key_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.rateLimits",
+ "name": "updateRateLimit",
+ "params": [
+ {
+ "type": "param",
+ "key": "rate_limit_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "rate_limit_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.groups",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.groups.roles",
+ "name": "create",
+ "params": [
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.groups.roles",
+ "name": "list",
+ "params": [
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": true
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.groups.roles",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "group_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.roles",
+ "name": "update",
+ "params": [
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "admin.organization.projects.roles",
+ "name": "delete",
+ "params": [
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "project_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "role_id",
+ "location": "path"
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
+ {
+ "base": "conversations.items",
+ "name": "retrieve",
+ "params": [
+ {
+ "type": "param",
+ "key": "item_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": false
+ },
+ {
+ "type": "options"
+ }
+ ],
+ "oldParams": [
+ {
+ "type": "param",
+ "key": "conversation_id",
+ "location": "path"
+ },
+ {
+ "type": "param",
+ "key": "item_id",
+ "location": "path"
+ },
+ {
+ "type": "params",
+ "maybeOverload": true
+ },
+ {
+ "type": "options"
+ }
+ ]
+ },
{
"base": "evals",
"name": "delete",
diff --git a/jsr.json b/jsr.json
index 872c126ebb..26149dc4cf 100644
--- a/jsr.json
+++ b/jsr.json
@@ -1,6 +1,6 @@
{
"name": "@openai/openai",
- "version": "6.35.0",
+ "version": "6.36.0",
"exports": {
".": "./index.ts",
"./helpers/zod": "./helpers/zod.ts",
diff --git a/package.json b/package.json
index d69c4d1dd6..21c162d78f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "openai",
- "version": "6.35.0",
+ "version": "6.36.0",
"description": "The official TypeScript library for the OpenAI API",
"author": "OpenAI ",
"types": "dist/index.d.ts",
diff --git a/scripts/detect-breaking-changes b/scripts/detect-breaking-changes
index c9dfc96b75..d2637a5e35 100755
--- a/scripts/detect-breaking-changes
+++ b/scripts/detect-breaking-changes
@@ -45,6 +45,29 @@ TEST_PATHS=(
tests/api-resources/batches.test.ts
tests/api-resources/uploads/uploads.test.ts
tests/api-resources/uploads/parts.test.ts
+ tests/api-resources/admin/admin.test.ts
+ tests/api-resources/admin/organization/organization.test.ts
+ tests/api-resources/admin/organization/audit-logs.test.ts
+ tests/api-resources/admin/organization/admin-api-keys.test.ts
+ tests/api-resources/admin/organization/usage.test.ts
+ tests/api-resources/admin/organization/invites.test.ts
+ tests/api-resources/admin/organization/users/users.test.ts
+ tests/api-resources/admin/organization/users/roles.test.ts
+ tests/api-resources/admin/organization/groups/groups.test.ts
+ tests/api-resources/admin/organization/groups/users.test.ts
+ tests/api-resources/admin/organization/groups/roles.test.ts
+ tests/api-resources/admin/organization/roles.test.ts
+ tests/api-resources/admin/organization/certificates.test.ts
+ tests/api-resources/admin/organization/projects/projects.test.ts
+ tests/api-resources/admin/organization/projects/users/users.test.ts
+ tests/api-resources/admin/organization/projects/users/roles.test.ts
+ tests/api-resources/admin/organization/projects/service-accounts.test.ts
+ tests/api-resources/admin/organization/projects/api-keys.test.ts
+ tests/api-resources/admin/organization/projects/rate-limits.test.ts
+ tests/api-resources/admin/organization/projects/groups/groups.test.ts
+ tests/api-resources/admin/organization/projects/groups/roles.test.ts
+ tests/api-resources/admin/organization/projects/roles.test.ts
+ tests/api-resources/admin/organization/projects/certificates.test.ts
tests/api-resources/responses/responses.test.ts
tests/api-resources/responses/input-items.test.ts
tests/api-resources/responses/input-tokens.test.ts
diff --git a/scripts/fast-format b/scripts/fast-format
index e172313642..f1873aef8e 100755
--- a/scripts/fast-format
+++ b/scripts/fast-format
@@ -31,8 +31,7 @@ if ! [ -z "$ESLINT_FILES" ]; then
fi
echo "==> Running prettier --write"
-PRETTIER_FILES="$(grep '\.\([mc]?tsx?\|[mc]?jsx?\|json\)$' "$FILE_LIST" || true)"
-if ! [ -z "$PRETTIER_FILES" ]; then
- echo "$PRETTIER_FILES" | xargs ./node_modules/.bin/prettier \
- --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern
+if ! [ -z "$FILE_LIST" ]; then
+ cat "$FILE_LIST" | xargs ./node_modules/.bin/prettier \
+ --write --cache --cache-strategy metadata --no-error-on-unmatched-pattern --ignore-unknown
fi
diff --git a/src/azure.ts b/src/azure.ts
index 26874a5281..3dff14b7a8 100644
--- a/src/azure.ts
+++ b/src/azure.ts
@@ -138,11 +138,15 @@ export class AzureOpenAI extends OpenAI {
return super.buildRequest(options, props);
}
- protected override async authHeaders(opts: FinalRequestOptions): Promise {
- if (typeof this._options.apiKey === 'string') {
+ protected override async authHeaders(
+ opts: FinalRequestOptions,
+ schemes?: { bearerAuth?: boolean; adminAPIKeyAuth?: boolean },
+ ): Promise {
+ const security = schemes ?? { bearerAuth: true, adminAPIKeyAuth: true };
+ if (security.bearerAuth && typeof this._options.apiKey === 'string') {
return buildHeaders([{ 'api-key': this.apiKey }]);
}
- return super.authHeaders(opts);
+ return super.authHeaders(opts, security);
}
}
diff --git a/src/beta/realtime/websocket.ts b/src/beta/realtime/websocket.ts
index 31284f12bf..427a0513ee 100644
--- a/src/beta/realtime/websocket.ts
+++ b/src/beta/realtime/websocket.ts
@@ -117,11 +117,16 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
): Promise {
const isApiKeyProvider = await client._callApiKey();
+ const apiKey = client.apiKey;
+ if (!apiKey) {
+ throw new Error('Azure OpenAI Realtime requires an API key');
+ }
+ const azureApiKey = apiKey;
function onURL(url: URL) {
if (isApiKeyProvider) {
- url.searchParams.set('Authorization', `Bearer ${client.apiKey}`);
+ url.searchParams.set('Authorization', `Bearer ${azureApiKey}`);
} else {
- url.searchParams.set('api-key', client.apiKey);
+ url.searchParams.set('api-key', azureApiKey);
}
}
const deploymentName = options.deploymentName ?? client.deploymentName;
diff --git a/src/beta/realtime/ws.ts b/src/beta/realtime/ws.ts
index d1b8343317..224e6dfc17 100644
--- a/src/beta/realtime/ws.ts
+++ b/src/beta/realtime/ws.ts
@@ -76,6 +76,10 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
props: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},
): Promise {
const isApiKeyProvider = await client._callApiKey();
+ const apiKey = client.apiKey;
+ if (!apiKey) {
+ throw new Error('Azure OpenAI Realtime requires an API key');
+ }
const deploymentName = props.deploymentName ?? client.deploymentName;
if (!deploymentName) {
throw new Error('No deployment name provided');
@@ -87,7 +91,7 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
...props.options,
headers: {
...props.options?.headers,
- ...(isApiKeyProvider ? {} : { 'api-key': client.apiKey }),
+ ...(isApiKeyProvider ? {} : { 'api-key': apiKey }),
},
},
__resolvedApiKey: isApiKeyProvider,
diff --git a/src/client.ts b/src/client.ts
index f55a6b986e..86130c98d8 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -24,6 +24,8 @@ import {
ConversationCursorPageResponse,
type CursorPageParams,
CursorPageResponse,
+ type NextCursorPageParams,
+ NextCursorPageResponse,
PageResponse,
} from './core/pagination';
import * as Uploads from './core/uploads';
@@ -115,6 +117,7 @@ import {
Videos,
VideosPage,
} from './resources/videos';
+import { Admin } from './resources/admin/admin';
import { Audio, AudioModel, AudioResponseFormat } from './resources/audio/audio';
import { Beta } from './resources/beta/beta';
import { Chat } from './resources/chat/chat';
@@ -258,7 +261,12 @@ export interface ClientOptions {
* error available as `cause`.
* - Mutually exclusive with `workloadIdentity`.
*/
- apiKey?: string | ApiKeySetter | undefined;
+ apiKey?: string | ApiKeySetter | null | undefined;
+
+ /**
+ * Defaults to process.env['OPENAI_ADMIN_KEY'].
+ */
+ adminAPIKey?: string | null | undefined;
/**
* Defaults to process.env['OPENAI_ORG_ID'].
@@ -361,7 +369,8 @@ export interface ClientOptions {
* API Client for interfacing with the OpenAI API.
*/
export class OpenAI {
- apiKey: string;
+ apiKey: string | null;
+ adminAPIKey: string | null;
organization: string | null;
project: string | null;
webhookSecret: string | null;
@@ -382,7 +391,8 @@ export class OpenAI {
/**
* API Client for interfacing with the OpenAI API.
*
- * @param {string | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? undefined]
+ * @param {string | null | undefined} [opts.apiKey=process.env['OPENAI_API_KEY'] ?? null]
+ * @param {string | null | undefined} [opts.adminAPIKey=process.env['OPENAI_ADMIN_KEY'] ?? null]
* @param {string | null | undefined} [opts.organization=process.env['OPENAI_ORG_ID'] ?? null]
* @param {string | null | undefined} [opts.project=process.env['OPENAI_PROJECT_ID'] ?? null]
* @param {string | null | undefined} [opts.webhookSecret=process.env['OPENAI_WEBHOOK_SECRET'] ?? null]
@@ -397,28 +407,17 @@ export class OpenAI {
*/
constructor({
baseURL = readEnv('OPENAI_BASE_URL'),
- apiKey = readEnv('OPENAI_API_KEY'),
+ apiKey = readEnv('OPENAI_API_KEY') ?? null,
+ adminAPIKey = readEnv('OPENAI_ADMIN_KEY') ?? null,
organization = readEnv('OPENAI_ORG_ID') ?? null,
project = readEnv('OPENAI_PROJECT_ID') ?? null,
webhookSecret = readEnv('OPENAI_WEBHOOK_SECRET') ?? null,
workloadIdentity,
...opts
}: ClientOptions = {}) {
- if (workloadIdentity) {
- if (apiKey && apiKey !== WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER) {
- throw new Errors.OpenAIError(
- 'The `apiKey` and `workloadIdentity` arguments are mutually exclusive; only one can be passed at a time.',
- );
- }
- apiKey = WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER;
- } else if (apiKey === undefined) {
- throw new Errors.OpenAIError(
- 'Missing credentials. Please pass an `apiKey`, `workloadIdentity`, or set the `OPENAI_API_KEY` environment variable.',
- );
- }
-
const options: ClientOptions = {
apiKey,
+ adminAPIKey,
organization,
project,
webhookSecret,
@@ -427,6 +426,16 @@ export class OpenAI {
baseURL: baseURL || `https://api.openai.com/v1`,
};
+ if (apiKey && workloadIdentity) {
+ throw new Errors.OpenAIError('The `apiKey` and `workloadIdentity` options are mutually exclusive');
+ }
+
+ if (!apiKey && !adminAPIKey && !workloadIdentity) {
+ throw new Errors.OpenAIError(
+ 'Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.',
+ );
+ }
+
if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
throw new Errors.OpenAIError(
"It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n",
@@ -448,13 +457,26 @@ export class OpenAI {
this.fetch = options.fetch ?? Shims.getDefaultFetch();
this.#encoder = Opts.FallbackEncoder;
+ const customHeadersEnv = readEnv('OPENAI_CUSTOM_HEADERS');
+ if (customHeadersEnv) {
+ const parsed: Record = {};
+ for (const line of customHeadersEnv.split('\n')) {
+ const colon = line.indexOf(':');
+ if (colon >= 0) {
+ parsed[line.substring(0, colon).trim()] = line.substring(colon + 1).trim();
+ }
+ }
+ options.defaultHeaders = buildHeaders([parsed, options.defaultHeaders]);
+ }
+
this._options = options;
if (workloadIdentity) {
this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
}
- this.apiKey = typeof apiKey === 'string' ? apiKey : 'Missing Key';
+ this.apiKey = typeof apiKey === 'string' ? apiKey : null;
+ this.adminAPIKey = adminAPIKey;
this.organization = organization;
this.project = project;
this.webhookSecret = webhookSecret;
@@ -473,7 +495,8 @@ export class OpenAI {
logLevel: this.logLevel,
fetch: this.fetch,
fetchOptions: this.fetchOptions,
- apiKey: this.apiKey,
+ apiKey: this._options.apiKey,
+ adminAPIKey: this.adminAPIKey,
workloadIdentity: this._options.workloadIdentity,
organization: this.organization,
project: this.project,
@@ -494,14 +517,59 @@ export class OpenAI {
return this._options.defaultQuery;
}
- protected validateHeaders({ values, nulls }: NullableHeaders) {
- return;
+ protected validateHeaders(
+ { values, nulls }: NullableHeaders,
+ schemes: { bearerAuth?: boolean; adminAPIKeyAuth?: boolean } = {
+ bearerAuth: true,
+ adminAPIKeyAuth: true,
+ },
+ ) {
+ if (values.get('authorization') || values.get('api-key')) {
+ return;
+ }
+ if (nulls.has('authorization') || nulls.has('api-key')) {
+ return;
+ }
+
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
+ return;
+ }
+
+ throw new Error(
+ 'Could not resolve authentication method. Expected either apiKey or adminAPIKey to be set. Or for one of the "Authorization" or "api-key" headers to be explicitly omitted',
+ );
+ }
+
+ protected async authHeaders(
+ opts: FinalRequestOptions,
+ schemes: { bearerAuth?: boolean; adminAPIKeyAuth?: boolean } = {
+ bearerAuth: true,
+ adminAPIKeyAuth: true,
+ },
+ ): Promise {
+ return buildHeaders([
+ schemes.bearerAuth ? await this.bearerAuth(opts) : null,
+ schemes.adminAPIKeyAuth ? await this.adminAPIKeyAuth(opts) : null,
+ ]);
}
- protected async authHeaders(opts: FinalRequestOptions): Promise {
+ protected async bearerAuth(opts: FinalRequestOptions): Promise {
+ if (this._workloadIdentityAuth) {
+ return buildHeaders([{ Authorization: `Bearer ${await this._workloadIdentityAuth.getToken()}` }]);
+ }
+ if (this.apiKey == null) {
+ return undefined;
+ }
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
}
+ protected async adminAPIKeyAuth(opts: FinalRequestOptions): Promise {
+ if (this.adminAPIKey == null) {
+ return undefined;
+ }
+ return buildHeaders([{ Authorization: `Bearer ${this.adminAPIKey}` }]);
+ }
+
protected stringifyQuery(query: object | Record): string {
return stringifyQuery(query);
}
@@ -576,7 +644,10 @@ export class OpenAI {
* Used as a callback for mutating the given `FinalRequestOptions` object.
*/
protected async prepareOptions(options: FinalRequestOptions): Promise {
- await this._callApiKey();
+ const security = options.__security ?? { bearerAuth: true };
+ if (security.bearerAuth) {
+ await this._callApiKey();
+ }
}
/**
@@ -668,8 +739,9 @@ export class OpenAI {
throw new Errors.APIUserAbortError();
}
+ const security = options.__security ?? { bearerAuth: true };
const controller = new AbortController();
- const response = await this.fetchWithAuth(url, req, timeout, controller).catch(castToError);
+ const response = await this.fetchWithAuth(url, req, timeout, controller, security).catch(castToError);
const headersTime = Date.now();
if (response instanceof globalThis.Error) {
@@ -732,6 +804,7 @@ export class OpenAI {
if (
response.status === 401 &&
this._workloadIdentityAuth &&
+ security.bearerAuth &&
!options.__metadata?.['hasStreamingBody'] &&
!options.__metadata?.['workloadIdentityTokenRefreshed']
) {
@@ -844,8 +917,12 @@ export class OpenAI {
init: RequestInit,
timeout: number,
controller: AbortController,
+ schemes: { bearerAuth?: boolean; adminAPIKeyAuth?: boolean } = {
+ bearerAuth: true,
+ adminAPIKeyAuth: true,
+ },
): Promise {
- if (this._workloadIdentityAuth) {
+ if (this._workloadIdentityAuth && schemes.bearerAuth) {
const headers = init.headers as Headers;
const authHeader = headers.get('Authorization');
if (!authHeader || authHeader === `Bearer ${WORKLOAD_IDENTITY_API_KEY_PLACEHOLDER}`) {
@@ -1035,13 +1112,13 @@ export class OpenAI {
'OpenAI-Organization': this.organization,
'OpenAI-Project': this.project,
},
- await this.authHeaders(options),
+ await this.authHeaders(options, options.__security ?? { bearerAuth: true }),
this._options.defaultHeaders,
bodyHeaders,
options.headers,
]);
- this.validateHeaders(headers);
+ this.validateHeaders(headers, options.__security ?? { bearerAuth: true });
return headers.values;
}
@@ -1176,6 +1253,7 @@ export class OpenAI {
* Use Uploads to upload large files in multiple parts.
*/
uploads: API.Uploads = new API.Uploads(this);
+ admin: API.Admin = new API.Admin(this);
responses: API.Responses = new API.Responses(this);
realtime: API.Realtime = new API.Realtime(this);
/**
@@ -1206,6 +1284,7 @@ OpenAI.Webhooks = Webhooks;
OpenAI.Beta = Beta;
OpenAI.Batches = Batches;
OpenAI.Uploads = UploadsAPIUploads;
+OpenAI.Admin = Admin;
OpenAI.Responses = Responses;
OpenAI.Realtime = Realtime;
OpenAI.Conversations = Conversations;
@@ -1229,6 +1308,12 @@ export declare namespace OpenAI {
type ConversationCursorPageResponse as ConversationCursorPageResponse,
};
+ export import NextCursorPage = Pagination.NextCursorPage;
+ export {
+ type NextCursorPageParams as NextCursorPageParams,
+ type NextCursorPageResponse as NextCursorPageResponse,
+ };
+
export {
Completions as Completions,
type Completion as Completion,
@@ -1391,6 +1476,8 @@ export declare namespace OpenAI {
type UploadCompleteParams as UploadCompleteParams,
};
+ export { Admin as Admin };
+
export { Responses as Responses };
export { Realtime as Realtime };
diff --git a/src/core/pagination.ts b/src/core/pagination.ts
index 9bef26447b..cd23ab7af1 100644
--- a/src/core/pagination.ts
+++ b/src/core/pagination.ts
@@ -267,3 +267,65 @@ export class ConversationCursorPage-
};
}
}
+
+export interface NextCursorPageResponse
- {
+ data: Array
- ;
+
+ has_more: boolean;
+
+ next: string | null;
+}
+
+export interface NextCursorPageParams {
+ after?: string;
+
+ limit?: number;
+}
+
+export class NextCursorPage
- extends AbstractPage
- implements NextCursorPageResponse
- {
+ data: Array
- ;
+
+ has_more: boolean;
+
+ next: string | null;
+
+ constructor(
+ client: OpenAI,
+ response: Response,
+ body: NextCursorPageResponse
- ,
+ options: FinalRequestOptions,
+ ) {
+ super(client, response, body, options);
+
+ this.data = body.data || [];
+ this.has_more = body.has_more || false;
+ this.next = body.next || null;
+ }
+
+ getPaginatedItems(): Item[] {
+ return this.data ?? [];
+ }
+
+ override hasNextPage(): boolean {
+ if (this.has_more === false) {
+ return false;
+ }
+
+ return super.hasNextPage();
+ }
+
+ nextPageRequestOptions(): PageRequestOptions | null {
+ const cursor = this.next;
+ if (!cursor) {
+ return null;
+ }
+
+ return {
+ ...this.options,
+ query: {
+ ...maybeObj(this.options.query),
+ after: cursor,
+ },
+ };
+ }
+}
diff --git a/src/internal/request-options.ts b/src/internal/request-options.ts
index 991919e1fe..afed093290 100644
--- a/src/internal/request-options.ts
+++ b/src/internal/request-options.ts
@@ -77,6 +77,7 @@ export type RequestOptions = {
defaultBaseURL?: string | undefined;
__metadata?: Record;
+ __security?: { bearerAuth?: boolean; adminAPIKeyAuth?: boolean };
__binaryResponse?: boolean | undefined;
__streamClass?: typeof Stream;
__synthesizeEventData?: boolean;
diff --git a/src/realtime/websocket.ts b/src/realtime/websocket.ts
index 5362661927..0abfdb7a26 100644
--- a/src/realtime/websocket.ts
+++ b/src/realtime/websocket.ts
@@ -116,11 +116,16 @@ export class OpenAIRealtimeWebSocket extends OpenAIRealtimeEmitter {
options: { deploymentName?: string; dangerouslyAllowBrowser?: boolean } = {},
): Promise {
const isApiKeyProvider = await client._callApiKey();
+ const apiKey = client.apiKey;
+ if (!apiKey) {
+ throw new Error('Azure OpenAI Realtime requires an API key');
+ }
+ const azureApiKey = apiKey;
function onURL(url: URL) {
if (isApiKeyProvider) {
- url.searchParams.set('Authorization', `Bearer ${client.apiKey}`);
+ url.searchParams.set('Authorization', `Bearer ${azureApiKey}`);
} else {
- url.searchParams.set('api-key', client.apiKey);
+ url.searchParams.set('api-key', azureApiKey);
}
}
const deploymentName = options.deploymentName ?? client.deploymentName;
diff --git a/src/realtime/ws.ts b/src/realtime/ws.ts
index cf79c185d9..2dd97f1695 100644
--- a/src/realtime/ws.ts
+++ b/src/realtime/ws.ts
@@ -75,6 +75,10 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
props: { deploymentName?: string; options?: WS.ClientOptions | undefined } = {},
): Promise {
const isApiKeyProvider = await client._callApiKey();
+ const apiKey = client.apiKey;
+ if (!apiKey) {
+ throw new Error('Azure OpenAI Realtime requires an API key');
+ }
const deploymentName = props.deploymentName ?? client.deploymentName;
if (!deploymentName) {
throw new Error('No deployment name provided');
@@ -86,7 +90,7 @@ export class OpenAIRealtimeWS extends OpenAIRealtimeEmitter {
...props.options,
headers: {
...props.options?.headers,
- ...(isApiKeyProvider ? {} : { 'api-key': client.apiKey }),
+ ...(isApiKeyProvider ? {} : { 'api-key': apiKey }),
},
},
__resolvedApiKey: isApiKeyProvider,
diff --git a/src/resources/admin.ts b/src/resources/admin.ts
new file mode 100644
index 0000000000..12e3c483ad
--- /dev/null
+++ b/src/resources/admin.ts
@@ -0,0 +1,3 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export * from './admin/index';
diff --git a/src/resources/admin/admin.ts b/src/resources/admin/admin.ts
new file mode 100644
index 0000000000..4d9340b475
--- /dev/null
+++ b/src/resources/admin/admin.ts
@@ -0,0 +1,15 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../core/resource';
+import * as OrganizationAPI from './organization/organization';
+import { Organization } from './organization/organization';
+
+export class Admin extends APIResource {
+ organization: OrganizationAPI.Organization = new OrganizationAPI.Organization(this._client);
+}
+
+Admin.Organization = Organization;
+
+export declare namespace Admin {
+ export { Organization as Organization };
+}
diff --git a/src/resources/admin/index.ts b/src/resources/admin/index.ts
new file mode 100644
index 0000000000..c6ebb099b6
--- /dev/null
+++ b/src/resources/admin/index.ts
@@ -0,0 +1,4 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export { Admin } from './admin';
+export { Organization } from './organization/index';
diff --git a/src/resources/admin/organization.ts b/src/resources/admin/organization.ts
new file mode 100644
index 0000000000..4e74c0d480
--- /dev/null
+++ b/src/resources/admin/organization.ts
@@ -0,0 +1,3 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export * from './organization/index';
diff --git a/src/resources/admin/organization/admin-api-keys.ts b/src/resources/admin/organization/admin-api-keys.ts
new file mode 100644
index 0000000000..50fe8b036c
--- /dev/null
+++ b/src/resources/admin/organization/admin-api-keys.ts
@@ -0,0 +1,204 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../core/resource';
+import { APIPromise } from '../../../core/api-promise';
+import { CursorPage, type CursorPageParams, PagePromise } from '../../../core/pagination';
+import { RequestOptions } from '../../../internal/request-options';
+import { path } from '../../../internal/utils/path';
+
+export class AdminAPIKeys extends APIResource {
+ /**
+ * Create an organization admin API key
+ *
+ * @example
+ * ```ts
+ * const adminAPIKey =
+ * await client.admin.organization.adminAPIKeys.create({
+ * name: 'New Admin Key',
+ * });
+ * ```
+ */
+ create(body: AdminAPIKeyCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post('/organization/admin_api_keys', {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Retrieve a single organization API key
+ *
+ * @example
+ * ```ts
+ * const adminAPIKey =
+ * await client.admin.organization.adminAPIKeys.retrieve(
+ * 'key_id',
+ * );
+ * ```
+ */
+ retrieve(keyID: string, options?: RequestOptions): APIPromise {
+ return this._client.get(path`/organization/admin_api_keys/${keyID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * List organization API keys
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const adminAPIKey of client.admin.organization.adminAPIKeys.list()) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ query: AdminAPIKeyListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList('/organization/admin_api_keys', CursorPage, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Delete an organization admin API key
+ *
+ * @example
+ * ```ts
+ * const adminAPIKey =
+ * await client.admin.organization.adminAPIKeys.delete(
+ * 'key_id',
+ * );
+ * ```
+ */
+ delete(keyID: string, options?: RequestOptions): APIPromise {
+ return this._client.delete(path`/organization/admin_api_keys/${keyID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type AdminAPIKeysPage = CursorPage;
+
+/**
+ * Represents an individual Admin API key in an org.
+ */
+export interface AdminAPIKey {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the API key was created
+ */
+ created_at: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the API key was last used
+ */
+ last_used_at: number | null;
+
+ /**
+ * The name of the API key
+ */
+ name: string;
+
+ /**
+ * The object type, which is always `organization.admin_api_key`
+ */
+ object: 'organization.admin_api_key';
+
+ owner: AdminAPIKey.Owner;
+
+ /**
+ * The redacted value of the API key
+ */
+ redacted_value: string;
+
+ /**
+ * The value of the API key. Only shown on create.
+ */
+ value?: string;
+}
+
+export namespace AdminAPIKey {
+ export interface Owner {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id?: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the user was created
+ */
+ created_at?: number;
+
+ /**
+ * The name of the user
+ */
+ name?: string;
+
+ /**
+ * The object type, which is always organization.user
+ */
+ object?: string;
+
+ /**
+ * Always `owner`
+ */
+ role?: string;
+
+ /**
+ * Always `user`
+ */
+ type?: string;
+ }
+}
+
+/**
+ * Represents an individual Admin API key in an org.
+ */
+export interface AdminAPIKeyCreateResponse extends AdminAPIKey {
+ /**
+ * The value of the API key. Only shown on create.
+ */
+ value: string;
+}
+
+export interface AdminAPIKeyDeleteResponse {
+ id: string;
+
+ deleted: boolean;
+
+ object: 'organization.admin_api_key.deleted';
+}
+
+export interface AdminAPIKeyCreateParams {
+ name: string;
+}
+
+export interface AdminAPIKeyListParams extends CursorPageParams {
+ /**
+ * Order results by creation time, ascending or descending.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export declare namespace AdminAPIKeys {
+ export {
+ type AdminAPIKey as AdminAPIKey,
+ type AdminAPIKeyCreateResponse as AdminAPIKeyCreateResponse,
+ type AdminAPIKeyDeleteResponse as AdminAPIKeyDeleteResponse,
+ type AdminAPIKeysPage as AdminAPIKeysPage,
+ type AdminAPIKeyCreateParams as AdminAPIKeyCreateParams,
+ type AdminAPIKeyListParams as AdminAPIKeyListParams,
+ };
+}
diff --git a/src/resources/admin/organization/audit-logs.ts b/src/resources/admin/organization/audit-logs.ts
new file mode 100644
index 0000000000..4ace09256f
--- /dev/null
+++ b/src/resources/admin/organization/audit-logs.ts
@@ -0,0 +1,1597 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../core/resource';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ PagePromise,
+} from '../../../core/pagination';
+import { RequestOptions } from '../../../internal/request-options';
+
+/**
+ * List user actions and configuration changes within this organization.
+ */
+export class AuditLogs extends APIResource {
+ /**
+ * List user actions and configuration changes within this organization.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const auditLogListResponse of client.admin.organization.auditLogs.list()) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ query: AuditLogListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList('/organization/audit_logs', ConversationCursorPage, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type AuditLogListResponsesPage = ConversationCursorPage;
+
+/**
+ * A log of a user action or configuration change within this organization.
+ */
+export interface AuditLogListResponse {
+ /**
+ * The ID of this log.
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of the event.
+ */
+ effective_at: number;
+
+ /**
+ * The event type.
+ */
+ type:
+ | 'api_key.created'
+ | 'api_key.updated'
+ | 'api_key.deleted'
+ | 'certificate.created'
+ | 'certificate.updated'
+ | 'certificate.deleted'
+ | 'certificates.activated'
+ | 'certificates.deactivated'
+ | 'checkpoint.permission.created'
+ | 'checkpoint.permission.deleted'
+ | 'external_key.registered'
+ | 'external_key.removed'
+ | 'group.created'
+ | 'group.updated'
+ | 'group.deleted'
+ | 'invite.sent'
+ | 'invite.accepted'
+ | 'invite.deleted'
+ | 'ip_allowlist.created'
+ | 'ip_allowlist.updated'
+ | 'ip_allowlist.deleted'
+ | 'ip_allowlist.config.activated'
+ | 'ip_allowlist.config.deactivated'
+ | 'login.succeeded'
+ | 'login.failed'
+ | 'logout.succeeded'
+ | 'logout.failed'
+ | 'organization.updated'
+ | 'project.created'
+ | 'project.updated'
+ | 'project.archived'
+ | 'project.deleted'
+ | 'rate_limit.updated'
+ | 'rate_limit.deleted'
+ | 'resource.deleted'
+ | 'tunnel.created'
+ | 'tunnel.updated'
+ | 'tunnel.deleted'
+ | 'role.created'
+ | 'role.updated'
+ | 'role.deleted'
+ | 'role.assignment.created'
+ | 'role.assignment.deleted'
+ | 'scim.enabled'
+ | 'scim.disabled'
+ | 'service_account.created'
+ | 'service_account.updated'
+ | 'service_account.deleted'
+ | 'user.added'
+ | 'user.updated'
+ | 'user.deleted';
+
+ /**
+ * The actor who performed the audit logged action.
+ */
+ actor?: AuditLogListResponse.Actor | null;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'api_key.created'?: AuditLogListResponse.APIKeyCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'api_key.deleted'?: AuditLogListResponse.APIKeyDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'api_key.updated'?: AuditLogListResponse.APIKeyUpdated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'certificate.created'?: AuditLogListResponse.CertificateCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'certificate.deleted'?: AuditLogListResponse.CertificateDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'certificate.updated'?: AuditLogListResponse.CertificateUpdated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'certificates.activated'?: AuditLogListResponse.CertificatesActivated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'certificates.deactivated'?: AuditLogListResponse.CertificatesDeactivated;
+
+ /**
+ * The project and fine-tuned model checkpoint that the checkpoint permission was
+ * created for.
+ */
+ 'checkpoint.permission.created'?: AuditLogListResponse.CheckpointPermissionCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'checkpoint.permission.deleted'?: AuditLogListResponse.CheckpointPermissionDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'external_key.registered'?: AuditLogListResponse.ExternalKeyRegistered;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'external_key.removed'?: AuditLogListResponse.ExternalKeyRemoved;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'group.created'?: AuditLogListResponse.GroupCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'group.deleted'?: AuditLogListResponse.GroupDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'group.updated'?: AuditLogListResponse.GroupUpdated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'invite.accepted'?: AuditLogListResponse.InviteAccepted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'invite.deleted'?: AuditLogListResponse.InviteDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'invite.sent'?: AuditLogListResponse.InviteSent;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'ip_allowlist.config.activated'?: AuditLogListResponse.IPAllowlistConfigActivated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'ip_allowlist.config.deactivated'?: AuditLogListResponse.IPAllowlistConfigDeactivated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'ip_allowlist.created'?: AuditLogListResponse.IPAllowlistCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'ip_allowlist.deleted'?: AuditLogListResponse.IPAllowlistDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'ip_allowlist.updated'?: AuditLogListResponse.IPAllowlistUpdated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'login.failed'?: AuditLogListResponse.LoginFailed;
+
+ /**
+ * This event has no additional fields beyond the standard audit log attributes.
+ */
+ 'login.succeeded'?: unknown;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'logout.failed'?: AuditLogListResponse.LogoutFailed;
+
+ /**
+ * This event has no additional fields beyond the standard audit log attributes.
+ */
+ 'logout.succeeded'?: unknown;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'organization.updated'?: AuditLogListResponse.OrganizationUpdated;
+
+ /**
+ * 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.
+ */
+ project?: AuditLogListResponse.Project;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'project.archived'?: AuditLogListResponse.ProjectArchived;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'project.created'?: AuditLogListResponse.ProjectCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'project.deleted'?: AuditLogListResponse.ProjectDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'project.updated'?: AuditLogListResponse.ProjectUpdated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'rate_limit.deleted'?: AuditLogListResponse.RateLimitDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'rate_limit.updated'?: AuditLogListResponse.RateLimitUpdated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'role.assignment.created'?: AuditLogListResponse.RoleAssignmentCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'role.assignment.deleted'?: AuditLogListResponse.RoleAssignmentDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'role.created'?: AuditLogListResponse.RoleCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'role.deleted'?: AuditLogListResponse.RoleDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'role.updated'?: AuditLogListResponse.RoleUpdated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'scim.disabled'?: AuditLogListResponse.ScimDisabled;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'scim.enabled'?: AuditLogListResponse.ScimEnabled;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'service_account.created'?: AuditLogListResponse.ServiceAccountCreated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'service_account.deleted'?: AuditLogListResponse.ServiceAccountDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'service_account.updated'?: AuditLogListResponse.ServiceAccountUpdated;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'user.added'?: AuditLogListResponse.UserAdded;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'user.deleted'?: AuditLogListResponse.UserDeleted;
+
+ /**
+ * The details for events with this `type`.
+ */
+ 'user.updated'?: AuditLogListResponse.UserUpdated;
+}
+
+export namespace AuditLogListResponse {
+ /**
+ * The actor who performed the audit logged action.
+ */
+ export interface Actor {
+ /**
+ * The API Key used to perform the audit logged action.
+ */
+ api_key?: Actor.APIKey;
+
+ /**
+ * The session in which the audit logged action was performed.
+ */
+ session?: Actor.Session;
+
+ /**
+ * The type of actor. Is either `session` or `api_key`.
+ */
+ type?: 'session' | 'api_key';
+ }
+
+ export namespace Actor {
+ /**
+ * The API Key used to perform the audit logged action.
+ */
+ export interface APIKey {
+ /**
+ * The tracking id of the API key.
+ */
+ id?: string;
+
+ /**
+ * The service account that performed the audit logged action.
+ */
+ service_account?: APIKey.ServiceAccount;
+
+ /**
+ * The type of API key. Can be either `user` or `service_account`.
+ */
+ type?: 'user' | 'service_account';
+
+ /**
+ * The user who performed the audit logged action.
+ */
+ user?: APIKey.User;
+ }
+
+ export namespace APIKey {
+ /**
+ * The service account that performed the audit logged action.
+ */
+ export interface ServiceAccount {
+ /**
+ * The service account id.
+ */
+ id?: string;
+ }
+
+ /**
+ * The user who performed the audit logged action.
+ */
+ export interface User {
+ /**
+ * The user id.
+ */
+ id?: string;
+
+ /**
+ * The user email.
+ */
+ email?: string;
+ }
+ }
+
+ /**
+ * The session in which the audit logged action was performed.
+ */
+ export interface Session {
+ /**
+ * The IP address from which the action was performed.
+ */
+ ip_address?: string;
+
+ /**
+ * The user who performed the audit logged action.
+ */
+ user?: Session.User;
+ }
+
+ export namespace Session {
+ /**
+ * The user who performed the audit logged action.
+ */
+ export interface User {
+ /**
+ * The user id.
+ */
+ id?: string;
+
+ /**
+ * The user email.
+ */
+ email?: string;
+ }
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface APIKeyCreated {
+ /**
+ * The tracking ID of the API key.
+ */
+ id?: string;
+
+ /**
+ * The payload used to create the API key.
+ */
+ data?: APIKeyCreated.Data;
+ }
+
+ export namespace APIKeyCreated {
+ /**
+ * The payload used to create the API key.
+ */
+ export interface Data {
+ /**
+ * A list of scopes allowed for the API key, e.g. `["api.model.request"]`
+ */
+ scopes?: Array;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface APIKeyDeleted {
+ /**
+ * The tracking ID of the API key.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface APIKeyUpdated {
+ /**
+ * The tracking ID of the API key.
+ */
+ id?: string;
+
+ /**
+ * The payload used to update the API key.
+ */
+ changes_requested?: APIKeyUpdated.ChangesRequested;
+ }
+
+ export namespace APIKeyUpdated {
+ /**
+ * The payload used to update the API key.
+ */
+ export interface ChangesRequested {
+ /**
+ * A list of scopes allowed for the API key, e.g. `["api.model.request"]`
+ */
+ scopes?: Array;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface CertificateCreated {
+ /**
+ * The certificate ID.
+ */
+ id?: string;
+
+ /**
+ * The name of the certificate.
+ */
+ name?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface CertificateDeleted {
+ /**
+ * The certificate ID.
+ */
+ id?: string;
+
+ /**
+ * The certificate content in PEM format.
+ */
+ certificate?: string;
+
+ /**
+ * The name of the certificate.
+ */
+ name?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface CertificateUpdated {
+ /**
+ * The certificate ID.
+ */
+ id?: string;
+
+ /**
+ * The name of the certificate.
+ */
+ name?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface CertificatesActivated {
+ certificates?: Array;
+ }
+
+ export namespace CertificatesActivated {
+ export interface Certificate {
+ /**
+ * The certificate ID.
+ */
+ id?: string;
+
+ /**
+ * The name of the certificate.
+ */
+ name?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface CertificatesDeactivated {
+ certificates?: Array;
+ }
+
+ export namespace CertificatesDeactivated {
+ export interface Certificate {
+ /**
+ * The certificate ID.
+ */
+ id?: string;
+
+ /**
+ * The name of the certificate.
+ */
+ name?: string;
+ }
+ }
+
+ /**
+ * The project and fine-tuned model checkpoint that the checkpoint permission was
+ * created for.
+ */
+ export interface CheckpointPermissionCreated {
+ /**
+ * The ID of the checkpoint permission.
+ */
+ id?: string;
+
+ /**
+ * The payload used to create the checkpoint permission.
+ */
+ data?: CheckpointPermissionCreated.Data;
+ }
+
+ export namespace CheckpointPermissionCreated {
+ /**
+ * The payload used to create the checkpoint permission.
+ */
+ export interface Data {
+ /**
+ * The ID of the fine-tuned model checkpoint.
+ */
+ fine_tuned_model_checkpoint?: string;
+
+ /**
+ * The ID of the project that the checkpoint permission was created for.
+ */
+ project_id?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface CheckpointPermissionDeleted {
+ /**
+ * The ID of the checkpoint permission.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ExternalKeyRegistered {
+ /**
+ * The ID of the external key configuration.
+ */
+ id?: string;
+
+ /**
+ * The configuration for the external key.
+ */
+ data?: unknown;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ExternalKeyRemoved {
+ /**
+ * The ID of the external key configuration.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface GroupCreated {
+ /**
+ * The ID of the group.
+ */
+ id?: string;
+
+ /**
+ * Information about the created group.
+ */
+ data?: GroupCreated.Data;
+ }
+
+ export namespace GroupCreated {
+ /**
+ * Information about the created group.
+ */
+ export interface Data {
+ /**
+ * The group name.
+ */
+ group_name?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface GroupDeleted {
+ /**
+ * The ID of the group.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface GroupUpdated {
+ /**
+ * The ID of the group.
+ */
+ id?: string;
+
+ /**
+ * The payload used to update the group.
+ */
+ changes_requested?: GroupUpdated.ChangesRequested;
+ }
+
+ export namespace GroupUpdated {
+ /**
+ * The payload used to update the group.
+ */
+ export interface ChangesRequested {
+ /**
+ * The updated group name.
+ */
+ group_name?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface InviteAccepted {
+ /**
+ * The ID of the invite.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface InviteDeleted {
+ /**
+ * The ID of the invite.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface InviteSent {
+ /**
+ * The ID of the invite.
+ */
+ id?: string;
+
+ /**
+ * The payload used to create the invite.
+ */
+ data?: InviteSent.Data;
+ }
+
+ export namespace InviteSent {
+ /**
+ * The payload used to create the invite.
+ */
+ export interface Data {
+ /**
+ * The email invited to the organization.
+ */
+ email?: string;
+
+ /**
+ * The role the email was invited to be. Is either `owner` or `member`.
+ */
+ role?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface IPAllowlistConfigActivated {
+ /**
+ * The configurations that were activated.
+ */
+ configs?: Array;
+ }
+
+ export namespace IPAllowlistConfigActivated {
+ export interface Config {
+ /**
+ * The ID of the IP allowlist configuration.
+ */
+ id?: string;
+
+ /**
+ * The name of the IP allowlist configuration.
+ */
+ name?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface IPAllowlistConfigDeactivated {
+ /**
+ * The configurations that were deactivated.
+ */
+ configs?: Array;
+ }
+
+ export namespace IPAllowlistConfigDeactivated {
+ export interface Config {
+ /**
+ * The ID of the IP allowlist configuration.
+ */
+ id?: string;
+
+ /**
+ * The name of the IP allowlist configuration.
+ */
+ name?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface IPAllowlistCreated {
+ /**
+ * The ID of the IP allowlist configuration.
+ */
+ id?: string;
+
+ /**
+ * The IP addresses or CIDR ranges included in the configuration.
+ */
+ allowed_ips?: Array;
+
+ /**
+ * The name of the IP allowlist configuration.
+ */
+ name?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface IPAllowlistDeleted {
+ /**
+ * The ID of the IP allowlist configuration.
+ */
+ id?: string;
+
+ /**
+ * The IP addresses or CIDR ranges that were in the configuration.
+ */
+ allowed_ips?: Array;
+
+ /**
+ * The name of the IP allowlist configuration.
+ */
+ name?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface IPAllowlistUpdated {
+ /**
+ * The ID of the IP allowlist configuration.
+ */
+ id?: string;
+
+ /**
+ * The updated set of IP addresses or CIDR ranges in the configuration.
+ */
+ allowed_ips?: Array;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface LoginFailed {
+ /**
+ * The error code of the failure.
+ */
+ error_code?: string;
+
+ /**
+ * The error message of the failure.
+ */
+ error_message?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface LogoutFailed {
+ /**
+ * The error code of the failure.
+ */
+ error_code?: string;
+
+ /**
+ * The error message of the failure.
+ */
+ error_message?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface OrganizationUpdated {
+ /**
+ * The organization ID.
+ */
+ id?: string;
+
+ /**
+ * The payload used to update the organization settings.
+ */
+ changes_requested?: OrganizationUpdated.ChangesRequested;
+ }
+
+ export namespace OrganizationUpdated {
+ /**
+ * The payload used to update the organization settings.
+ */
+ export interface ChangesRequested {
+ /**
+ * How your organization logs data from supported API calls. One of `disabled`,
+ * `enabled_per_call`, `enabled_for_all_projects`, or
+ * `enabled_for_selected_projects`
+ */
+ api_call_logging?: string;
+
+ /**
+ * The list of project ids if api_call_logging is set to
+ * `enabled_for_selected_projects`
+ */
+ api_call_logging_project_ids?: string;
+
+ /**
+ * The organization description.
+ */
+ description?: string;
+
+ /**
+ * The organization name.
+ */
+ name?: string;
+
+ /**
+ * Visibility of the threads page which shows messages created with the Assistants
+ * API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`.
+ */
+ threads_ui_visibility?: string;
+
+ /**
+ * The organization title.
+ */
+ title?: string;
+
+ /**
+ * Visibility of the usage dashboard which shows activity and costs for your
+ * organization. One of `ANY_ROLE` or `OWNERS`.
+ */
+ usage_dashboard_visibility?: string;
+ }
+ }
+
+ /**
+ * 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.
+ */
+ export interface Project {
+ /**
+ * The project ID.
+ */
+ id?: string;
+
+ /**
+ * The project title.
+ */
+ name?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ProjectArchived {
+ /**
+ * The project ID.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ProjectCreated {
+ /**
+ * The project ID.
+ */
+ id?: string;
+
+ /**
+ * The payload used to create the project.
+ */
+ data?: ProjectCreated.Data;
+ }
+
+ export namespace ProjectCreated {
+ /**
+ * The payload used to create the project.
+ */
+ export interface Data {
+ /**
+ * The project name.
+ */
+ name?: string;
+
+ /**
+ * The title of the project as seen on the dashboard.
+ */
+ title?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ProjectDeleted {
+ /**
+ * The project ID.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ProjectUpdated {
+ /**
+ * The project ID.
+ */
+ id?: string;
+
+ /**
+ * The payload used to update the project.
+ */
+ changes_requested?: ProjectUpdated.ChangesRequested;
+ }
+
+ export namespace ProjectUpdated {
+ /**
+ * The payload used to update the project.
+ */
+ export interface ChangesRequested {
+ /**
+ * The title of the project as seen on the dashboard.
+ */
+ title?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface RateLimitDeleted {
+ /**
+ * The rate limit ID
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface RateLimitUpdated {
+ /**
+ * The rate limit ID
+ */
+ id?: string;
+
+ /**
+ * The payload used to update the rate limits.
+ */
+ changes_requested?: RateLimitUpdated.ChangesRequested;
+ }
+
+ export namespace RateLimitUpdated {
+ /**
+ * The payload used to update the rate limits.
+ */
+ export interface ChangesRequested {
+ /**
+ * The maximum batch input tokens per day. Only relevant for certain models.
+ */
+ batch_1_day_max_input_tokens?: number;
+
+ /**
+ * The maximum audio megabytes per minute. Only relevant for certain models.
+ */
+ max_audio_megabytes_per_1_minute?: number;
+
+ /**
+ * The maximum images per minute. Only relevant for certain models.
+ */
+ max_images_per_1_minute?: number;
+
+ /**
+ * The maximum requests per day. Only relevant for certain models.
+ */
+ max_requests_per_1_day?: number;
+
+ /**
+ * The maximum requests per minute.
+ */
+ max_requests_per_1_minute?: number;
+
+ /**
+ * The maximum tokens per minute.
+ */
+ max_tokens_per_1_minute?: number;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface RoleAssignmentCreated {
+ /**
+ * The identifier of the role assignment.
+ */
+ id?: string;
+
+ /**
+ * The principal (user or group) that received the role.
+ */
+ principal_id?: string;
+
+ /**
+ * The type of principal (user or group) that received the role.
+ */
+ principal_type?: string;
+
+ /**
+ * The resource the role assignment is scoped to.
+ */
+ resource_id?: string;
+
+ /**
+ * The type of resource the role assignment is scoped to.
+ */
+ resource_type?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface RoleAssignmentDeleted {
+ /**
+ * The identifier of the role assignment.
+ */
+ id?: string;
+
+ /**
+ * The principal (user or group) that had the role removed.
+ */
+ principal_id?: string;
+
+ /**
+ * The type of principal (user or group) that had the role removed.
+ */
+ principal_type?: string;
+
+ /**
+ * The resource the role assignment was scoped to.
+ */
+ resource_id?: string;
+
+ /**
+ * The type of resource the role assignment was scoped to.
+ */
+ resource_type?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface RoleCreated {
+ /**
+ * The role ID.
+ */
+ id?: string;
+
+ /**
+ * The permissions granted by the role.
+ */
+ permissions?: Array;
+
+ /**
+ * The resource the role is scoped to.
+ */
+ resource_id?: string;
+
+ /**
+ * The type of resource the role belongs to.
+ */
+ resource_type?: string;
+
+ /**
+ * The name of the role.
+ */
+ role_name?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface RoleDeleted {
+ /**
+ * The role ID.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface RoleUpdated {
+ /**
+ * The role ID.
+ */
+ id?: string;
+
+ /**
+ * The payload used to update the role.
+ */
+ changes_requested?: RoleUpdated.ChangesRequested;
+ }
+
+ export namespace RoleUpdated {
+ /**
+ * The payload used to update the role.
+ */
+ export interface ChangesRequested {
+ /**
+ * The updated role description, when provided.
+ */
+ description?: string;
+
+ /**
+ * Additional metadata stored on the role.
+ */
+ metadata?: unknown;
+
+ /**
+ * The permissions added to the role.
+ */
+ permissions_added?: Array;
+
+ /**
+ * The permissions removed from the role.
+ */
+ permissions_removed?: Array;
+
+ /**
+ * The resource the role is scoped to.
+ */
+ resource_id?: string;
+
+ /**
+ * The type of resource the role belongs to.
+ */
+ resource_type?: string;
+
+ /**
+ * The updated role name, when provided.
+ */
+ role_name?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ScimDisabled {
+ /**
+ * The ID of the SCIM was disabled for.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ScimEnabled {
+ /**
+ * The ID of the SCIM was enabled for.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ServiceAccountCreated {
+ /**
+ * The service account ID.
+ */
+ id?: string;
+
+ /**
+ * The payload used to create the service account.
+ */
+ data?: ServiceAccountCreated.Data;
+ }
+
+ export namespace ServiceAccountCreated {
+ /**
+ * The payload used to create the service account.
+ */
+ export interface Data {
+ /**
+ * The role of the service account. Is either `owner` or `member`.
+ */
+ role?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ServiceAccountDeleted {
+ /**
+ * The service account ID.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface ServiceAccountUpdated {
+ /**
+ * The service account ID.
+ */
+ id?: string;
+
+ /**
+ * The payload used to updated the service account.
+ */
+ changes_requested?: ServiceAccountUpdated.ChangesRequested;
+ }
+
+ export namespace ServiceAccountUpdated {
+ /**
+ * The payload used to updated the service account.
+ */
+ export interface ChangesRequested {
+ /**
+ * The role of the service account. Is either `owner` or `member`.
+ */
+ role?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface UserAdded {
+ /**
+ * The user ID.
+ */
+ id?: string;
+
+ /**
+ * The payload used to add the user to the project.
+ */
+ data?: UserAdded.Data;
+ }
+
+ export namespace UserAdded {
+ /**
+ * The payload used to add the user to the project.
+ */
+ export interface Data {
+ /**
+ * The role of the user. Is either `owner` or `member`.
+ */
+ role?: string;
+ }
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface UserDeleted {
+ /**
+ * The user ID.
+ */
+ id?: string;
+ }
+
+ /**
+ * The details for events with this `type`.
+ */
+ export interface UserUpdated {
+ /**
+ * The project ID.
+ */
+ id?: string;
+
+ /**
+ * The payload used to update the user.
+ */
+ changes_requested?: UserUpdated.ChangesRequested;
+ }
+
+ export namespace UserUpdated {
+ /**
+ * The payload used to update the user.
+ */
+ export interface ChangesRequested {
+ /**
+ * The role of the user. Is either `owner` or `member`.
+ */
+ role?: string;
+ }
+ }
+}
+
+export interface AuditLogListParams extends ConversationCursorPageParams {
+ /**
+ * Return only events performed by users with these emails.
+ */
+ actor_emails?: Array;
+
+ /**
+ * Return only events performed by these actors. Can be a user ID, a service
+ * account ID, or an api key tracking ID.
+ */
+ actor_ids?: Array;
+
+ /**
+ * 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.
+ */
+ before?: string;
+
+ /**
+ * Return only events whose `effective_at` (Unix seconds) is in this range.
+ */
+ effective_at?: AuditLogListParams.EffectiveAt;
+
+ /**
+ * 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).
+ */
+ event_types?: Array<
+ | 'api_key.created'
+ | 'api_key.updated'
+ | 'api_key.deleted'
+ | 'certificate.created'
+ | 'certificate.updated'
+ | 'certificate.deleted'
+ | 'certificates.activated'
+ | 'certificates.deactivated'
+ | 'checkpoint.permission.created'
+ | 'checkpoint.permission.deleted'
+ | 'external_key.registered'
+ | 'external_key.removed'
+ | 'group.created'
+ | 'group.updated'
+ | 'group.deleted'
+ | 'invite.sent'
+ | 'invite.accepted'
+ | 'invite.deleted'
+ | 'ip_allowlist.created'
+ | 'ip_allowlist.updated'
+ | 'ip_allowlist.deleted'
+ | 'ip_allowlist.config.activated'
+ | 'ip_allowlist.config.deactivated'
+ | 'login.succeeded'
+ | 'login.failed'
+ | 'logout.succeeded'
+ | 'logout.failed'
+ | 'organization.updated'
+ | 'project.created'
+ | 'project.updated'
+ | 'project.archived'
+ | 'project.deleted'
+ | 'rate_limit.updated'
+ | 'rate_limit.deleted'
+ | 'resource.deleted'
+ | 'tunnel.created'
+ | 'tunnel.updated'
+ | 'tunnel.deleted'
+ | 'role.created'
+ | 'role.updated'
+ | 'role.deleted'
+ | 'role.assignment.created'
+ | 'role.assignment.deleted'
+ | 'scim.enabled'
+ | 'scim.disabled'
+ | 'service_account.created'
+ | 'service_account.updated'
+ | 'service_account.deleted'
+ | 'user.added'
+ | 'user.updated'
+ | 'user.deleted'
+ >;
+
+ /**
+ * Return only events for these projects.
+ */
+ project_ids?: Array;
+
+ /**
+ * Return only events performed on these targets. For example, a project ID
+ * updated.
+ */
+ resource_ids?: Array;
+}
+
+export namespace AuditLogListParams {
+ /**
+ * Return only events whose `effective_at` (Unix seconds) is in this range.
+ */
+ export interface EffectiveAt {
+ /**
+ * Return only events whose `effective_at` (Unix seconds) is greater than this
+ * value.
+ */
+ gt?: number;
+
+ /**
+ * Return only events whose `effective_at` (Unix seconds) is greater than or equal
+ * to this value.
+ */
+ gte?: number;
+
+ /**
+ * Return only events whose `effective_at` (Unix seconds) is less than this value.
+ */
+ lt?: number;
+
+ /**
+ * Return only events whose `effective_at` (Unix seconds) is less than or equal to
+ * this value.
+ */
+ lte?: number;
+ }
+}
+
+export declare namespace AuditLogs {
+ export {
+ type AuditLogListResponse as AuditLogListResponse,
+ type AuditLogListResponsesPage as AuditLogListResponsesPage,
+ type AuditLogListParams as AuditLogListParams,
+ };
+}
diff --git a/src/resources/admin/organization/certificates.ts b/src/resources/admin/organization/certificates.ts
new file mode 100644
index 0000000000..e3c602a740
--- /dev/null
+++ b/src/resources/admin/organization/certificates.ts
@@ -0,0 +1,458 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../core/resource';
+import { APIPromise } from '../../../core/api-promise';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ Page,
+ PagePromise,
+} from '../../../core/pagination';
+import { RequestOptions } from '../../../internal/request-options';
+import { path } from '../../../internal/utils/path';
+
+export class Certificates extends APIResource {
+ /**
+ * Upload a certificate to the organization. This does **not** automatically
+ * activate the certificate.
+ *
+ * Organizations can upload up to 50 certificates.
+ *
+ * @example
+ * ```ts
+ * const certificate =
+ * await client.admin.organization.certificates.create({
+ * certificate: 'certificate',
+ * });
+ * ```
+ */
+ create(body: CertificateCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post('/organization/certificates', {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get a certificate that has been uploaded to the organization.
+ *
+ * You can get a certificate regardless of whether it is active or not.
+ *
+ * @example
+ * ```ts
+ * const certificate =
+ * await client.admin.organization.certificates.retrieve(
+ * 'certificate_id',
+ * );
+ * ```
+ */
+ retrieve(
+ certificateID: string,
+ query: CertificateRetrieveParams | null | undefined = {},
+ options?: RequestOptions,
+ ): APIPromise {
+ return this._client.get(path`/organization/certificates/${certificateID}`, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Modify a certificate. Note that only the name can be modified.
+ *
+ * @example
+ * ```ts
+ * const certificate =
+ * await client.admin.organization.certificates.update(
+ * 'certificate_id',
+ * );
+ * ```
+ */
+ update(
+ certificateID: string,
+ body: CertificateUpdateParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ return this._client.post(path`/organization/certificates/${certificateID}`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * List uploaded certificates for this organization.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const certificateListResponse of client.admin.organization.certificates.list()) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ query: CertificateListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ '/organization/certificates',
+ ConversationCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Delete a certificate from the organization.
+ *
+ * The certificate must be inactive for the organization and all projects.
+ *
+ * @example
+ * ```ts
+ * const certificate =
+ * await client.admin.organization.certificates.delete(
+ * 'certificate_id',
+ * );
+ * ```
+ */
+ delete(certificateID: string, options?: RequestOptions): APIPromise {
+ return this._client.delete(path`/organization/certificates/${certificateID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Activate certificates at the organization level.
+ *
+ * You can atomically and idempotently activate up to 10 certificates at a time.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const certificateActivateResponse of client.admin.organization.certificates.activate(
+ * { certificate_ids: ['cert_abc'] },
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ activate(
+ body: CertificateActivateParams,
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList('/organization/certificates/activate', Page, {
+ body,
+ method: 'post',
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Deactivate certificates at the organization level.
+ *
+ * You can atomically and idempotently deactivate up to 10 certificates at a time.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const certificateDeactivateResponse of client.admin.organization.certificates.deactivate(
+ * { certificate_ids: ['cert_abc'] },
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ deactivate(
+ body: CertificateDeactivateParams,
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ '/organization/certificates/deactivate',
+ Page,
+ { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+}
+
+export type CertificateListResponsesPage = ConversationCursorPage;
+
+// Note: no pagination actually occurs yet, this is for forwards-compatibility.
+export type CertificateActivateResponsesPage = Page;
+
+// Note: no pagination actually occurs yet, this is for forwards-compatibility.
+export type CertificateDeactivateResponsesPage = Page;
+
+/**
+ * Represents an individual `certificate` uploaded to the organization.
+ */
+export interface Certificate {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ certificate_details: Certificate.CertificateDetails;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate was uploaded.
+ */
+ created_at: number;
+
+ /**
+ * The name of the certificate.
+ */
+ name: string | null;
+
+ /**
+ * 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`.
+ */
+ object: 'certificate' | 'organization.certificate' | 'organization.project.certificate';
+
+ /**
+ * Whether the certificate is currently active at the specified scope. Not returned
+ * when getting details for a specific certificate.
+ */
+ active?: boolean;
+}
+
+export namespace Certificate {
+ export interface CertificateDetails {
+ /**
+ * The content of the certificate in PEM format.
+ */
+ content?: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate expires.
+ */
+ expires_at?: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate becomes valid.
+ */
+ valid_at?: number;
+ }
+}
+
+/**
+ * Represents an individual certificate configured at the organization level.
+ */
+export interface CertificateListResponse {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * Whether the certificate is currently active at the organization level.
+ */
+ active: boolean;
+
+ certificate_details: CertificateListResponse.CertificateDetails;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate was uploaded.
+ */
+ created_at: number;
+
+ /**
+ * The name of the certificate.
+ */
+ name: string | null;
+
+ /**
+ * The object type, which is always `organization.certificate`.
+ */
+ object: 'organization.certificate';
+}
+
+export namespace CertificateListResponse {
+ export interface CertificateDetails {
+ /**
+ * The Unix timestamp (in seconds) of when the certificate expires.
+ */
+ expires_at?: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate becomes valid.
+ */
+ valid_at?: number;
+ }
+}
+
+export interface CertificateDeleteResponse {
+ /**
+ * The ID of the certificate that was deleted.
+ */
+ id: string;
+
+ /**
+ * The object type, must be `certificate.deleted`.
+ */
+ object: 'certificate.deleted';
+}
+
+/**
+ * Represents an individual certificate configured at the organization level.
+ */
+export interface CertificateActivateResponse {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * Whether the certificate is currently active at the organization level.
+ */
+ active: boolean;
+
+ certificate_details: CertificateActivateResponse.CertificateDetails;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate was uploaded.
+ */
+ created_at: number;
+
+ /**
+ * The name of the certificate.
+ */
+ name: string | null;
+
+ /**
+ * The object type, which is always `organization.certificate`.
+ */
+ object: 'organization.certificate';
+}
+
+export namespace CertificateActivateResponse {
+ export interface CertificateDetails {
+ /**
+ * The Unix timestamp (in seconds) of when the certificate expires.
+ */
+ expires_at?: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate becomes valid.
+ */
+ valid_at?: number;
+ }
+}
+
+/**
+ * Represents an individual certificate configured at the organization level.
+ */
+export interface CertificateDeactivateResponse {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * Whether the certificate is currently active at the organization level.
+ */
+ active: boolean;
+
+ certificate_details: CertificateDeactivateResponse.CertificateDetails;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate was uploaded.
+ */
+ created_at: number;
+
+ /**
+ * The name of the certificate.
+ */
+ name: string | null;
+
+ /**
+ * The object type, which is always `organization.certificate`.
+ */
+ object: 'organization.certificate';
+}
+
+export namespace CertificateDeactivateResponse {
+ export interface CertificateDetails {
+ /**
+ * The Unix timestamp (in seconds) of when the certificate expires.
+ */
+ expires_at?: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate becomes valid.
+ */
+ valid_at?: number;
+ }
+}
+
+export interface CertificateCreateParams {
+ /**
+ * The certificate content in PEM format
+ */
+ certificate: string;
+
+ /**
+ * An optional name for the certificate
+ */
+ name?: string;
+}
+
+export interface CertificateRetrieveParams {
+ /**
+ * 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.
+ */
+ include?: Array<'content'>;
+}
+
+export interface CertificateUpdateParams {
+ /**
+ * The updated name for the certificate
+ */
+ name?: string;
+}
+
+export interface CertificateListParams extends ConversationCursorPageParams {
+ /**
+ * Sort order by the `created_at` timestamp of the objects. `asc` for ascending
+ * order and `desc` for descending order.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface CertificateActivateParams {
+ certificate_ids: Array;
+}
+
+export interface CertificateDeactivateParams {
+ certificate_ids: Array;
+}
+
+export declare namespace Certificates {
+ export {
+ type Certificate as Certificate,
+ type CertificateListResponse as CertificateListResponse,
+ type CertificateDeleteResponse as CertificateDeleteResponse,
+ type CertificateActivateResponse as CertificateActivateResponse,
+ type CertificateDeactivateResponse as CertificateDeactivateResponse,
+ type CertificateListResponsesPage as CertificateListResponsesPage,
+ type CertificateActivateResponsesPage as CertificateActivateResponsesPage,
+ type CertificateDeactivateResponsesPage as CertificateDeactivateResponsesPage,
+ type CertificateCreateParams as CertificateCreateParams,
+ type CertificateRetrieveParams as CertificateRetrieveParams,
+ type CertificateUpdateParams as CertificateUpdateParams,
+ type CertificateListParams as CertificateListParams,
+ type CertificateActivateParams as CertificateActivateParams,
+ type CertificateDeactivateParams as CertificateDeactivateParams,
+ };
+}
diff --git a/src/resources/admin/organization/groups.ts b/src/resources/admin/organization/groups.ts
new file mode 100644
index 0000000000..429bb1a07d
--- /dev/null
+++ b/src/resources/admin/organization/groups.ts
@@ -0,0 +1,3 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export * from './groups/index';
diff --git a/src/resources/admin/organization/groups/groups.ts b/src/resources/admin/organization/groups/groups.ts
new file mode 100644
index 0000000000..295b18f607
--- /dev/null
+++ b/src/resources/admin/organization/groups/groups.ts
@@ -0,0 +1,246 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import * as RolesAPI from './roles';
+import {
+ RoleCreateParams,
+ RoleCreateResponse,
+ RoleDeleteParams,
+ RoleDeleteResponse,
+ RoleListParams,
+ RoleListResponse,
+ RoleListResponsesPage,
+ Roles,
+} from './roles';
+import * as UsersAPI from './users';
+import {
+ OrganizationGroupUser,
+ OrganizationGroupUsersPage,
+ UserCreateParams,
+ UserCreateResponse,
+ UserDeleteParams,
+ UserDeleteResponse,
+ UserListParams,
+ Users,
+} from './users';
+import { APIPromise } from '../../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class Groups extends APIResource {
+ users: UsersAPI.Users = new UsersAPI.Users(this._client);
+ roles: RolesAPI.Roles = new RolesAPI.Roles(this._client);
+
+ /**
+ * Creates a new group in the organization.
+ *
+ * @example
+ * ```ts
+ * const group = await client.admin.organization.groups.create(
+ * { name: 'x' },
+ * );
+ * ```
+ */
+ create(body: GroupCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post('/organization/groups', {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Updates a group's information.
+ *
+ * @example
+ * ```ts
+ * const group = await client.admin.organization.groups.update(
+ * 'group_id',
+ * { name: 'x' },
+ * );
+ * ```
+ */
+ update(
+ groupID: string,
+ body: GroupUpdateParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ return this._client.post(path`/organization/groups/${groupID}`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists all groups in the organization.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const group of client.admin.organization.groups.list()) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ query: GroupListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList('/organization/groups', NextCursorPage, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Deletes a group from the organization.
+ *
+ * @example
+ * ```ts
+ * const group = await client.admin.organization.groups.delete(
+ * 'group_id',
+ * );
+ * ```
+ */
+ delete(groupID: string, options?: RequestOptions): APIPromise {
+ return this._client.delete(path`/organization/groups/${groupID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type GroupsPage = NextCursorPage;
+
+/**
+ * Details about an organization group.
+ */
+export interface Group {
+ /**
+ * Identifier for the group.
+ */
+ id: string;
+
+ /**
+ * Unix timestamp (in seconds) when the group was created.
+ */
+ created_at: number;
+
+ /**
+ * Whether the group is managed through SCIM and controlled by your identity
+ * provider.
+ */
+ is_scim_managed: boolean;
+
+ /**
+ * Display name of the group.
+ */
+ name: string;
+}
+
+/**
+ * Response returned after updating a group.
+ */
+export interface GroupUpdateResponse {
+ /**
+ * Identifier for the group.
+ */
+ id: string;
+
+ /**
+ * Unix timestamp (in seconds) when the group was created.
+ */
+ created_at: number;
+
+ /**
+ * Whether the group is managed through SCIM and controlled by your identity
+ * provider.
+ */
+ is_scim_managed: boolean;
+
+ /**
+ * Updated display name for the group.
+ */
+ name: string;
+}
+
+/**
+ * Confirmation payload returned after deleting a group.
+ */
+export interface GroupDeleteResponse {
+ /**
+ * Identifier of the deleted group.
+ */
+ id: string;
+
+ /**
+ * Whether the group was deleted.
+ */
+ deleted: boolean;
+
+ /**
+ * Always `group.deleted`.
+ */
+ object: 'group.deleted';
+}
+
+export interface GroupCreateParams {
+ /**
+ * Human readable name for the group.
+ */
+ name: string;
+}
+
+export interface GroupUpdateParams {
+ /**
+ * New display name for the group.
+ */
+ name: string;
+}
+
+export interface GroupListParams extends NextCursorPageParams {
+ /**
+ * Specifies the sort order of the returned groups.
+ */
+ order?: 'asc' | 'desc';
+}
+
+Groups.Users = Users;
+Groups.Roles = Roles;
+
+export declare namespace Groups {
+ export {
+ type Group as Group,
+ type GroupUpdateResponse as GroupUpdateResponse,
+ type GroupDeleteResponse as GroupDeleteResponse,
+ type GroupsPage as GroupsPage,
+ type GroupCreateParams as GroupCreateParams,
+ type GroupUpdateParams as GroupUpdateParams,
+ type GroupListParams as GroupListParams,
+ };
+
+ export {
+ Users as Users,
+ type OrganizationGroupUser as OrganizationGroupUser,
+ type UserCreateResponse as UserCreateResponse,
+ type UserDeleteResponse as UserDeleteResponse,
+ type OrganizationGroupUsersPage as OrganizationGroupUsersPage,
+ type UserCreateParams as UserCreateParams,
+ type UserListParams as UserListParams,
+ type UserDeleteParams as UserDeleteParams,
+ };
+
+ export {
+ Roles as Roles,
+ type RoleCreateResponse as RoleCreateResponse,
+ type RoleListResponse as RoleListResponse,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleListResponsesPage as RoleListResponsesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/groups/index.ts b/src/resources/admin/organization/groups/index.ts
new file mode 100644
index 0000000000..ef3bd96638
--- /dev/null
+++ b/src/resources/admin/organization/groups/index.ts
@@ -0,0 +1,32 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export {
+ Groups,
+ type Group,
+ type GroupUpdateResponse,
+ type GroupDeleteResponse,
+ type GroupCreateParams,
+ type GroupUpdateParams,
+ type GroupListParams,
+ type GroupsPage,
+} from './groups';
+export {
+ Roles,
+ type RoleCreateResponse,
+ type RoleListResponse,
+ type RoleDeleteResponse,
+ type RoleCreateParams,
+ type RoleListParams,
+ type RoleDeleteParams,
+ type RoleListResponsesPage,
+} from './roles';
+export {
+ Users,
+ type OrganizationGroupUser,
+ type UserCreateResponse,
+ type UserDeleteResponse,
+ type UserCreateParams,
+ type UserListParams,
+ type UserDeleteParams,
+ type OrganizationGroupUsersPage,
+} from './users';
diff --git a/src/resources/admin/organization/groups/roles.ts b/src/resources/admin/organization/groups/roles.ts
new file mode 100644
index 0000000000..28e498774f
--- /dev/null
+++ b/src/resources/admin/organization/groups/roles.ts
@@ -0,0 +1,239 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import * as RolesAPI from '../roles';
+import { APIPromise } from '../../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class Roles extends APIResource {
+ /**
+ * Assigns an organization role to a group within the organization.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.groups.roles.create(
+ * 'group_id',
+ * { role_id: 'role_id' },
+ * );
+ * ```
+ */
+ create(groupID: string, body: RoleCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/groups/${groupID}/roles`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists the organization roles assigned to a group within the organization.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const roleListResponse of client.admin.organization.groups.roles.list(
+ * 'group_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ groupID: string,
+ query: RoleListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/groups/${groupID}/roles`,
+ NextCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Unassigns an organization role from a group within the organization.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.groups.roles.delete(
+ * 'role_id',
+ * { group_id: 'group_id' },
+ * );
+ * ```
+ */
+ delete(roleID: string, params: RoleDeleteParams, options?: RequestOptions): APIPromise {
+ const { group_id } = params;
+ return this._client.delete(path`/organization/groups/${group_id}/roles/${roleID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type RoleListResponsesPage = NextCursorPage;
+
+/**
+ * Role assignment linking a group to a role.
+ */
+export interface RoleCreateResponse {
+ /**
+ * Summary information about a group returned in role assignment responses.
+ */
+ group: RoleCreateResponse.Group;
+
+ /**
+ * Always `group.role`.
+ */
+ object: 'group.role';
+
+ /**
+ * Details about a role that can be assigned through the public Roles API.
+ */
+ role: RolesAPI.Role;
+}
+
+export namespace RoleCreateResponse {
+ /**
+ * Summary information about a group returned in role assignment responses.
+ */
+ export interface Group {
+ /**
+ * Identifier for the group.
+ */
+ id: string;
+
+ /**
+ * Unix timestamp (in seconds) when the group was created.
+ */
+ created_at: number;
+
+ /**
+ * Display name of the group.
+ */
+ name: string;
+
+ /**
+ * Always `group`.
+ */
+ object: 'group';
+
+ /**
+ * Whether the group is managed through SCIM.
+ */
+ scim_managed: boolean;
+ }
+}
+
+/**
+ * Detailed information about a role assignment entry returned when listing
+ * assignments.
+ */
+export interface RoleListResponse {
+ /**
+ * Identifier for the role.
+ */
+ id: string;
+
+ /**
+ * When the role was created.
+ */
+ created_at: number | null;
+
+ /**
+ * Identifier of the actor who created the role.
+ */
+ created_by: string | null;
+
+ /**
+ * User details for the actor that created the role, when available.
+ */
+ created_by_user_obj: { [key: string]: unknown } | null;
+
+ /**
+ * Description of the role.
+ */
+ description: string | null;
+
+ /**
+ * Arbitrary metadata stored on the role.
+ */
+ metadata: { [key: string]: unknown } | null;
+
+ /**
+ * Name of the role.
+ */
+ name: string;
+
+ /**
+ * Permissions associated with the role.
+ */
+ permissions: Array;
+
+ /**
+ * Whether the role is predefined by OpenAI.
+ */
+ predefined_role: boolean;
+
+ /**
+ * Resource type the role applies to.
+ */
+ resource_type: string;
+
+ /**
+ * When the role was last updated.
+ */
+ updated_at: number | null;
+}
+
+/**
+ * Confirmation payload returned after unassigning a role.
+ */
+export interface RoleDeleteResponse {
+ /**
+ * Whether the assignment was removed.
+ */
+ deleted: boolean;
+
+ /**
+ * Identifier for the deleted assignment, such as `group.role.deleted` or
+ * `user.role.deleted`.
+ */
+ object: string;
+}
+
+export interface RoleCreateParams {
+ /**
+ * Identifier of the role to assign.
+ */
+ role_id: string;
+}
+
+export interface RoleListParams extends NextCursorPageParams {
+ /**
+ * Sort order for the returned organization roles.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface RoleDeleteParams {
+ /**
+ * The ID of the group to modify.
+ */
+ group_id: string;
+}
+
+export declare namespace Roles {
+ export {
+ type RoleCreateResponse as RoleCreateResponse,
+ type RoleListResponse as RoleListResponse,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleListResponsesPage as RoleListResponsesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/groups/users.ts b/src/resources/admin/organization/groups/users.ts
new file mode 100644
index 0000000000..6f10d296c7
--- /dev/null
+++ b/src/resources/admin/organization/groups/users.ts
@@ -0,0 +1,164 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import { APIPromise } from '../../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class Users extends APIResource {
+ /**
+ * Adds a user to a group.
+ *
+ * @example
+ * ```ts
+ * const user =
+ * await client.admin.organization.groups.users.create(
+ * 'group_id',
+ * { user_id: 'user_id' },
+ * );
+ * ```
+ */
+ create(groupID: string, body: UserCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/groups/${groupID}/users`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists the users assigned to a group.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const organizationGroupUser of client.admin.organization.groups.users.list(
+ * 'group_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ groupID: string,
+ query: UserListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/groups/${groupID}/users`,
+ NextCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Removes a user from a group.
+ *
+ * @example
+ * ```ts
+ * const user =
+ * await client.admin.organization.groups.users.delete(
+ * 'user_id',
+ * { group_id: 'group_id' },
+ * );
+ * ```
+ */
+ delete(userID: string, params: UserDeleteParams, options?: RequestOptions): APIPromise {
+ const { group_id } = params;
+ return this._client.delete(path`/organization/groups/${group_id}/users/${userID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type OrganizationGroupUsersPage = NextCursorPage;
+
+/**
+ * Represents an individual user returned when inspecting group membership.
+ */
+export interface OrganizationGroupUser {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The email address of the user.
+ */
+ email: string | null;
+
+ /**
+ * The name of the user.
+ */
+ name: string;
+}
+
+/**
+ * Confirmation payload returned after adding a user to a group.
+ */
+export interface UserCreateResponse {
+ /**
+ * Identifier of the group the user was added to.
+ */
+ group_id: string;
+
+ /**
+ * Always `group.user`.
+ */
+ object: 'group.user';
+
+ /**
+ * Identifier of the user that was added.
+ */
+ user_id: string;
+}
+
+/**
+ * Confirmation payload returned after removing a user from a group.
+ */
+export interface UserDeleteResponse {
+ /**
+ * Whether the group membership was removed.
+ */
+ deleted: boolean;
+
+ /**
+ * Always `group.user.deleted`.
+ */
+ object: 'group.user.deleted';
+}
+
+export interface UserCreateParams {
+ /**
+ * Identifier of the user to add to the group.
+ */
+ user_id: string;
+}
+
+export interface UserListParams extends NextCursorPageParams {
+ /**
+ * Specifies the sort order of users in the list.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface UserDeleteParams {
+ /**
+ * The ID of the group to update.
+ */
+ group_id: string;
+}
+
+export declare namespace Users {
+ export {
+ type OrganizationGroupUser as OrganizationGroupUser,
+ type UserCreateResponse as UserCreateResponse,
+ type UserDeleteResponse as UserDeleteResponse,
+ type OrganizationGroupUsersPage as OrganizationGroupUsersPage,
+ type UserCreateParams as UserCreateParams,
+ type UserListParams as UserListParams,
+ type UserDeleteParams as UserDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/index.ts b/src/resources/admin/organization/index.ts
new file mode 100644
index 0000000000..56ee761c93
--- /dev/null
+++ b/src/resources/admin/organization/index.ts
@@ -0,0 +1,99 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export {
+ AdminAPIKeys,
+ type AdminAPIKey,
+ type AdminAPIKeyCreateResponse,
+ type AdminAPIKeyDeleteResponse,
+ type AdminAPIKeyCreateParams,
+ type AdminAPIKeyListParams,
+ type AdminAPIKeysPage,
+} from './admin-api-keys';
+export {
+ AuditLogs,
+ type AuditLogListResponse,
+ type AuditLogListParams,
+ type AuditLogListResponsesPage,
+} from './audit-logs';
+export {
+ Certificates,
+ type Certificate,
+ type CertificateListResponse,
+ type CertificateDeleteResponse,
+ type CertificateActivateResponse,
+ type CertificateDeactivateResponse,
+ type CertificateCreateParams,
+ type CertificateRetrieveParams,
+ type CertificateUpdateParams,
+ type CertificateListParams,
+ type CertificateActivateParams,
+ type CertificateDeactivateParams,
+ type CertificateListResponsesPage,
+ type CertificateActivateResponsesPage,
+ type CertificateDeactivateResponsesPage,
+} from './certificates';
+export {
+ Groups,
+ type Group,
+ type GroupUpdateResponse,
+ type GroupDeleteResponse,
+ type GroupCreateParams,
+ type GroupUpdateParams,
+ type GroupListParams,
+ type GroupsPage,
+} from './groups/index';
+export {
+ Invites,
+ type Invite,
+ type InviteDeleteResponse,
+ type InviteCreateParams,
+ type InviteListParams,
+ type InvitesPage,
+} from './invites';
+export { Organization } from './organization';
+export {
+ Projects,
+ type Project,
+ type ProjectCreateParams,
+ type ProjectUpdateParams,
+ type ProjectListParams,
+ type ProjectsPage,
+} from './projects/index';
+export {
+ Roles,
+ type Role,
+ type RoleDeleteResponse,
+ type RoleCreateParams,
+ type RoleUpdateParams,
+ type RoleListParams,
+ type RolesPage,
+} from './roles';
+export {
+ Usage,
+ type UsageAudioSpeechesResponse,
+ type UsageAudioTranscriptionsResponse,
+ type UsageCodeInterpreterSessionsResponse,
+ type UsageCompletionsResponse,
+ type UsageCostsResponse,
+ type UsageEmbeddingsResponse,
+ type UsageImagesResponse,
+ type UsageModerationsResponse,
+ type UsageVectorStoresResponse,
+ type UsageAudioSpeechesParams,
+ type UsageAudioTranscriptionsParams,
+ type UsageCodeInterpreterSessionsParams,
+ type UsageCompletionsParams,
+ type UsageCostsParams,
+ type UsageEmbeddingsParams,
+ type UsageImagesParams,
+ type UsageModerationsParams,
+ type UsageVectorStoresParams,
+} from './usage';
+export {
+ Users,
+ type OrganizationUser,
+ type UserDeleteResponse,
+ type UserUpdateParams,
+ type UserListParams,
+ type OrganizationUsersPage,
+} from './users/index';
diff --git a/src/resources/admin/organization/invites.ts b/src/resources/admin/organization/invites.ts
new file mode 100644
index 0000000000..b272752828
--- /dev/null
+++ b/src/resources/admin/organization/invites.ts
@@ -0,0 +1,214 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../core/resource';
+import { APIPromise } from '../../../core/api-promise';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ PagePromise,
+} from '../../../core/pagination';
+import { RequestOptions } from '../../../internal/request-options';
+import { path } from '../../../internal/utils/path';
+
+export class Invites extends APIResource {
+ /**
+ * Create an invite for a user to the organization. The invite must be accepted by
+ * the user before they have access to the organization.
+ *
+ * @example
+ * ```ts
+ * const invite =
+ * await client.admin.organization.invites.create({
+ * email: 'email',
+ * role: 'reader',
+ * });
+ * ```
+ */
+ create(body: InviteCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post('/organization/invites', {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Retrieves an invite.
+ *
+ * @example
+ * ```ts
+ * const invite =
+ * await client.admin.organization.invites.retrieve(
+ * 'invite_id',
+ * );
+ * ```
+ */
+ retrieve(inviteID: string, options?: RequestOptions): APIPromise {
+ return this._client.get(path`/organization/invites/${inviteID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Returns a list of invites in the organization.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const invite of client.admin.organization.invites.list()) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ query: InviteListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList('/organization/invites', ConversationCursorPage, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Delete an invite. If the invite has already been accepted, it cannot be deleted.
+ *
+ * @example
+ * ```ts
+ * const invite =
+ * await client.admin.organization.invites.delete(
+ * 'invite_id',
+ * );
+ * ```
+ */
+ delete(inviteID: string, options?: RequestOptions): APIPromise {
+ return this._client.delete(path`/organization/invites/${inviteID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type InvitesPage = ConversationCursorPage;
+
+/**
+ * Represents an individual `invite` to the organization.
+ */
+export interface Invite {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the invite was sent.
+ */
+ created_at: number;
+
+ /**
+ * The email address of the individual to whom the invite was sent
+ */
+ email: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the invite expires.
+ */
+ expires_at: number | null;
+
+ /**
+ * The object type, which is always `organization.invite`
+ */
+ object: 'organization.invite';
+
+ /**
+ * `owner` or `reader`
+ */
+ role: 'owner' | 'reader';
+
+ /**
+ * `accepted`,`expired`, or `pending`
+ */
+ status: 'accepted' | 'expired' | 'pending';
+
+ /**
+ * The Unix timestamp (in seconds) of when the invite was accepted.
+ */
+ accepted_at?: number | null;
+
+ /**
+ * The projects that were granted membership upon acceptance of the invite.
+ */
+ projects?: Array;
+}
+
+export namespace Invite {
+ export interface Project {
+ /**
+ * Project's public ID
+ */
+ id?: string;
+
+ /**
+ * Project membership role
+ */
+ role?: 'member' | 'owner';
+ }
+}
+
+export interface InviteDeleteResponse {
+ id: string;
+
+ deleted: boolean;
+
+ /**
+ * The object type, which is always `organization.invite.deleted`
+ */
+ object: 'organization.invite.deleted';
+}
+
+export interface InviteCreateParams {
+ /**
+ * Send an email to this address
+ */
+ email: string;
+
+ /**
+ * `owner` or `reader`
+ */
+ role: 'reader' | 'owner';
+
+ /**
+ * 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.
+ */
+ projects?: Array;
+}
+
+export namespace InviteCreateParams {
+ export interface Project {
+ /**
+ * Project's public ID
+ */
+ id: string;
+
+ /**
+ * Project membership role
+ */
+ role: 'member' | 'owner';
+ }
+}
+
+export interface InviteListParams extends ConversationCursorPageParams {}
+
+export declare namespace Invites {
+ export {
+ type Invite as Invite,
+ type InviteDeleteResponse as InviteDeleteResponse,
+ type InvitesPage as InvitesPage,
+ type InviteCreateParams as InviteCreateParams,
+ type InviteListParams as InviteListParams,
+ };
+}
diff --git a/src/resources/admin/organization/organization.ts b/src/resources/admin/organization/organization.ts
new file mode 100644
index 0000000000..4ffa4223cc
--- /dev/null
+++ b/src/resources/admin/organization/organization.ts
@@ -0,0 +1,232 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../core/resource';
+import * as AdminAPIKeysAPI from './admin-api-keys';
+import {
+ AdminAPIKey,
+ AdminAPIKeyCreateParams,
+ AdminAPIKeyCreateResponse,
+ AdminAPIKeyDeleteResponse,
+ AdminAPIKeyListParams,
+ AdminAPIKeys,
+ AdminAPIKeysPage,
+} from './admin-api-keys';
+import * as AuditLogsAPI from './audit-logs';
+import { AuditLogListParams, AuditLogListResponse, AuditLogListResponsesPage, AuditLogs } from './audit-logs';
+import * as CertificatesAPI from './certificates';
+import {
+ Certificate,
+ CertificateActivateParams,
+ CertificateActivateResponse,
+ CertificateActivateResponsesPage,
+ CertificateCreateParams,
+ CertificateDeactivateParams,
+ CertificateDeactivateResponse,
+ CertificateDeactivateResponsesPage,
+ CertificateDeleteResponse,
+ CertificateListParams,
+ CertificateListResponse,
+ CertificateListResponsesPage,
+ CertificateRetrieveParams,
+ CertificateUpdateParams,
+ Certificates,
+} from './certificates';
+import * as InvitesAPI from './invites';
+import {
+ Invite,
+ InviteCreateParams,
+ InviteDeleteResponse,
+ InviteListParams,
+ Invites,
+ InvitesPage,
+} from './invites';
+import * as RolesAPI from './roles';
+import {
+ Role,
+ RoleCreateParams,
+ RoleDeleteResponse,
+ RoleListParams,
+ RoleUpdateParams,
+ Roles,
+ RolesPage,
+} from './roles';
+import * as UsageAPI from './usage';
+import {
+ Usage,
+ UsageAudioSpeechesParams,
+ UsageAudioSpeechesResponse,
+ UsageAudioTranscriptionsParams,
+ UsageAudioTranscriptionsResponse,
+ UsageCodeInterpreterSessionsParams,
+ UsageCodeInterpreterSessionsResponse,
+ UsageCompletionsParams,
+ UsageCompletionsResponse,
+ UsageCostsParams,
+ UsageCostsResponse,
+ UsageEmbeddingsParams,
+ UsageEmbeddingsResponse,
+ UsageImagesParams,
+ UsageImagesResponse,
+ UsageModerationsParams,
+ UsageModerationsResponse,
+ UsageVectorStoresParams,
+ UsageVectorStoresResponse,
+} from './usage';
+import * as GroupsAPI from './groups/groups';
+import {
+ Group,
+ GroupCreateParams,
+ GroupDeleteResponse,
+ GroupListParams,
+ GroupUpdateParams,
+ GroupUpdateResponse,
+ Groups,
+ GroupsPage,
+} from './groups/groups';
+import * as ProjectsAPI from './projects/projects';
+import {
+ Project,
+ ProjectCreateParams,
+ ProjectListParams,
+ ProjectUpdateParams,
+ Projects,
+ ProjectsPage,
+} from './projects/projects';
+import * as UsersAPI from './users/users';
+import {
+ OrganizationUser,
+ OrganizationUsersPage,
+ UserDeleteResponse,
+ UserListParams,
+ UserUpdateParams,
+ Users,
+} from './users/users';
+
+export class Organization extends APIResource {
+ auditLogs: AuditLogsAPI.AuditLogs = new AuditLogsAPI.AuditLogs(this._client);
+ adminAPIKeys: AdminAPIKeysAPI.AdminAPIKeys = new AdminAPIKeysAPI.AdminAPIKeys(this._client);
+ usage: UsageAPI.Usage = new UsageAPI.Usage(this._client);
+ invites: InvitesAPI.Invites = new InvitesAPI.Invites(this._client);
+ users: UsersAPI.Users = new UsersAPI.Users(this._client);
+ groups: GroupsAPI.Groups = new GroupsAPI.Groups(this._client);
+ roles: RolesAPI.Roles = new RolesAPI.Roles(this._client);
+ certificates: CertificatesAPI.Certificates = new CertificatesAPI.Certificates(this._client);
+ projects: ProjectsAPI.Projects = new ProjectsAPI.Projects(this._client);
+}
+
+Organization.AuditLogs = AuditLogs;
+Organization.AdminAPIKeys = AdminAPIKeys;
+Organization.Usage = Usage;
+Organization.Invites = Invites;
+Organization.Users = Users;
+Organization.Groups = Groups;
+Organization.Roles = Roles;
+Organization.Certificates = Certificates;
+Organization.Projects = Projects;
+
+export declare namespace Organization {
+ export {
+ AuditLogs as AuditLogs,
+ type AuditLogListResponse as AuditLogListResponse,
+ type AuditLogListResponsesPage as AuditLogListResponsesPage,
+ type AuditLogListParams as AuditLogListParams,
+ };
+
+ export {
+ AdminAPIKeys as AdminAPIKeys,
+ type AdminAPIKey as AdminAPIKey,
+ type AdminAPIKeyCreateResponse as AdminAPIKeyCreateResponse,
+ type AdminAPIKeyDeleteResponse as AdminAPIKeyDeleteResponse,
+ type AdminAPIKeysPage as AdminAPIKeysPage,
+ type AdminAPIKeyCreateParams as AdminAPIKeyCreateParams,
+ type AdminAPIKeyListParams as AdminAPIKeyListParams,
+ };
+
+ export {
+ Usage as Usage,
+ type UsageAudioSpeechesResponse as UsageAudioSpeechesResponse,
+ type UsageAudioTranscriptionsResponse as UsageAudioTranscriptionsResponse,
+ type UsageCodeInterpreterSessionsResponse as UsageCodeInterpreterSessionsResponse,
+ type UsageCompletionsResponse as UsageCompletionsResponse,
+ type UsageCostsResponse as UsageCostsResponse,
+ type UsageEmbeddingsResponse as UsageEmbeddingsResponse,
+ type UsageImagesResponse as UsageImagesResponse,
+ type UsageModerationsResponse as UsageModerationsResponse,
+ type UsageVectorStoresResponse as UsageVectorStoresResponse,
+ type UsageAudioSpeechesParams as UsageAudioSpeechesParams,
+ type UsageAudioTranscriptionsParams as UsageAudioTranscriptionsParams,
+ type UsageCodeInterpreterSessionsParams as UsageCodeInterpreterSessionsParams,
+ type UsageCompletionsParams as UsageCompletionsParams,
+ type UsageCostsParams as UsageCostsParams,
+ type UsageEmbeddingsParams as UsageEmbeddingsParams,
+ type UsageImagesParams as UsageImagesParams,
+ type UsageModerationsParams as UsageModerationsParams,
+ type UsageVectorStoresParams as UsageVectorStoresParams,
+ };
+
+ export {
+ Invites as Invites,
+ type Invite as Invite,
+ type InviteDeleteResponse as InviteDeleteResponse,
+ type InvitesPage as InvitesPage,
+ type InviteCreateParams as InviteCreateParams,
+ type InviteListParams as InviteListParams,
+ };
+
+ export {
+ Users as Users,
+ type OrganizationUser as OrganizationUser,
+ type UserDeleteResponse as UserDeleteResponse,
+ type OrganizationUsersPage as OrganizationUsersPage,
+ type UserUpdateParams as UserUpdateParams,
+ type UserListParams as UserListParams,
+ };
+
+ export {
+ Groups as Groups,
+ type Group as Group,
+ type GroupUpdateResponse as GroupUpdateResponse,
+ type GroupDeleteResponse as GroupDeleteResponse,
+ type GroupsPage as GroupsPage,
+ type GroupCreateParams as GroupCreateParams,
+ type GroupUpdateParams as GroupUpdateParams,
+ type GroupListParams as GroupListParams,
+ };
+
+ export {
+ Roles as Roles,
+ type Role as Role,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RolesPage as RolesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleUpdateParams as RoleUpdateParams,
+ type RoleListParams as RoleListParams,
+ };
+
+ export {
+ Certificates as Certificates,
+ type Certificate as Certificate,
+ type CertificateListResponse as CertificateListResponse,
+ type CertificateDeleteResponse as CertificateDeleteResponse,
+ type CertificateActivateResponse as CertificateActivateResponse,
+ type CertificateDeactivateResponse as CertificateDeactivateResponse,
+ type CertificateListResponsesPage as CertificateListResponsesPage,
+ type CertificateActivateResponsesPage as CertificateActivateResponsesPage,
+ type CertificateDeactivateResponsesPage as CertificateDeactivateResponsesPage,
+ type CertificateCreateParams as CertificateCreateParams,
+ type CertificateRetrieveParams as CertificateRetrieveParams,
+ type CertificateUpdateParams as CertificateUpdateParams,
+ type CertificateListParams as CertificateListParams,
+ type CertificateActivateParams as CertificateActivateParams,
+ type CertificateDeactivateParams as CertificateDeactivateParams,
+ };
+
+ export {
+ Projects as Projects,
+ type Project as Project,
+ type ProjectsPage as ProjectsPage,
+ type ProjectCreateParams as ProjectCreateParams,
+ type ProjectUpdateParams as ProjectUpdateParams,
+ type ProjectListParams as ProjectListParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects.ts b/src/resources/admin/organization/projects.ts
new file mode 100644
index 0000000000..f9985fc35d
--- /dev/null
+++ b/src/resources/admin/organization/projects.ts
@@ -0,0 +1,3 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export * from './projects/index';
diff --git a/src/resources/admin/organization/projects/api-keys.ts b/src/resources/admin/organization/projects/api-keys.ts
new file mode 100644
index 0000000000..7d40a08921
--- /dev/null
+++ b/src/resources/admin/organization/projects/api-keys.ts
@@ -0,0 +1,239 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import { APIPromise } from '../../../../core/api-promise';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ PagePromise,
+} from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class APIKeys extends APIResource {
+ /**
+ * Retrieves an API key in the project.
+ *
+ * @example
+ * ```ts
+ * const projectAPIKey =
+ * await client.admin.organization.projects.apiKeys.retrieve(
+ * 'api_key_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ retrieve(
+ apiKeyID: string,
+ params: APIKeyRetrieveParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ const { project_id } = params;
+ return this._client.get(path`/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Returns a list of API keys in the project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const projectAPIKey of client.admin.organization.projects.apiKeys.list(
+ * 'project_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ projectID: string,
+ query: APIKeyListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/projects/${projectID}/api_keys`,
+ ConversationCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Deletes an API key from the project.
+ *
+ * Returns confirmation of the key deletion, or an error if the key belonged to a
+ * service account.
+ *
+ * @example
+ * ```ts
+ * const apiKey =
+ * await client.admin.organization.projects.apiKeys.delete(
+ * 'api_key_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ delete(
+ apiKeyID: string,
+ params: APIKeyDeleteParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ const { project_id } = params;
+ return this._client.delete(path`/organization/projects/${project_id}/api_keys/${apiKeyID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type ProjectAPIKeysPage = ConversationCursorPage;
+
+/**
+ * Represents an individual API key in a project.
+ */
+export interface ProjectAPIKey {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the API key was created
+ */
+ created_at: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the API key was last used.
+ */
+ last_used_at: number | null;
+
+ /**
+ * The name of the API key
+ */
+ name: string;
+
+ /**
+ * The object type, which is always `organization.project.api_key`
+ */
+ object: 'organization.project.api_key';
+
+ owner: ProjectAPIKey.Owner;
+
+ /**
+ * The redacted value of the API key
+ */
+ redacted_value: string;
+}
+
+export namespace ProjectAPIKey {
+ export interface Owner {
+ /**
+ * The service account that owns a project API key.
+ */
+ service_account?: Owner.ServiceAccount;
+
+ /**
+ * `user` or `service_account`
+ */
+ type?: 'user' | 'service_account';
+
+ /**
+ * The user that owns a project API key.
+ */
+ user?: Owner.User;
+ }
+
+ export namespace Owner {
+ /**
+ * The service account that owns a project API key.
+ */
+ export interface ServiceAccount {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the service account was created.
+ */
+ created_at: number;
+
+ /**
+ * The name of the service account.
+ */
+ name: string;
+
+ /**
+ * The service account's project role.
+ */
+ role: string;
+ }
+
+ /**
+ * The user that owns a project API key.
+ */
+ export interface User {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the user was created.
+ */
+ created_at: number;
+
+ /**
+ * The email address of the user.
+ */
+ email: string;
+
+ /**
+ * The name of the user.
+ */
+ name: string;
+
+ /**
+ * The user's project role.
+ */
+ role: string;
+ }
+ }
+}
+
+export interface APIKeyDeleteResponse {
+ id: string;
+
+ deleted: boolean;
+
+ object: 'organization.project.api_key.deleted';
+}
+
+export interface APIKeyRetrieveParams {
+ /**
+ * The ID of the project.
+ */
+ project_id: string;
+}
+
+export interface APIKeyListParams extends ConversationCursorPageParams {}
+
+export interface APIKeyDeleteParams {
+ /**
+ * The ID of the project.
+ */
+ project_id: string;
+}
+
+export declare namespace APIKeys {
+ export {
+ type ProjectAPIKey as ProjectAPIKey,
+ type APIKeyDeleteResponse as APIKeyDeleteResponse,
+ type ProjectAPIKeysPage as ProjectAPIKeysPage,
+ type APIKeyRetrieveParams as APIKeyRetrieveParams,
+ type APIKeyListParams as APIKeyListParams,
+ type APIKeyDeleteParams as APIKeyDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects/certificates.ts b/src/resources/admin/organization/projects/certificates.ts
new file mode 100644
index 0000000000..53677a268d
--- /dev/null
+++ b/src/resources/admin/organization/projects/certificates.ts
@@ -0,0 +1,269 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ Page,
+ PagePromise,
+} from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class Certificates extends APIResource {
+ /**
+ * List certificates for this project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const certificateListResponse of client.admin.organization.projects.certificates.list(
+ * 'project_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ projectID: string,
+ query: CertificateListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/projects/${projectID}/certificates`,
+ ConversationCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Activate certificates at the project level.
+ *
+ * You can atomically and idempotently activate up to 10 certificates at a time.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const certificateActivateResponse of client.admin.organization.projects.certificates.activate(
+ * 'project_id',
+ * { certificate_ids: ['cert_abc'] },
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ activate(
+ projectID: string,
+ body: CertificateActivateParams,
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/projects/${projectID}/certificates/activate`,
+ Page,
+ { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Deactivate certificates at the project level. You can atomically and
+ * idempotently deactivate up to 10 certificates at a time.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const certificateDeactivateResponse of client.admin.organization.projects.certificates.deactivate(
+ * 'project_id',
+ * { certificate_ids: ['cert_abc'] },
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ deactivate(
+ projectID: string,
+ body: CertificateDeactivateParams,
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/projects/${projectID}/certificates/deactivate`,
+ Page,
+ { body, method: 'post', ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+}
+
+export type CertificateListResponsesPage = ConversationCursorPage;
+
+// Note: no pagination actually occurs yet, this is for forwards-compatibility.
+export type CertificateActivateResponsesPage = Page;
+
+// Note: no pagination actually occurs yet, this is for forwards-compatibility.
+export type CertificateDeactivateResponsesPage = Page;
+
+/**
+ * Represents an individual certificate configured at the project level.
+ */
+export interface CertificateListResponse {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * Whether the certificate is currently active at the project level.
+ */
+ active: boolean;
+
+ certificate_details: CertificateListResponse.CertificateDetails;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate was uploaded.
+ */
+ created_at: number;
+
+ /**
+ * The name of the certificate.
+ */
+ name: string | null;
+
+ /**
+ * The object type, which is always `organization.project.certificate`.
+ */
+ object: 'organization.project.certificate';
+}
+
+export namespace CertificateListResponse {
+ export interface CertificateDetails {
+ /**
+ * The Unix timestamp (in seconds) of when the certificate expires.
+ */
+ expires_at?: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate becomes valid.
+ */
+ valid_at?: number;
+ }
+}
+
+/**
+ * Represents an individual certificate configured at the project level.
+ */
+export interface CertificateActivateResponse {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * Whether the certificate is currently active at the project level.
+ */
+ active: boolean;
+
+ certificate_details: CertificateActivateResponse.CertificateDetails;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate was uploaded.
+ */
+ created_at: number;
+
+ /**
+ * The name of the certificate.
+ */
+ name: string | null;
+
+ /**
+ * The object type, which is always `organization.project.certificate`.
+ */
+ object: 'organization.project.certificate';
+}
+
+export namespace CertificateActivateResponse {
+ export interface CertificateDetails {
+ /**
+ * The Unix timestamp (in seconds) of when the certificate expires.
+ */
+ expires_at?: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate becomes valid.
+ */
+ valid_at?: number;
+ }
+}
+
+/**
+ * Represents an individual certificate configured at the project level.
+ */
+export interface CertificateDeactivateResponse {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * Whether the certificate is currently active at the project level.
+ */
+ active: boolean;
+
+ certificate_details: CertificateDeactivateResponse.CertificateDetails;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate was uploaded.
+ */
+ created_at: number;
+
+ /**
+ * The name of the certificate.
+ */
+ name: string | null;
+
+ /**
+ * The object type, which is always `organization.project.certificate`.
+ */
+ object: 'organization.project.certificate';
+}
+
+export namespace CertificateDeactivateResponse {
+ export interface CertificateDetails {
+ /**
+ * The Unix timestamp (in seconds) of when the certificate expires.
+ */
+ expires_at?: number;
+
+ /**
+ * The Unix timestamp (in seconds) of when the certificate becomes valid.
+ */
+ valid_at?: number;
+ }
+}
+
+export interface CertificateListParams extends ConversationCursorPageParams {
+ /**
+ * Sort order by the `created_at` timestamp of the objects. `asc` for ascending
+ * order and `desc` for descending order.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface CertificateActivateParams {
+ certificate_ids: Array;
+}
+
+export interface CertificateDeactivateParams {
+ certificate_ids: Array;
+}
+
+export declare namespace Certificates {
+ export {
+ type CertificateListResponse as CertificateListResponse,
+ type CertificateActivateResponse as CertificateActivateResponse,
+ type CertificateDeactivateResponse as CertificateDeactivateResponse,
+ type CertificateListResponsesPage as CertificateListResponsesPage,
+ type CertificateActivateResponsesPage as CertificateActivateResponsesPage,
+ type CertificateDeactivateResponsesPage as CertificateDeactivateResponsesPage,
+ type CertificateListParams as CertificateListParams,
+ type CertificateActivateParams as CertificateActivateParams,
+ type CertificateDeactivateParams as CertificateDeactivateParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects/groups.ts b/src/resources/admin/organization/projects/groups.ts
new file mode 100644
index 0000000000..429bb1a07d
--- /dev/null
+++ b/src/resources/admin/organization/projects/groups.ts
@@ -0,0 +1,3 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export * from './groups/index';
diff --git a/src/resources/admin/organization/projects/groups/groups.ts b/src/resources/admin/organization/projects/groups/groups.ts
new file mode 100644
index 0000000000..324e33acab
--- /dev/null
+++ b/src/resources/admin/organization/projects/groups/groups.ts
@@ -0,0 +1,188 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../../core/resource';
+import * as RolesAPI from './roles';
+import {
+ RoleCreateParams,
+ RoleCreateResponse,
+ RoleDeleteParams,
+ RoleDeleteResponse,
+ RoleListParams,
+ RoleListResponse,
+ RoleListResponsesPage,
+ Roles,
+} from './roles';
+import { APIPromise } from '../../../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../../../core/pagination';
+import { RequestOptions } from '../../../../../internal/request-options';
+import { path } from '../../../../../internal/utils/path';
+
+export class Groups extends APIResource {
+ roles: RolesAPI.Roles = new RolesAPI.Roles(this._client);
+
+ /**
+ * Grants a group access to a project.
+ *
+ * @example
+ * ```ts
+ * const projectGroup =
+ * await client.admin.organization.projects.groups.create(
+ * 'project_id',
+ * { group_id: 'group_id', role: 'role' },
+ * );
+ * ```
+ */
+ create(projectID: string, body: GroupCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/projects/${projectID}/groups`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists the groups that have access to a project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const projectGroup of client.admin.organization.projects.groups.list(
+ * 'project_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ projectID: string,
+ query: GroupListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/projects/${projectID}/groups`,
+ NextCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Revokes a group's access to a project.
+ *
+ * @example
+ * ```ts
+ * const group =
+ * await client.admin.organization.projects.groups.delete(
+ * 'group_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ delete(
+ groupID: string,
+ params: GroupDeleteParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ const { project_id } = params;
+ return this._client.delete(path`/organization/projects/${project_id}/groups/${groupID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type ProjectGroupsPage = NextCursorPage;
+
+/**
+ * Details about a group's membership in a project.
+ */
+export interface ProjectGroup {
+ /**
+ * Unix timestamp (in seconds) when the group was granted project access.
+ */
+ created_at: number;
+
+ /**
+ * Identifier of the group that has access to the project.
+ */
+ group_id: string;
+
+ /**
+ * Display name of the group.
+ */
+ group_name: string;
+
+ /**
+ * Always `project.group`.
+ */
+ object: 'project.group';
+
+ /**
+ * Identifier of the project.
+ */
+ project_id: string;
+}
+
+/**
+ * Confirmation payload returned after removing a group from a project.
+ */
+export interface GroupDeleteResponse {
+ /**
+ * Whether the group membership in the project was removed.
+ */
+ deleted: boolean;
+
+ /**
+ * Always `project.group.deleted`.
+ */
+ object: 'project.group.deleted';
+}
+
+export interface GroupCreateParams {
+ /**
+ * Identifier of the group to add to the project.
+ */
+ group_id: string;
+
+ /**
+ * Identifier of the project role to grant to the group.
+ */
+ role: string;
+}
+
+export interface GroupListParams extends NextCursorPageParams {
+ /**
+ * Sort order for the returned groups.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface GroupDeleteParams {
+ /**
+ * The ID of the project to update.
+ */
+ project_id: string;
+}
+
+Groups.Roles = Roles;
+
+export declare namespace Groups {
+ export {
+ type ProjectGroup as ProjectGroup,
+ type GroupDeleteResponse as GroupDeleteResponse,
+ type ProjectGroupsPage as ProjectGroupsPage,
+ type GroupCreateParams as GroupCreateParams,
+ type GroupListParams as GroupListParams,
+ type GroupDeleteParams as GroupDeleteParams,
+ };
+
+ export {
+ Roles as Roles,
+ type RoleCreateResponse as RoleCreateResponse,
+ type RoleListResponse as RoleListResponse,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleListResponsesPage as RoleListResponsesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects/groups/index.ts b/src/resources/admin/organization/projects/groups/index.ts
new file mode 100644
index 0000000000..cfa5fc6afc
--- /dev/null
+++ b/src/resources/admin/organization/projects/groups/index.ts
@@ -0,0 +1,21 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export {
+ Groups,
+ type ProjectGroup,
+ type GroupDeleteResponse,
+ type GroupCreateParams,
+ type GroupListParams,
+ type GroupDeleteParams,
+ type ProjectGroupsPage,
+} from './groups';
+export {
+ Roles,
+ type RoleCreateResponse,
+ type RoleListResponse,
+ type RoleDeleteResponse,
+ type RoleCreateParams,
+ type RoleListParams,
+ type RoleDeleteParams,
+ type RoleListResponsesPage,
+} from './roles';
diff --git a/src/resources/admin/organization/projects/groups/roles.ts b/src/resources/admin/organization/projects/groups/roles.ts
new file mode 100644
index 0000000000..dc7bfe39e4
--- /dev/null
+++ b/src/resources/admin/organization/projects/groups/roles.ts
@@ -0,0 +1,261 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../../core/resource';
+import * as RolesAPI from '../../roles';
+import { APIPromise } from '../../../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../../../core/pagination';
+import { RequestOptions } from '../../../../../internal/request-options';
+import { path } from '../../../../../internal/utils/path';
+
+export class Roles extends APIResource {
+ /**
+ * Assigns a project role to a group within a project.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.projects.groups.roles.create(
+ * 'group_id',
+ * { project_id: 'project_id', role_id: 'role_id' },
+ * );
+ * ```
+ */
+ create(
+ groupID: string,
+ params: RoleCreateParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ const { project_id, ...body } = params;
+ return this._client.post(path`/projects/${project_id}/groups/${groupID}/roles`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists the project roles assigned to a group within a project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const roleListResponse of client.admin.organization.projects.groups.roles.list(
+ * 'group_id',
+ * { project_id: 'project_id' },
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ groupID: string,
+ params: RoleListParams,
+ options?: RequestOptions,
+ ): PagePromise {
+ const { project_id, ...query } = params;
+ return this._client.getAPIList(
+ path`/projects/${project_id}/groups/${groupID}/roles`,
+ NextCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Unassigns a project role from a group within a project.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.projects.groups.roles.delete(
+ * 'role_id',
+ * { project_id: 'project_id', group_id: 'group_id' },
+ * );
+ * ```
+ */
+ delete(roleID: string, params: RoleDeleteParams, options?: RequestOptions): APIPromise {
+ const { project_id, group_id } = params;
+ return this._client.delete(path`/projects/${project_id}/groups/${group_id}/roles/${roleID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type RoleListResponsesPage = NextCursorPage;
+
+/**
+ * Role assignment linking a group to a role.
+ */
+export interface RoleCreateResponse {
+ /**
+ * Summary information about a group returned in role assignment responses.
+ */
+ group: RoleCreateResponse.Group;
+
+ /**
+ * Always `group.role`.
+ */
+ object: 'group.role';
+
+ /**
+ * Details about a role that can be assigned through the public Roles API.
+ */
+ role: RolesAPI.Role;
+}
+
+export namespace RoleCreateResponse {
+ /**
+ * Summary information about a group returned in role assignment responses.
+ */
+ export interface Group {
+ /**
+ * Identifier for the group.
+ */
+ id: string;
+
+ /**
+ * Unix timestamp (in seconds) when the group was created.
+ */
+ created_at: number;
+
+ /**
+ * Display name of the group.
+ */
+ name: string;
+
+ /**
+ * Always `group`.
+ */
+ object: 'group';
+
+ /**
+ * Whether the group is managed through SCIM.
+ */
+ scim_managed: boolean;
+ }
+}
+
+/**
+ * Detailed information about a role assignment entry returned when listing
+ * assignments.
+ */
+export interface RoleListResponse {
+ /**
+ * Identifier for the role.
+ */
+ id: string;
+
+ /**
+ * When the role was created.
+ */
+ created_at: number | null;
+
+ /**
+ * Identifier of the actor who created the role.
+ */
+ created_by: string | null;
+
+ /**
+ * User details for the actor that created the role, when available.
+ */
+ created_by_user_obj: { [key: string]: unknown } | null;
+
+ /**
+ * Description of the role.
+ */
+ description: string | null;
+
+ /**
+ * Arbitrary metadata stored on the role.
+ */
+ metadata: { [key: string]: unknown } | null;
+
+ /**
+ * Name of the role.
+ */
+ name: string;
+
+ /**
+ * Permissions associated with the role.
+ */
+ permissions: Array;
+
+ /**
+ * Whether the role is predefined by OpenAI.
+ */
+ predefined_role: boolean;
+
+ /**
+ * Resource type the role applies to.
+ */
+ resource_type: string;
+
+ /**
+ * When the role was last updated.
+ */
+ updated_at: number | null;
+}
+
+/**
+ * Confirmation payload returned after unassigning a role.
+ */
+export interface RoleDeleteResponse {
+ /**
+ * Whether the assignment was removed.
+ */
+ deleted: boolean;
+
+ /**
+ * Identifier for the deleted assignment, such as `group.role.deleted` or
+ * `user.role.deleted`.
+ */
+ object: string;
+}
+
+export interface RoleCreateParams {
+ /**
+ * Path param: The ID of the project to update.
+ */
+ project_id: string;
+
+ /**
+ * Body param: Identifier of the role to assign.
+ */
+ role_id: string;
+}
+
+export interface RoleListParams extends NextCursorPageParams {
+ /**
+ * Path param: The ID of the project to inspect.
+ */
+ project_id: string;
+
+ /**
+ * Query param: Sort order for the returned project roles.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface RoleDeleteParams {
+ /**
+ * The ID of the project to modify.
+ */
+ project_id: string;
+
+ /**
+ * The ID of the group whose project role assignment should be removed.
+ */
+ group_id: string;
+}
+
+export declare namespace Roles {
+ export {
+ type RoleCreateResponse as RoleCreateResponse,
+ type RoleListResponse as RoleListResponse,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleListResponsesPage as RoleListResponsesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects/index.ts b/src/resources/admin/organization/projects/index.ts
new file mode 100644
index 0000000000..35d776d530
--- /dev/null
+++ b/src/resources/admin/organization/projects/index.ts
@@ -0,0 +1,77 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export {
+ APIKeys,
+ type ProjectAPIKey,
+ type APIKeyDeleteResponse,
+ type APIKeyRetrieveParams,
+ type APIKeyListParams,
+ type APIKeyDeleteParams,
+ type ProjectAPIKeysPage,
+} from './api-keys';
+export {
+ Certificates,
+ type CertificateListResponse,
+ type CertificateActivateResponse,
+ type CertificateDeactivateResponse,
+ type CertificateListParams,
+ type CertificateActivateParams,
+ type CertificateDeactivateParams,
+ type CertificateListResponsesPage,
+ type CertificateActivateResponsesPage,
+ type CertificateDeactivateResponsesPage,
+} from './certificates';
+export {
+ Groups,
+ type ProjectGroup,
+ type GroupDeleteResponse,
+ type GroupCreateParams,
+ type GroupListParams,
+ type GroupDeleteParams,
+ type ProjectGroupsPage,
+} from './groups/index';
+export {
+ Projects,
+ type Project,
+ type ProjectCreateParams,
+ type ProjectUpdateParams,
+ type ProjectListParams,
+ type ProjectsPage,
+} from './projects';
+export {
+ RateLimits,
+ type ProjectRateLimit,
+ type RateLimitListRateLimitsParams,
+ type RateLimitUpdateRateLimitParams,
+ type ProjectRateLimitsPage,
+} from './rate-limits';
+export {
+ Roles,
+ type RoleDeleteResponse,
+ type RoleCreateParams,
+ type RoleUpdateParams,
+ type RoleListParams,
+ type RoleDeleteParams,
+} from './roles';
+export {
+ ServiceAccounts,
+ type ProjectServiceAccount,
+ type ServiceAccountCreateResponse,
+ type ServiceAccountDeleteResponse,
+ type ServiceAccountCreateParams,
+ type ServiceAccountRetrieveParams,
+ type ServiceAccountListParams,
+ type ServiceAccountDeleteParams,
+ type ProjectServiceAccountsPage,
+} from './service-accounts';
+export {
+ Users,
+ type ProjectUser,
+ type UserDeleteResponse,
+ type UserCreateParams,
+ type UserRetrieveParams,
+ type UserUpdateParams,
+ type UserListParams,
+ type UserDeleteParams,
+ type ProjectUsersPage,
+} from './users/index';
diff --git a/src/resources/admin/organization/projects/projects.ts b/src/resources/admin/organization/projects/projects.ts
new file mode 100644
index 0000000000..4efd6128a9
--- /dev/null
+++ b/src/resources/admin/organization/projects/projects.ts
@@ -0,0 +1,353 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import * as APIKeysAPI from './api-keys';
+import {
+ APIKeyDeleteParams,
+ APIKeyDeleteResponse,
+ APIKeyListParams,
+ APIKeyRetrieveParams,
+ APIKeys,
+ ProjectAPIKey,
+ ProjectAPIKeysPage,
+} from './api-keys';
+import * as CertificatesAPI from './certificates';
+import {
+ CertificateActivateParams,
+ CertificateActivateResponse,
+ CertificateActivateResponsesPage,
+ CertificateDeactivateParams,
+ CertificateDeactivateResponse,
+ CertificateDeactivateResponsesPage,
+ CertificateListParams,
+ CertificateListResponse,
+ CertificateListResponsesPage,
+ Certificates,
+} from './certificates';
+import * as RateLimitsAPI from './rate-limits';
+import {
+ ProjectRateLimit,
+ ProjectRateLimitsPage,
+ RateLimitListRateLimitsParams,
+ RateLimitUpdateRateLimitParams,
+ RateLimits,
+} from './rate-limits';
+import * as RolesAPI from './roles';
+import {
+ RoleCreateParams,
+ RoleDeleteParams,
+ RoleDeleteResponse,
+ RoleListParams,
+ RoleUpdateParams,
+ Roles,
+} from './roles';
+import * as ServiceAccountsAPI from './service-accounts';
+import {
+ ProjectServiceAccount,
+ ProjectServiceAccountsPage,
+ ServiceAccountCreateParams,
+ ServiceAccountCreateResponse,
+ ServiceAccountDeleteParams,
+ ServiceAccountDeleteResponse,
+ ServiceAccountListParams,
+ ServiceAccountRetrieveParams,
+ ServiceAccounts,
+} from './service-accounts';
+import * as GroupsAPI from './groups/groups';
+import {
+ GroupCreateParams,
+ GroupDeleteParams,
+ GroupDeleteResponse,
+ GroupListParams,
+ Groups,
+ ProjectGroup,
+ ProjectGroupsPage,
+} from './groups/groups';
+import * as UsersAPI from './users/users';
+import {
+ ProjectUser,
+ ProjectUsersPage,
+ UserCreateParams,
+ UserDeleteParams,
+ UserDeleteResponse,
+ UserListParams,
+ UserRetrieveParams,
+ UserUpdateParams,
+ Users,
+} from './users/users';
+import { APIPromise } from '../../../../core/api-promise';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ PagePromise,
+} from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class Projects extends APIResource {
+ users: UsersAPI.Users = new UsersAPI.Users(this._client);
+ serviceAccounts: ServiceAccountsAPI.ServiceAccounts = new ServiceAccountsAPI.ServiceAccounts(this._client);
+ apiKeys: APIKeysAPI.APIKeys = new APIKeysAPI.APIKeys(this._client);
+ rateLimits: RateLimitsAPI.RateLimits = new RateLimitsAPI.RateLimits(this._client);
+ groups: GroupsAPI.Groups = new GroupsAPI.Groups(this._client);
+ roles: RolesAPI.Roles = new RolesAPI.Roles(this._client);
+ certificates: CertificatesAPI.Certificates = new CertificatesAPI.Certificates(this._client);
+
+ /**
+ * Create a new project in the organization. Projects can be created and archived,
+ * but cannot be deleted.
+ *
+ * @example
+ * ```ts
+ * const project =
+ * await client.admin.organization.projects.create({
+ * name: 'name',
+ * });
+ * ```
+ */
+ create(body: ProjectCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post('/organization/projects', {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Retrieves a project.
+ *
+ * @example
+ * ```ts
+ * const project =
+ * await client.admin.organization.projects.retrieve(
+ * 'project_id',
+ * );
+ * ```
+ */
+ retrieve(projectID: string, options?: RequestOptions): APIPromise {
+ return this._client.get(path`/organization/projects/${projectID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Modifies a project in the organization.
+ *
+ * @example
+ * ```ts
+ * const project =
+ * await client.admin.organization.projects.update(
+ * 'project_id',
+ * { name: 'name' },
+ * );
+ * ```
+ */
+ update(projectID: string, body: ProjectUpdateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/projects/${projectID}`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Returns a list of projects.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const project of client.admin.organization.projects.list()) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ query: ProjectListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList('/organization/projects', ConversationCursorPage, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Archives a project in the organization. Archived projects cannot be used or
+ * updated.
+ *
+ * @example
+ * ```ts
+ * const project =
+ * await client.admin.organization.projects.archive(
+ * 'project_id',
+ * );
+ * ```
+ */
+ archive(projectID: string, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/projects/${projectID}/archive`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type ProjectsPage = ConversationCursorPage;
+
+/**
+ * Represents an individual project.
+ */
+export interface Project {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the project was created.
+ */
+ created_at: number;
+
+ /**
+ * The name of the project. This appears in reporting.
+ */
+ name: string;
+
+ /**
+ * The object type, which is always `organization.project`
+ */
+ object: 'organization.project';
+
+ /**
+ * `active` or `archived`
+ */
+ status: 'active' | 'archived';
+
+ /**
+ * The Unix timestamp (in seconds) of when the project was archived or `null`.
+ */
+ archived_at?: number | null;
+}
+
+export interface ProjectCreateParams {
+ /**
+ * The friendly name of the project, this name appears in reports.
+ */
+ name: string;
+
+ /**
+ * Create the project with the specified data residency region. Your organization
+ * must have access to Data residency functionality in order to use. See
+ * [data residency controls](https://platform.openai.com/docs/guides/your-data#data-residency-controls)
+ * to review the functionality and limitations of setting this field.
+ */
+ geography?: 'US' | 'EU' | 'JP' | 'IN' | 'KR' | 'CA' | 'AU' | 'SG';
+}
+
+export interface ProjectUpdateParams {
+ /**
+ * The updated name of the project, this name appears in reports.
+ */
+ name: string;
+}
+
+export interface ProjectListParams extends ConversationCursorPageParams {
+ /**
+ * If `true` returns all projects including those that have been `archived`.
+ * Archived projects are not included by default.
+ */
+ include_archived?: boolean;
+}
+
+Projects.Users = Users;
+Projects.ServiceAccounts = ServiceAccounts;
+Projects.APIKeys = APIKeys;
+Projects.RateLimits = RateLimits;
+Projects.Groups = Groups;
+Projects.Roles = Roles;
+Projects.Certificates = Certificates;
+
+export declare namespace Projects {
+ export {
+ type Project as Project,
+ type ProjectsPage as ProjectsPage,
+ type ProjectCreateParams as ProjectCreateParams,
+ type ProjectUpdateParams as ProjectUpdateParams,
+ type ProjectListParams as ProjectListParams,
+ };
+
+ export {
+ Users as Users,
+ type ProjectUser as ProjectUser,
+ type UserDeleteResponse as UserDeleteResponse,
+ type ProjectUsersPage as ProjectUsersPage,
+ type UserCreateParams as UserCreateParams,
+ type UserRetrieveParams as UserRetrieveParams,
+ type UserUpdateParams as UserUpdateParams,
+ type UserListParams as UserListParams,
+ type UserDeleteParams as UserDeleteParams,
+ };
+
+ export {
+ ServiceAccounts as ServiceAccounts,
+ type ProjectServiceAccount as ProjectServiceAccount,
+ type ServiceAccountCreateResponse as ServiceAccountCreateResponse,
+ type ServiceAccountDeleteResponse as ServiceAccountDeleteResponse,
+ type ProjectServiceAccountsPage as ProjectServiceAccountsPage,
+ type ServiceAccountCreateParams as ServiceAccountCreateParams,
+ type ServiceAccountRetrieveParams as ServiceAccountRetrieveParams,
+ type ServiceAccountListParams as ServiceAccountListParams,
+ type ServiceAccountDeleteParams as ServiceAccountDeleteParams,
+ };
+
+ export {
+ APIKeys as APIKeys,
+ type ProjectAPIKey as ProjectAPIKey,
+ type APIKeyDeleteResponse as APIKeyDeleteResponse,
+ type ProjectAPIKeysPage as ProjectAPIKeysPage,
+ type APIKeyRetrieveParams as APIKeyRetrieveParams,
+ type APIKeyListParams as APIKeyListParams,
+ type APIKeyDeleteParams as APIKeyDeleteParams,
+ };
+
+ export {
+ RateLimits as RateLimits,
+ type ProjectRateLimit as ProjectRateLimit,
+ type ProjectRateLimitsPage as ProjectRateLimitsPage,
+ type RateLimitListRateLimitsParams as RateLimitListRateLimitsParams,
+ type RateLimitUpdateRateLimitParams as RateLimitUpdateRateLimitParams,
+ };
+
+ export {
+ Groups as Groups,
+ type ProjectGroup as ProjectGroup,
+ type GroupDeleteResponse as GroupDeleteResponse,
+ type ProjectGroupsPage as ProjectGroupsPage,
+ type GroupCreateParams as GroupCreateParams,
+ type GroupListParams as GroupListParams,
+ type GroupDeleteParams as GroupDeleteParams,
+ };
+
+ export {
+ Roles as Roles,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleUpdateParams as RoleUpdateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+
+ export {
+ Certificates as Certificates,
+ type CertificateListResponse as CertificateListResponse,
+ type CertificateActivateResponse as CertificateActivateResponse,
+ type CertificateDeactivateResponse as CertificateDeactivateResponse,
+ type CertificateListResponsesPage as CertificateListResponsesPage,
+ type CertificateActivateResponsesPage as CertificateActivateResponsesPage,
+ type CertificateDeactivateResponsesPage as CertificateDeactivateResponsesPage,
+ type CertificateListParams as CertificateListParams,
+ type CertificateActivateParams as CertificateActivateParams,
+ type CertificateDeactivateParams as CertificateDeactivateParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects/rate-limits.ts b/src/resources/admin/organization/projects/rate-limits.ts
new file mode 100644
index 0000000000..10dee8b8e8
--- /dev/null
+++ b/src/resources/admin/organization/projects/rate-limits.ts
@@ -0,0 +1,173 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import { APIPromise } from '../../../../core/api-promise';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ PagePromise,
+} from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class RateLimits extends APIResource {
+ /**
+ * Returns the rate limits per model for a project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const projectRateLimit of client.admin.organization.projects.rateLimits.listRateLimits(
+ * 'project_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ listRateLimits(
+ projectID: string,
+ query: RateLimitListRateLimitsParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/projects/${projectID}/rate_limits`,
+ ConversationCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Updates a project rate limit.
+ *
+ * @example
+ * ```ts
+ * const projectRateLimit =
+ * await client.admin.organization.projects.rateLimits.updateRateLimit(
+ * 'rate_limit_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ updateRateLimit(
+ rateLimitID: string,
+ params: RateLimitUpdateRateLimitParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ const { project_id, ...body } = params;
+ return this._client.post(path`/organization/projects/${project_id}/rate_limits/${rateLimitID}`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type ProjectRateLimitsPage = ConversationCursorPage;
+
+/**
+ * Represents a project rate limit config.
+ */
+export interface ProjectRateLimit {
+ /**
+ * The identifier, which can be referenced in API endpoints.
+ */
+ id: string;
+
+ /**
+ * The maximum requests per minute.
+ */
+ max_requests_per_1_minute: number;
+
+ /**
+ * The maximum tokens per minute.
+ */
+ max_tokens_per_1_minute: number;
+
+ /**
+ * The model this rate limit applies to.
+ */
+ model: string;
+
+ /**
+ * The object type, which is always `project.rate_limit`
+ */
+ object: 'project.rate_limit';
+
+ /**
+ * The maximum batch input tokens per day. Only present for relevant models.
+ */
+ batch_1_day_max_input_tokens?: number;
+
+ /**
+ * The maximum audio megabytes per minute. Only present for relevant models.
+ */
+ max_audio_megabytes_per_1_minute?: number;
+
+ /**
+ * The maximum images per minute. Only present for relevant models.
+ */
+ max_images_per_1_minute?: number;
+
+ /**
+ * The maximum requests per day. Only present for relevant models.
+ */
+ max_requests_per_1_day?: number;
+}
+
+export interface RateLimitListRateLimitsParams extends ConversationCursorPageParams {
+ /**
+ * 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.
+ */
+ before?: string;
+}
+
+export interface RateLimitUpdateRateLimitParams {
+ /**
+ * Path param: The ID of the project.
+ */
+ project_id: string;
+
+ /**
+ * Body param: The maximum batch input tokens per day. Only relevant for certain
+ * models.
+ */
+ batch_1_day_max_input_tokens?: number;
+
+ /**
+ * Body param: The maximum audio megabytes per minute. Only relevant for certain
+ * models.
+ */
+ max_audio_megabytes_per_1_minute?: number;
+
+ /**
+ * Body param: The maximum images per minute. Only relevant for certain models.
+ */
+ max_images_per_1_minute?: number;
+
+ /**
+ * Body param: The maximum requests per day. Only relevant for certain models.
+ */
+ max_requests_per_1_day?: number;
+
+ /**
+ * Body param: The maximum requests per minute.
+ */
+ max_requests_per_1_minute?: number;
+
+ /**
+ * Body param: The maximum tokens per minute.
+ */
+ max_tokens_per_1_minute?: number;
+}
+
+export declare namespace RateLimits {
+ export {
+ type ProjectRateLimit as ProjectRateLimit,
+ type ProjectRateLimitsPage as ProjectRateLimitsPage,
+ type RateLimitListRateLimitsParams as RateLimitListRateLimitsParams,
+ type RateLimitUpdateRateLimitParams as RateLimitUpdateRateLimitParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects/roles.ts b/src/resources/admin/organization/projects/roles.ts
new file mode 100644
index 0000000000..aaeb1b94c1
--- /dev/null
+++ b/src/resources/admin/organization/projects/roles.ts
@@ -0,0 +1,182 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import * as RolesAPI from '../roles';
+import { RolesPage } from '../roles';
+import { APIPromise } from '../../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class Roles extends APIResource {
+ /**
+ * Creates a custom role for a project.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.projects.roles.create(
+ * 'project_id',
+ * { permissions: ['string'], role_name: 'role_name' },
+ * );
+ * ```
+ */
+ create(projectID: string, body: RoleCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/projects/${projectID}/roles`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Updates an existing project role.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.projects.roles.update(
+ * 'role_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ update(roleID: string, params: RoleUpdateParams, options?: RequestOptions): APIPromise {
+ const { project_id, ...body } = params;
+ return this._client.post(path`/projects/${project_id}/roles/${roleID}`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists the roles configured for a project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const role of client.admin.organization.projects.roles.list(
+ * 'project_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ projectID: string,
+ query: RoleListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(path`/projects/${projectID}/roles`, NextCursorPage, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Deletes a custom role from a project.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.projects.roles.delete(
+ * 'role_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ delete(roleID: string, params: RoleDeleteParams, options?: RequestOptions): APIPromise {
+ const { project_id } = params;
+ return this._client.delete(path`/projects/${project_id}/roles/${roleID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+/**
+ * Confirmation payload returned after deleting a role.
+ */
+export interface RoleDeleteResponse {
+ /**
+ * Identifier of the deleted role.
+ */
+ id: string;
+
+ /**
+ * Whether the role was deleted.
+ */
+ deleted: boolean;
+
+ /**
+ * Always `role.deleted`.
+ */
+ object: 'role.deleted';
+}
+
+export interface RoleCreateParams {
+ /**
+ * Permissions to grant to the role.
+ */
+ permissions: Array;
+
+ /**
+ * Unique name for the role.
+ */
+ role_name: string;
+
+ /**
+ * Optional description of the role.
+ */
+ description?: string | null;
+}
+
+export interface RoleUpdateParams {
+ /**
+ * Path param: The ID of the project to update.
+ */
+ project_id: string;
+
+ /**
+ * Body param: New description for the role.
+ */
+ description?: string | null;
+
+ /**
+ * Body param: Updated set of permissions for the role.
+ */
+ permissions?: Array | null;
+
+ /**
+ * Body param: New name for the role.
+ */
+ role_name?: string | null;
+}
+
+export interface RoleListParams extends NextCursorPageParams {
+ /**
+ * Sort order for the returned roles.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface RoleDeleteParams {
+ /**
+ * The ID of the project to update.
+ */
+ project_id: string;
+}
+
+export declare namespace Roles {
+ export {
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleUpdateParams as RoleUpdateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
+
+export { type RolesPage };
diff --git a/src/resources/admin/organization/projects/service-accounts.ts b/src/resources/admin/organization/projects/service-accounts.ts
new file mode 100644
index 0000000000..462f273e02
--- /dev/null
+++ b/src/resources/admin/organization/projects/service-accounts.ts
@@ -0,0 +1,224 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import { APIPromise } from '../../../../core/api-promise';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ PagePromise,
+} from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class ServiceAccounts extends APIResource {
+ /**
+ * Creates a new service account in the project. This also returns an unredacted
+ * API key for the service account.
+ *
+ * @example
+ * ```ts
+ * const serviceAccount =
+ * await client.admin.organization.projects.serviceAccounts.create(
+ * 'project_id',
+ * { name: 'name' },
+ * );
+ * ```
+ */
+ create(
+ projectID: string,
+ body: ServiceAccountCreateParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ return this._client.post(path`/organization/projects/${projectID}/service_accounts`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Retrieves a service account in the project.
+ *
+ * @example
+ * ```ts
+ * const projectServiceAccount =
+ * await client.admin.organization.projects.serviceAccounts.retrieve(
+ * 'service_account_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ retrieve(
+ serviceAccountID: string,
+ params: ServiceAccountRetrieveParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ const { project_id } = params;
+ return this._client.get(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Returns a list of service accounts in the project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list(
+ * 'project_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ projectID: string,
+ query: ServiceAccountListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/projects/${projectID}/service_accounts`,
+ ConversationCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * 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).
+ *
+ * @example
+ * ```ts
+ * const serviceAccount =
+ * await client.admin.organization.projects.serviceAccounts.delete(
+ * 'service_account_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ delete(
+ serviceAccountID: string,
+ params: ServiceAccountDeleteParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ const { project_id } = params;
+ return this._client.delete(
+ path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`,
+ { ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+}
+
+export type ProjectServiceAccountsPage = ConversationCursorPage;
+
+/**
+ * Represents an individual service account in a project.
+ */
+export interface ProjectServiceAccount {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the service account was created
+ */
+ created_at: number;
+
+ /**
+ * The name of the service account
+ */
+ name: string;
+
+ /**
+ * The object type, which is always `organization.project.service_account`
+ */
+ object: 'organization.project.service_account';
+
+ /**
+ * `owner` or `member`
+ */
+ role: 'owner' | 'member';
+}
+
+export interface ServiceAccountCreateResponse {
+ id: string;
+
+ api_key: ServiceAccountCreateResponse.APIKey | null;
+
+ created_at: number;
+
+ name: string;
+
+ object: 'organization.project.service_account';
+
+ /**
+ * Service accounts can only have one role of type `member`
+ */
+ role: 'member';
+}
+
+export namespace ServiceAccountCreateResponse {
+ export interface APIKey {
+ id: string;
+
+ created_at: number;
+
+ name: string;
+
+ /**
+ * The object type, which is always `organization.project.service_account.api_key`
+ */
+ object: 'organization.project.service_account.api_key';
+
+ value: string;
+ }
+}
+
+export interface ServiceAccountDeleteResponse {
+ id: string;
+
+ deleted: boolean;
+
+ object: 'organization.project.service_account.deleted';
+}
+
+export interface ServiceAccountCreateParams {
+ /**
+ * The name of the service account being created.
+ */
+ name: string;
+}
+
+export interface ServiceAccountRetrieveParams {
+ /**
+ * The ID of the project.
+ */
+ project_id: string;
+}
+
+export interface ServiceAccountListParams extends ConversationCursorPageParams {}
+
+export interface ServiceAccountDeleteParams {
+ /**
+ * The ID of the project.
+ */
+ project_id: string;
+}
+
+export declare namespace ServiceAccounts {
+ export {
+ type ProjectServiceAccount as ProjectServiceAccount,
+ type ServiceAccountCreateResponse as ServiceAccountCreateResponse,
+ type ServiceAccountDeleteResponse as ServiceAccountDeleteResponse,
+ type ProjectServiceAccountsPage as ProjectServiceAccountsPage,
+ type ServiceAccountCreateParams as ServiceAccountCreateParams,
+ type ServiceAccountRetrieveParams as ServiceAccountRetrieveParams,
+ type ServiceAccountListParams as ServiceAccountListParams,
+ type ServiceAccountDeleteParams as ServiceAccountDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects/users.ts b/src/resources/admin/organization/projects/users.ts
new file mode 100644
index 0000000000..db908c701b
--- /dev/null
+++ b/src/resources/admin/organization/projects/users.ts
@@ -0,0 +1,3 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export * from './users/index';
diff --git a/src/resources/admin/organization/projects/users/index.ts b/src/resources/admin/organization/projects/users/index.ts
new file mode 100644
index 0000000000..ca28dd6014
--- /dev/null
+++ b/src/resources/admin/organization/projects/users/index.ts
@@ -0,0 +1,23 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export {
+ Roles,
+ type RoleCreateResponse,
+ type RoleListResponse,
+ type RoleDeleteResponse,
+ type RoleCreateParams,
+ type RoleListParams,
+ type RoleDeleteParams,
+ type RoleListResponsesPage,
+} from './roles';
+export {
+ Users,
+ type ProjectUser,
+ type UserDeleteResponse,
+ type UserCreateParams,
+ type UserRetrieveParams,
+ type UserUpdateParams,
+ type UserListParams,
+ type UserDeleteParams,
+ type ProjectUsersPage,
+} from './users';
diff --git a/src/resources/admin/organization/projects/users/roles.ts b/src/resources/admin/organization/projects/users/roles.ts
new file mode 100644
index 0000000000..16e1a09b77
--- /dev/null
+++ b/src/resources/admin/organization/projects/users/roles.ts
@@ -0,0 +1,226 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../../core/resource';
+import * as RolesAPI from '../../roles';
+import * as UsersAPI from '../../users/users';
+import { APIPromise } from '../../../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../../../core/pagination';
+import { RequestOptions } from '../../../../../internal/request-options';
+import { path } from '../../../../../internal/utils/path';
+
+export class Roles extends APIResource {
+ /**
+ * Assigns a project role to a user within a project.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.projects.users.roles.create(
+ * 'user_id',
+ * { project_id: 'project_id', role_id: 'role_id' },
+ * );
+ * ```
+ */
+ create(userID: string, params: RoleCreateParams, options?: RequestOptions): APIPromise {
+ const { project_id, ...body } = params;
+ return this._client.post(path`/projects/${project_id}/users/${userID}/roles`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists the project roles assigned to a user within a project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const roleListResponse of client.admin.organization.projects.users.roles.list(
+ * 'user_id',
+ * { project_id: 'project_id' },
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ userID: string,
+ params: RoleListParams,
+ options?: RequestOptions,
+ ): PagePromise {
+ const { project_id, ...query } = params;
+ return this._client.getAPIList(
+ path`/projects/${project_id}/users/${userID}/roles`,
+ NextCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Unassigns a project role from a user within a project.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.projects.users.roles.delete(
+ * 'role_id',
+ * { project_id: 'project_id', user_id: 'user_id' },
+ * );
+ * ```
+ */
+ delete(roleID: string, params: RoleDeleteParams, options?: RequestOptions): APIPromise {
+ const { project_id, user_id } = params;
+ return this._client.delete(path`/projects/${project_id}/users/${user_id}/roles/${roleID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type RoleListResponsesPage = NextCursorPage;
+
+/**
+ * Role assignment linking a user to a role.
+ */
+export interface RoleCreateResponse {
+ /**
+ * Always `user.role`.
+ */
+ object: 'user.role';
+
+ /**
+ * Details about a role that can be assigned through the public Roles API.
+ */
+ role: RolesAPI.Role;
+
+ /**
+ * Represents an individual `user` within an organization.
+ */
+ user: UsersAPI.OrganizationUser;
+}
+
+/**
+ * Detailed information about a role assignment entry returned when listing
+ * assignments.
+ */
+export interface RoleListResponse {
+ /**
+ * Identifier for the role.
+ */
+ id: string;
+
+ /**
+ * When the role was created.
+ */
+ created_at: number | null;
+
+ /**
+ * Identifier of the actor who created the role.
+ */
+ created_by: string | null;
+
+ /**
+ * User details for the actor that created the role, when available.
+ */
+ created_by_user_obj: { [key: string]: unknown } | null;
+
+ /**
+ * Description of the role.
+ */
+ description: string | null;
+
+ /**
+ * Arbitrary metadata stored on the role.
+ */
+ metadata: { [key: string]: unknown } | null;
+
+ /**
+ * Name of the role.
+ */
+ name: string;
+
+ /**
+ * Permissions associated with the role.
+ */
+ permissions: Array;
+
+ /**
+ * Whether the role is predefined by OpenAI.
+ */
+ predefined_role: boolean;
+
+ /**
+ * Resource type the role applies to.
+ */
+ resource_type: string;
+
+ /**
+ * When the role was last updated.
+ */
+ updated_at: number | null;
+}
+
+/**
+ * Confirmation payload returned after unassigning a role.
+ */
+export interface RoleDeleteResponse {
+ /**
+ * Whether the assignment was removed.
+ */
+ deleted: boolean;
+
+ /**
+ * Identifier for the deleted assignment, such as `group.role.deleted` or
+ * `user.role.deleted`.
+ */
+ object: string;
+}
+
+export interface RoleCreateParams {
+ /**
+ * Path param: The ID of the project to update.
+ */
+ project_id: string;
+
+ /**
+ * Body param: Identifier of the role to assign.
+ */
+ role_id: string;
+}
+
+export interface RoleListParams extends NextCursorPageParams {
+ /**
+ * Path param: The ID of the project to inspect.
+ */
+ project_id: string;
+
+ /**
+ * Query param: Sort order for the returned project roles.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface RoleDeleteParams {
+ /**
+ * The ID of the project to modify.
+ */
+ project_id: string;
+
+ /**
+ * The ID of the user whose project role assignment should be removed.
+ */
+ user_id: string;
+}
+
+export declare namespace Roles {
+ export {
+ type RoleCreateResponse as RoleCreateResponse,
+ type RoleListResponse as RoleListResponse,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleListResponsesPage as RoleListResponsesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/projects/users/users.ts b/src/resources/admin/organization/projects/users/users.ts
new file mode 100644
index 0000000000..6f37240b2b
--- /dev/null
+++ b/src/resources/admin/organization/projects/users/users.ts
@@ -0,0 +1,247 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../../core/resource';
+import * as RolesAPI from './roles';
+import {
+ RoleCreateParams,
+ RoleCreateResponse,
+ RoleDeleteParams,
+ RoleDeleteResponse,
+ RoleListParams,
+ RoleListResponse,
+ RoleListResponsesPage,
+ Roles,
+} from './roles';
+import { APIPromise } from '../../../../../core/api-promise';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ PagePromise,
+} from '../../../../../core/pagination';
+import { RequestOptions } from '../../../../../internal/request-options';
+import { path } from '../../../../../internal/utils/path';
+
+export class Users extends APIResource {
+ roles: RolesAPI.Roles = new RolesAPI.Roles(this._client);
+
+ /**
+ * Adds a user to the project. Users must already be members of the organization to
+ * be added to a project.
+ *
+ * @example
+ * ```ts
+ * const projectUser =
+ * await client.admin.organization.projects.users.create(
+ * 'project_id',
+ * { role: 'owner', user_id: 'user_id' },
+ * );
+ * ```
+ */
+ create(projectID: string, body: UserCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/projects/${projectID}/users`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Retrieves a user in the project.
+ *
+ * @example
+ * ```ts
+ * const projectUser =
+ * await client.admin.organization.projects.users.retrieve(
+ * 'user_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ retrieve(userID: string, params: UserRetrieveParams, options?: RequestOptions): APIPromise {
+ const { project_id } = params;
+ return this._client.get(path`/organization/projects/${project_id}/users/${userID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Modifies a user's role in the project.
+ *
+ * @example
+ * ```ts
+ * const projectUser =
+ * await client.admin.organization.projects.users.update(
+ * 'user_id',
+ * { project_id: 'project_id', role: 'owner' },
+ * );
+ * ```
+ */
+ update(userID: string, params: UserUpdateParams, options?: RequestOptions): APIPromise {
+ const { project_id, ...body } = params;
+ return this._client.post(path`/organization/projects/${project_id}/users/${userID}`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Returns a list of users in the project.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const projectUser of client.admin.organization.projects.users.list(
+ * 'project_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ projectID: string,
+ query: UserListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/projects/${projectID}/users`,
+ ConversationCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * 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).
+ *
+ * @example
+ * ```ts
+ * const user =
+ * await client.admin.organization.projects.users.delete(
+ * 'user_id',
+ * { project_id: 'project_id' },
+ * );
+ * ```
+ */
+ delete(userID: string, params: UserDeleteParams, options?: RequestOptions): APIPromise {
+ const { project_id } = params;
+ return this._client.delete(path`/organization/projects/${project_id}/users/${userID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type ProjectUsersPage = ConversationCursorPage;
+
+/**
+ * Represents an individual user in a project.
+ */
+export interface ProjectUser {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the project was added.
+ */
+ added_at: number;
+
+ /**
+ * The email address of the user
+ */
+ email: string;
+
+ /**
+ * The name of the user
+ */
+ name: string;
+
+ /**
+ * The object type, which is always `organization.project.user`
+ */
+ object: 'organization.project.user';
+
+ /**
+ * `owner` or `member`
+ */
+ role: 'owner' | 'member';
+}
+
+export interface UserDeleteResponse {
+ id: string;
+
+ deleted: boolean;
+
+ object: 'organization.project.user.deleted';
+}
+
+export interface UserCreateParams {
+ /**
+ * `owner` or `member`
+ */
+ role: 'owner' | 'member';
+
+ /**
+ * The ID of the user.
+ */
+ user_id: string;
+}
+
+export interface UserRetrieveParams {
+ /**
+ * The ID of the project.
+ */
+ project_id: string;
+}
+
+export interface UserUpdateParams {
+ /**
+ * Path param: The ID of the project.
+ */
+ project_id: string;
+
+ /**
+ * Body param: `owner` or `member`
+ */
+ role: 'owner' | 'member';
+}
+
+export interface UserListParams extends ConversationCursorPageParams {}
+
+export interface UserDeleteParams {
+ /**
+ * The ID of the project.
+ */
+ project_id: string;
+}
+
+Users.Roles = Roles;
+
+export declare namespace Users {
+ export {
+ type ProjectUser as ProjectUser,
+ type UserDeleteResponse as UserDeleteResponse,
+ type ProjectUsersPage as ProjectUsersPage,
+ type UserCreateParams as UserCreateParams,
+ type UserRetrieveParams as UserRetrieveParams,
+ type UserUpdateParams as UserUpdateParams,
+ type UserListParams as UserListParams,
+ type UserDeleteParams as UserDeleteParams,
+ };
+
+ export {
+ Roles as Roles,
+ type RoleCreateResponse as RoleCreateResponse,
+ type RoleListResponse as RoleListResponse,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleListResponsesPage as RoleListResponsesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/roles.ts b/src/resources/admin/organization/roles.ts
new file mode 100644
index 0000000000..bad316ea9f
--- /dev/null
+++ b/src/resources/admin/organization/roles.ts
@@ -0,0 +1,200 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../core/resource';
+import { APIPromise } from '../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../core/pagination';
+import { RequestOptions } from '../../../internal/request-options';
+import { path } from '../../../internal/utils/path';
+
+export class Roles extends APIResource {
+ /**
+ * Creates a custom role for the organization.
+ *
+ * @example
+ * ```ts
+ * const role = await client.admin.organization.roles.create({
+ * permissions: ['string'],
+ * role_name: 'role_name',
+ * });
+ * ```
+ */
+ create(body: RoleCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post('/organization/roles', {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Updates an existing organization role.
+ *
+ * @example
+ * ```ts
+ * const role = await client.admin.organization.roles.update(
+ * 'role_id',
+ * );
+ * ```
+ */
+ update(roleID: string, body: RoleUpdateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/roles/${roleID}`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists the roles configured for the organization.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const role of client.admin.organization.roles.list()) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ query: RoleListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList('/organization/roles', NextCursorPage, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Deletes a custom role from the organization.
+ *
+ * @example
+ * ```ts
+ * const role = await client.admin.organization.roles.delete(
+ * 'role_id',
+ * );
+ * ```
+ */
+ delete(roleID: string, options?: RequestOptions): APIPromise {
+ return this._client.delete(path`/organization/roles/${roleID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type RolesPage = NextCursorPage;
+
+/**
+ * Details about a role that can be assigned through the public Roles API.
+ */
+export interface Role {
+ /**
+ * Identifier for the role.
+ */
+ id: string;
+
+ /**
+ * Optional description of the role.
+ */
+ description: string | null;
+
+ /**
+ * Unique name for the role.
+ */
+ name: string;
+
+ /**
+ * Always `role`.
+ */
+ object: 'role';
+
+ /**
+ * Permissions granted by the role.
+ */
+ permissions: Array;
+
+ /**
+ * Whether the role is predefined and managed by OpenAI.
+ */
+ predefined_role: boolean;
+
+ /**
+ * Resource type the role is bound to (for example `api.organization` or
+ * `api.project`).
+ */
+ resource_type: string;
+}
+
+/**
+ * Confirmation payload returned after deleting a role.
+ */
+export interface RoleDeleteResponse {
+ /**
+ * Identifier of the deleted role.
+ */
+ id: string;
+
+ /**
+ * Whether the role was deleted.
+ */
+ deleted: boolean;
+
+ /**
+ * Always `role.deleted`.
+ */
+ object: 'role.deleted';
+}
+
+export interface RoleCreateParams {
+ /**
+ * Permissions to grant to the role.
+ */
+ permissions: Array;
+
+ /**
+ * Unique name for the role.
+ */
+ role_name: string;
+
+ /**
+ * Optional description of the role.
+ */
+ description?: string | null;
+}
+
+export interface RoleUpdateParams {
+ /**
+ * New description for the role.
+ */
+ description?: string | null;
+
+ /**
+ * Updated set of permissions for the role.
+ */
+ permissions?: Array | null;
+
+ /**
+ * New name for the role.
+ */
+ role_name?: string | null;
+}
+
+export interface RoleListParams extends NextCursorPageParams {
+ /**
+ * Sort order for the returned roles.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export declare namespace Roles {
+ export {
+ type Role as Role,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RolesPage as RolesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleUpdateParams as RoleUpdateParams,
+ type RoleListParams as RoleListParams,
+ };
+}
diff --git a/src/resources/admin/organization/usage.ts b/src/resources/admin/organization/usage.ts
new file mode 100644
index 0000000000..4ca7840bdb
--- /dev/null
+++ b/src/resources/admin/organization/usage.ts
@@ -0,0 +1,4429 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../core/resource';
+import { APIPromise } from '../../../core/api-promise';
+import { RequestOptions } from '../../../internal/request-options';
+
+export class Usage extends APIResource {
+ /**
+ * Get audio speeches usage details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.audioSpeeches({
+ * start_time: 0,
+ * });
+ * ```
+ */
+ audioSpeeches(
+ query: UsageAudioSpeechesParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ return this._client.get('/organization/usage/audio_speeches', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get audio transcriptions usage details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.audioTranscriptions(
+ * { start_time: 0 },
+ * );
+ * ```
+ */
+ audioTranscriptions(
+ query: UsageAudioTranscriptionsParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ return this._client.get('/organization/usage/audio_transcriptions', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get code interpreter sessions usage details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.codeInterpreterSessions(
+ * { start_time: 0 },
+ * );
+ * ```
+ */
+ codeInterpreterSessions(
+ query: UsageCodeInterpreterSessionsParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ return this._client.get('/organization/usage/code_interpreter_sessions', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get completions usage details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.completions({
+ * start_time: 0,
+ * });
+ * ```
+ */
+ completions(query: UsageCompletionsParams, options?: RequestOptions): APIPromise {
+ return this._client.get('/organization/usage/completions', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get costs details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.costs({
+ * start_time: 0,
+ * });
+ * ```
+ */
+ costs(query: UsageCostsParams, options?: RequestOptions): APIPromise {
+ return this._client.get('/organization/costs', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get embeddings usage details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.embeddings({
+ * start_time: 0,
+ * });
+ * ```
+ */
+ embeddings(query: UsageEmbeddingsParams, options?: RequestOptions): APIPromise {
+ return this._client.get('/organization/usage/embeddings', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get images usage details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.images({
+ * start_time: 0,
+ * });
+ * ```
+ */
+ images(query: UsageImagesParams, options?: RequestOptions): APIPromise {
+ return this._client.get('/organization/usage/images', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get moderations usage details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.moderations({
+ * start_time: 0,
+ * });
+ * ```
+ */
+ moderations(query: UsageModerationsParams, options?: RequestOptions): APIPromise {
+ return this._client.get('/organization/usage/moderations', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Get vector stores usage details for the organization.
+ *
+ * @example
+ * ```ts
+ * const response =
+ * await client.admin.organization.usage.vectorStores({
+ * start_time: 0,
+ * });
+ * ```
+ */
+ vectorStores(
+ query: UsageVectorStoresParams,
+ options?: RequestOptions,
+ ): APIPromise {
+ return this._client.get('/organization/usage/vector_stores', {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export interface UsageAudioSpeechesResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageAudioSpeechesResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageAudioTranscriptionsResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageAudioTranscriptionsResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageCodeInterpreterSessionsResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageCodeInterpreterSessionsResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageCompletionsResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageCompletionsResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageCostsResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageCostsResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageEmbeddingsResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageEmbeddingsResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageImagesResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageImagesResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageModerationsResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageModerationsResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageVectorStoresResponse {
+ data: Array;
+
+ has_more: boolean;
+
+ next_page: string | null;
+
+ object: 'page';
+}
+
+export namespace UsageVectorStoresResponse {
+ export interface Data {
+ end_time: number;
+
+ object: 'bucket';
+
+ results: Array<
+ | Data.OrganizationUsageCompletionsResult
+ | Data.OrganizationUsageEmbeddingsResult
+ | Data.OrganizationUsageModerationsResult
+ | Data.OrganizationUsageImagesResult
+ | Data.OrganizationUsageAudioSpeechesResult
+ | Data.OrganizationUsageAudioTranscriptionsResult
+ | Data.OrganizationUsageVectorStoresResult
+ | Data.OrganizationUsageCodeInterpreterSessionsResult
+ | Data.OrganizationCostsResult
+ >;
+
+ start_time: number;
+ }
+
+ export namespace Data {
+ /**
+ * The aggregated completions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageCompletionsResult {
+ /**
+ * The aggregated number of text input tokens used, including cached tokens. For
+ * customers subscribe to scale tier, this includes scale tier tokens.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.completions.result';
+
+ /**
+ * The aggregated number of text output tokens used. For customers subscribe to
+ * scale tier, this includes scale tier tokens.
+ */
+ output_tokens: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=batch`, this field tells whether the grouped usage result is
+ * batch or not.
+ */
+ batch?: boolean | null;
+
+ /**
+ * The aggregated number of audio input tokens used, including cached tokens.
+ */
+ input_audio_tokens?: number;
+
+ /**
+ * 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.
+ */
+ input_cached_tokens?: number;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * The aggregated number of audio output tokens used.
+ */
+ output_audio_tokens?: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=service_tier`, this field provides the service tier of the
+ * grouped usage result.
+ */
+ service_tier?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated embeddings usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageEmbeddingsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.embeddings.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated moderations usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageModerationsResult {
+ /**
+ * The aggregated number of input tokens used.
+ */
+ input_tokens: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.moderations.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated images usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageImagesResult {
+ /**
+ * The number of images processed.
+ */
+ images: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.images.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=size`, this field provides the image size of the grouped usage
+ * result.
+ */
+ size?: string | null;
+
+ /**
+ * When `group_by=source`, this field provides the source of the grouped usage
+ * result, possible values are `image.generation`, `image.edit`, `image.variation`.
+ */
+ source?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio speeches usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioSpeechesResult {
+ /**
+ * The number of characters processed.
+ */
+ characters: number;
+
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_speeches.result';
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated audio transcriptions usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageAudioTranscriptionsResult {
+ /**
+ * The count of requests made to the model.
+ */
+ num_model_requests: number;
+
+ object: 'organization.usage.audio_transcriptions.result';
+
+ /**
+ * The number of seconds processed.
+ */
+ seconds: number;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API key ID of the grouped
+ * usage result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=model`, this field provides the model name of the grouped usage
+ * result.
+ */
+ model?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+
+ /**
+ * When `group_by=user_id`, this field provides the user ID of the grouped usage
+ * result.
+ */
+ user_id?: string | null;
+ }
+
+ /**
+ * The aggregated vector stores usage details of the specific time bucket.
+ */
+ export interface OrganizationUsageVectorStoresResult {
+ object: 'organization.usage.vector_stores.result';
+
+ /**
+ * The vector stores usage in bytes.
+ */
+ usage_bytes: number;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated code interpreter sessions usage details of the specific time
+ * bucket.
+ */
+ export interface OrganizationUsageCodeInterpreterSessionsResult {
+ /**
+ * The number of code interpreter sessions.
+ */
+ num_sessions: number;
+
+ object: 'organization.usage.code_interpreter_sessions.result';
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * usage result.
+ */
+ project_id?: string | null;
+ }
+
+ /**
+ * The aggregated costs details of the specific time bucket.
+ */
+ export interface OrganizationCostsResult {
+ object: 'organization.costs.result';
+
+ /**
+ * The monetary value in its associated currency.
+ */
+ amount?: OrganizationCostsResult.Amount;
+
+ /**
+ * When `group_by=api_key_id`, this field provides the API Key ID of the grouped
+ * costs result.
+ */
+ api_key_id?: string | null;
+
+ /**
+ * When `group_by=line_item`, this field provides the line item of the grouped
+ * costs result.
+ */
+ line_item?: string | null;
+
+ /**
+ * When `group_by=project_id`, this field provides the project ID of the grouped
+ * costs result.
+ */
+ project_id?: string | null;
+ }
+
+ export namespace OrganizationCostsResult {
+ /**
+ * The monetary value in its associated currency.
+ */
+ export interface Amount {
+ /**
+ * Lowercase ISO-4217 currency e.g. "usd"
+ */
+ currency?: string;
+
+ /**
+ * The numeric value of the cost.
+ */
+ value?: number;
+ }
+ }
+ }
+}
+
+export interface UsageAudioSpeechesParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Return only usage for these API keys.
+ */
+ api_key_ids?: Array;
+
+ /**
+ * Width of each time bucket in response. Currently `1m`, `1h` and `1d` are
+ * supported, default to `1d`.
+ */
+ bucket_width?: '1m' | '1h' | '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * Group the usage data by the specified fields. Support fields include
+ * `project_id`, `user_id`, `api_key_id`, `model` or any combination of them.
+ */
+ group_by?: Array<'project_id' | 'user_id' | 'api_key_id' | 'model'>;
+
+ /**
+ * 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
+ */
+ limit?: number;
+
+ /**
+ * Return only usage for these models.
+ */
+ models?: Array;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only usage for these projects.
+ */
+ project_ids?: Array;
+
+ /**
+ * Return only usage for these users.
+ */
+ user_ids?: Array;
+}
+
+export interface UsageAudioTranscriptionsParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Return only usage for these API keys.
+ */
+ api_key_ids?: Array;
+
+ /**
+ * Width of each time bucket in response. Currently `1m`, `1h` and `1d` are
+ * supported, default to `1d`.
+ */
+ bucket_width?: '1m' | '1h' | '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * Group the usage data by the specified fields. Support fields include
+ * `project_id`, `user_id`, `api_key_id`, `model` or any combination of them.
+ */
+ group_by?: Array<'project_id' | 'user_id' | 'api_key_id' | 'model'>;
+
+ /**
+ * 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
+ */
+ limit?: number;
+
+ /**
+ * Return only usage for these models.
+ */
+ models?: Array;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only usage for these projects.
+ */
+ project_ids?: Array;
+
+ /**
+ * Return only usage for these users.
+ */
+ user_ids?: Array;
+}
+
+export interface UsageCodeInterpreterSessionsParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Width of each time bucket in response. Currently `1m`, `1h` and `1d` are
+ * supported, default to `1d`.
+ */
+ bucket_width?: '1m' | '1h' | '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * Group the usage data by the specified fields. Support fields include
+ * `project_id`.
+ */
+ group_by?: Array<'project_id'>;
+
+ /**
+ * Specifies the number of buckets to return.
+ *
+ * - `bucket_width=1d`: default: 7, max: 31
+ * - `bucket_width=1h`: default: 24, max: 168
+ * - `bucket_width=1m`: default: 60, max: 1440
+ */
+ limit?: number;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only usage for these projects.
+ */
+ project_ids?: Array;
+}
+
+export interface UsageCompletionsParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Return only usage for these API keys.
+ */
+ api_key_ids?: Array;
+
+ /**
+ * If `true`, return batch jobs only. If `false`, return non-batch jobs only. By
+ * default, return both.
+ */
+ batch?: boolean;
+
+ /**
+ * Width of each time bucket in response. Currently `1m`, `1h` and `1d` are
+ * supported, default to `1d`.
+ */
+ bucket_width?: '1m' | '1h' | '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * 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.
+ */
+ group_by?: Array<'project_id' | 'user_id' | 'api_key_id' | 'model' | 'batch' | 'service_tier'>;
+
+ /**
+ * 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
+ */
+ limit?: number;
+
+ /**
+ * Return only usage for these models.
+ */
+ models?: Array;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only usage for these projects.
+ */
+ project_ids?: Array;
+
+ /**
+ * Return only usage for these users.
+ */
+ user_ids?: Array;
+}
+
+export interface UsageCostsParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Return only costs for these API keys.
+ */
+ api_key_ids?: Array;
+
+ /**
+ * Width of each time bucket in response. Currently only `1d` is supported, default
+ * to `1d`.
+ */
+ bucket_width?: '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * Group the costs by the specified fields. Support fields include `project_id`,
+ * `line_item`, `api_key_id` and any combination of them.
+ */
+ group_by?: Array<'project_id' | 'line_item' | 'api_key_id'>;
+
+ /**
+ * A limit on the number of buckets to be returned. Limit can range between 1 and
+ * 180, and the default is 7.
+ */
+ limit?: number;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only costs for these projects.
+ */
+ project_ids?: Array;
+}
+
+export interface UsageEmbeddingsParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Return only usage for these API keys.
+ */
+ api_key_ids?: Array;
+
+ /**
+ * Width of each time bucket in response. Currently `1m`, `1h` and `1d` are
+ * supported, default to `1d`.
+ */
+ bucket_width?: '1m' | '1h' | '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * Group the usage data by the specified fields. Support fields include
+ * `project_id`, `user_id`, `api_key_id`, `model` or any combination of them.
+ */
+ group_by?: Array<'project_id' | 'user_id' | 'api_key_id' | 'model'>;
+
+ /**
+ * 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
+ */
+ limit?: number;
+
+ /**
+ * Return only usage for these models.
+ */
+ models?: Array;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only usage for these projects.
+ */
+ project_ids?: Array;
+
+ /**
+ * Return only usage for these users.
+ */
+ user_ids?: Array;
+}
+
+export interface UsageImagesParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Return only usage for these API keys.
+ */
+ api_key_ids?: Array;
+
+ /**
+ * Width of each time bucket in response. Currently `1m`, `1h` and `1d` are
+ * supported, default to `1d`.
+ */
+ bucket_width?: '1m' | '1h' | '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * 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.
+ */
+ group_by?: Array<'project_id' | 'user_id' | 'api_key_id' | 'model' | 'size' | 'source'>;
+
+ /**
+ * 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
+ */
+ limit?: number;
+
+ /**
+ * Return only usage for these models.
+ */
+ models?: Array;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only usage for these projects.
+ */
+ project_ids?: Array;
+
+ /**
+ * Return only usages for these image sizes. Possible values are `256x256`,
+ * `512x512`, `1024x1024`, `1792x1792`, `1024x1792` or any combination of them.
+ */
+ sizes?: Array<'256x256' | '512x512' | '1024x1024' | '1792x1792' | '1024x1792'>;
+
+ /**
+ * Return only usages for these sources. Possible values are `image.generation`,
+ * `image.edit`, `image.variation` or any combination of them.
+ */
+ sources?: Array<'image.generation' | 'image.edit' | 'image.variation'>;
+
+ /**
+ * Return only usage for these users.
+ */
+ user_ids?: Array;
+}
+
+export interface UsageModerationsParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Return only usage for these API keys.
+ */
+ api_key_ids?: Array;
+
+ /**
+ * Width of each time bucket in response. Currently `1m`, `1h` and `1d` are
+ * supported, default to `1d`.
+ */
+ bucket_width?: '1m' | '1h' | '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * Group the usage data by the specified fields. Support fields include
+ * `project_id`, `user_id`, `api_key_id`, `model` or any combination of them.
+ */
+ group_by?: Array<'project_id' | 'user_id' | 'api_key_id' | 'model'>;
+
+ /**
+ * 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
+ */
+ limit?: number;
+
+ /**
+ * Return only usage for these models.
+ */
+ models?: Array;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only usage for these projects.
+ */
+ project_ids?: Array;
+
+ /**
+ * Return only usage for these users.
+ */
+ user_ids?: Array;
+}
+
+export interface UsageVectorStoresParams {
+ /**
+ * Start time (Unix seconds) of the query time range, inclusive.
+ */
+ start_time: number;
+
+ /**
+ * Width of each time bucket in response. Currently `1m`, `1h` and `1d` are
+ * supported, default to `1d`.
+ */
+ bucket_width?: '1m' | '1h' | '1d';
+
+ /**
+ * End time (Unix seconds) of the query time range, exclusive.
+ */
+ end_time?: number;
+
+ /**
+ * Group the usage data by the specified fields. Support fields include
+ * `project_id`.
+ */
+ group_by?: Array<'project_id'>;
+
+ /**
+ * Specifies the number of buckets to return.
+ *
+ * - `bucket_width=1d`: default: 7, max: 31
+ * - `bucket_width=1h`: default: 24, max: 168
+ * - `bucket_width=1m`: default: 60, max: 1440
+ */
+ limit?: number;
+
+ /**
+ * A cursor for use in pagination. Corresponding to the `next_page` field from the
+ * previous response.
+ */
+ page?: string;
+
+ /**
+ * Return only usage for these projects.
+ */
+ project_ids?: Array;
+}
+
+export declare namespace Usage {
+ export {
+ type UsageAudioSpeechesResponse as UsageAudioSpeechesResponse,
+ type UsageAudioTranscriptionsResponse as UsageAudioTranscriptionsResponse,
+ type UsageCodeInterpreterSessionsResponse as UsageCodeInterpreterSessionsResponse,
+ type UsageCompletionsResponse as UsageCompletionsResponse,
+ type UsageCostsResponse as UsageCostsResponse,
+ type UsageEmbeddingsResponse as UsageEmbeddingsResponse,
+ type UsageImagesResponse as UsageImagesResponse,
+ type UsageModerationsResponse as UsageModerationsResponse,
+ type UsageVectorStoresResponse as UsageVectorStoresResponse,
+ type UsageAudioSpeechesParams as UsageAudioSpeechesParams,
+ type UsageAudioTranscriptionsParams as UsageAudioTranscriptionsParams,
+ type UsageCodeInterpreterSessionsParams as UsageCodeInterpreterSessionsParams,
+ type UsageCompletionsParams as UsageCompletionsParams,
+ type UsageCostsParams as UsageCostsParams,
+ type UsageEmbeddingsParams as UsageEmbeddingsParams,
+ type UsageImagesParams as UsageImagesParams,
+ type UsageModerationsParams as UsageModerationsParams,
+ type UsageVectorStoresParams as UsageVectorStoresParams,
+ };
+}
diff --git a/src/resources/admin/organization/users.ts b/src/resources/admin/organization/users.ts
new file mode 100644
index 0000000000..db908c701b
--- /dev/null
+++ b/src/resources/admin/organization/users.ts
@@ -0,0 +1,3 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export * from './users/index';
diff --git a/src/resources/admin/organization/users/index.ts b/src/resources/admin/organization/users/index.ts
new file mode 100644
index 0000000000..2bc2196b56
--- /dev/null
+++ b/src/resources/admin/organization/users/index.ts
@@ -0,0 +1,20 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+export {
+ Roles,
+ type RoleCreateResponse,
+ type RoleListResponse,
+ type RoleDeleteResponse,
+ type RoleCreateParams,
+ type RoleListParams,
+ type RoleDeleteParams,
+ type RoleListResponsesPage,
+} from './roles';
+export {
+ Users,
+ type OrganizationUser,
+ type UserDeleteResponse,
+ type UserUpdateParams,
+ type UserListParams,
+ type OrganizationUsersPage,
+} from './users';
diff --git a/src/resources/admin/organization/users/roles.ts b/src/resources/admin/organization/users/roles.ts
new file mode 100644
index 0000000000..a5bcf39f72
--- /dev/null
+++ b/src/resources/admin/organization/users/roles.ts
@@ -0,0 +1,208 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import * as RolesAPI from '../roles';
+import * as UsersAPI from './users';
+import { APIPromise } from '../../../../core/api-promise';
+import { NextCursorPage, type NextCursorPageParams, PagePromise } from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class Roles extends APIResource {
+ /**
+ * Assigns an organization role to a user within the organization.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.users.roles.create(
+ * 'user_id',
+ * { role_id: 'role_id' },
+ * );
+ * ```
+ */
+ create(userID: string, body: RoleCreateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/users/${userID}/roles`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists the organization roles assigned to a user within the organization.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const roleListResponse of client.admin.organization.users.roles.list(
+ * 'user_id',
+ * )) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ userID: string,
+ query: RoleListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList(
+ path`/organization/users/${userID}/roles`,
+ NextCursorPage,
+ { query, ...options, __security: { adminAPIKeyAuth: true } },
+ );
+ }
+
+ /**
+ * Unassigns an organization role from a user within the organization.
+ *
+ * @example
+ * ```ts
+ * const role =
+ * await client.admin.organization.users.roles.delete(
+ * 'role_id',
+ * { user_id: 'user_id' },
+ * );
+ * ```
+ */
+ delete(roleID: string, params: RoleDeleteParams, options?: RequestOptions): APIPromise {
+ const { user_id } = params;
+ return this._client.delete(path`/organization/users/${user_id}/roles/${roleID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type RoleListResponsesPage = NextCursorPage;
+
+/**
+ * Role assignment linking a user to a role.
+ */
+export interface RoleCreateResponse {
+ /**
+ * Always `user.role`.
+ */
+ object: 'user.role';
+
+ /**
+ * Details about a role that can be assigned through the public Roles API.
+ */
+ role: RolesAPI.Role;
+
+ /**
+ * Represents an individual `user` within an organization.
+ */
+ user: UsersAPI.OrganizationUser;
+}
+
+/**
+ * Detailed information about a role assignment entry returned when listing
+ * assignments.
+ */
+export interface RoleListResponse {
+ /**
+ * Identifier for the role.
+ */
+ id: string;
+
+ /**
+ * When the role was created.
+ */
+ created_at: number | null;
+
+ /**
+ * Identifier of the actor who created the role.
+ */
+ created_by: string | null;
+
+ /**
+ * User details for the actor that created the role, when available.
+ */
+ created_by_user_obj: { [key: string]: unknown } | null;
+
+ /**
+ * Description of the role.
+ */
+ description: string | null;
+
+ /**
+ * Arbitrary metadata stored on the role.
+ */
+ metadata: { [key: string]: unknown } | null;
+
+ /**
+ * Name of the role.
+ */
+ name: string;
+
+ /**
+ * Permissions associated with the role.
+ */
+ permissions: Array;
+
+ /**
+ * Whether the role is predefined by OpenAI.
+ */
+ predefined_role: boolean;
+
+ /**
+ * Resource type the role applies to.
+ */
+ resource_type: string;
+
+ /**
+ * When the role was last updated.
+ */
+ updated_at: number | null;
+}
+
+/**
+ * Confirmation payload returned after unassigning a role.
+ */
+export interface RoleDeleteResponse {
+ /**
+ * Whether the assignment was removed.
+ */
+ deleted: boolean;
+
+ /**
+ * Identifier for the deleted assignment, such as `group.role.deleted` or
+ * `user.role.deleted`.
+ */
+ object: string;
+}
+
+export interface RoleCreateParams {
+ /**
+ * Identifier of the role to assign.
+ */
+ role_id: string;
+}
+
+export interface RoleListParams extends NextCursorPageParams {
+ /**
+ * Sort order for the returned organization roles.
+ */
+ order?: 'asc' | 'desc';
+}
+
+export interface RoleDeleteParams {
+ /**
+ * The ID of the user to modify.
+ */
+ user_id: string;
+}
+
+export declare namespace Roles {
+ export {
+ type RoleCreateResponse as RoleCreateResponse,
+ type RoleListResponse as RoleListResponse,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleListResponsesPage as RoleListResponsesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
diff --git a/src/resources/admin/organization/users/users.ts b/src/resources/admin/organization/users/users.ts
new file mode 100644
index 0000000000..df9f081d62
--- /dev/null
+++ b/src/resources/admin/organization/users/users.ts
@@ -0,0 +1,180 @@
+// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
+
+import { APIResource } from '../../../../core/resource';
+import * as RolesAPI from './roles';
+import {
+ RoleCreateParams,
+ RoleCreateResponse,
+ RoleDeleteParams,
+ RoleDeleteResponse,
+ RoleListParams,
+ RoleListResponse,
+ RoleListResponsesPage,
+ Roles,
+} from './roles';
+import { APIPromise } from '../../../../core/api-promise';
+import {
+ ConversationCursorPage,
+ type ConversationCursorPageParams,
+ PagePromise,
+} from '../../../../core/pagination';
+import { RequestOptions } from '../../../../internal/request-options';
+import { path } from '../../../../internal/utils/path';
+
+export class Users extends APIResource {
+ roles: RolesAPI.Roles = new RolesAPI.Roles(this._client);
+
+ /**
+ * Retrieves a user by their identifier.
+ *
+ * @example
+ * ```ts
+ * const organizationUser =
+ * await client.admin.organization.users.retrieve('user_id');
+ * ```
+ */
+ retrieve(userID: string, options?: RequestOptions): APIPromise {
+ return this._client.get(path`/organization/users/${userID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Modifies a user's role in the organization.
+ *
+ * @example
+ * ```ts
+ * const organizationUser =
+ * await client.admin.organization.users.update('user_id');
+ * ```
+ */
+ update(userID: string, body: UserUpdateParams, options?: RequestOptions): APIPromise {
+ return this._client.post(path`/organization/users/${userID}`, {
+ body,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Lists all of the users in the organization.
+ *
+ * @example
+ * ```ts
+ * // Automatically fetches more pages as needed.
+ * for await (const organizationUser of client.admin.organization.users.list()) {
+ * // ...
+ * }
+ * ```
+ */
+ list(
+ query: UserListParams | null | undefined = {},
+ options?: RequestOptions,
+ ): PagePromise {
+ return this._client.getAPIList('/organization/users', ConversationCursorPage, {
+ query,
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+
+ /**
+ * Deletes a user from the organization.
+ *
+ * @example
+ * ```ts
+ * const user = await client.admin.organization.users.delete(
+ * 'user_id',
+ * );
+ * ```
+ */
+ delete(userID: string, options?: RequestOptions): APIPromise {
+ return this._client.delete(path`/organization/users/${userID}`, {
+ ...options,
+ __security: { adminAPIKeyAuth: true },
+ });
+ }
+}
+
+export type OrganizationUsersPage = ConversationCursorPage;
+
+/**
+ * Represents an individual `user` within an organization.
+ */
+export interface OrganizationUser {
+ /**
+ * The identifier, which can be referenced in API endpoints
+ */
+ id: string;
+
+ /**
+ * The Unix timestamp (in seconds) of when the user was added.
+ */
+ added_at: number;
+
+ /**
+ * The email address of the user
+ */
+ email: string;
+
+ /**
+ * The name of the user
+ */
+ name: string;
+
+ /**
+ * The object type, which is always `organization.user`
+ */
+ object: 'organization.user';
+
+ /**
+ * `owner` or `reader`
+ */
+ role: 'owner' | 'reader';
+}
+
+export interface UserDeleteResponse {
+ id: string;
+
+ deleted: boolean;
+
+ object: 'organization.user.deleted';
+}
+
+export interface UserUpdateParams {
+ /**
+ * `owner` or `reader`
+ */
+ role?: 'owner' | 'reader';
+}
+
+export interface UserListParams extends ConversationCursorPageParams {
+ /**
+ * Filter by the email address of users.
+ */
+ emails?: Array;
+}
+
+Users.Roles = Roles;
+
+export declare namespace Users {
+ export {
+ type OrganizationUser as OrganizationUser,
+ type UserDeleteResponse as UserDeleteResponse,
+ type OrganizationUsersPage as OrganizationUsersPage,
+ type UserUpdateParams as UserUpdateParams,
+ type UserListParams as UserListParams,
+ };
+
+ export {
+ Roles as Roles,
+ type RoleCreateResponse as RoleCreateResponse,
+ type RoleListResponse as RoleListResponse,
+ type RoleDeleteResponse as RoleDeleteResponse,
+ type RoleListResponsesPage as RoleListResponsesPage,
+ type RoleCreateParams as RoleCreateParams,
+ type RoleListParams as RoleListParams,
+ type RoleDeleteParams as RoleDeleteParams,
+ };
+}
diff --git a/src/resources/audio/speech.ts b/src/resources/audio/speech.ts
index 657a3ca82b..7a95ae7129 100644
--- a/src/resources/audio/speech.ts
+++ b/src/resources/audio/speech.ts
@@ -31,6 +31,7 @@ export class Speech extends APIResource {
body,
...options,
headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]),
+ __security: { bearerAuth: true },
__binaryResponse: true,
});
}
diff --git a/src/resources/audio/transcriptions.ts b/src/resources/audio/transcriptions.ts
index 4c3f2da65d..1a1fcf5120 100644
--- a/src/resources/audio/transcriptions.ts
+++ b/src/resources/audio/transcriptions.ts
@@ -61,6 +61,7 @@ export class Transcriptions extends APIResource {
...options,
stream: body.stream ?? false,
__metadata: { model: body.model },
+ __security: { bearerAuth: true },
},
this._client,
),
diff --git a/src/resources/audio/translations.ts b/src/resources/audio/translations.ts
index c043bc4b4f..2217461a0f 100644
--- a/src/resources/audio/translations.ts
+++ b/src/resources/audio/translations.ts
@@ -39,7 +39,10 @@ export class Translations extends APIResource {
): APIPromise {
return this._client.post(
'/audio/translations',
- multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model } }, this._client),
+ multipartFormRequestOptions(
+ { body, ...options, __metadata: { model: body.model }, __security: { bearerAuth: true } },
+ this._client,
+ ),
);
}
}
diff --git a/src/resources/batches.ts b/src/resources/batches.ts
index 37f3ef45af..ad07c1a7d1 100644
--- a/src/resources/batches.ts
+++ b/src/resources/batches.ts
@@ -16,14 +16,14 @@ export class Batches extends APIResource {
* Creates and executes a batch from an uploaded file of requests
*/
create(body: BatchCreateParams, options?: RequestOptions): APIPromise {
- return this._client.post('/batches', { body, ...options });
+ return this._client.post('/batches', { body, ...options, __security: { bearerAuth: true } });
}
/**
* Retrieves a batch.
*/
retrieve(batchID: string, options?: RequestOptions): APIPromise {
- return this._client.get(path`/batches/${batchID}`, options);
+ return this._client.get(path`/batches/${batchID}`, { ...options, __security: { bearerAuth: true } });
}
/**
@@ -33,7 +33,11 @@ export class Batches extends APIResource {
query: BatchListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise {
- return this._client.getAPIList('/batches', CursorPage, { query, ...options });
+ return this._client.getAPIList('/batches', CursorPage, {
+ query,
+ ...options,
+ __security: { bearerAuth: true },
+ });
}
/**
@@ -42,7 +46,10 @@ export class Batches extends APIResource {
* (if any) available in the output file.
*/
cancel(batchID: string, options?: RequestOptions): APIPromise {
- return this._client.post(path`/batches/${batchID}/cancel`, options);
+ return this._client.post(path`/batches/${batchID}/cancel`, {
+ ...options,
+ __security: { bearerAuth: true },
+ });
}
}
diff --git a/src/resources/beta/assistants.ts b/src/resources/beta/assistants.ts
index d2ea3c04c0..ead0b3f6ff 100644
--- a/src/resources/beta/assistants.ts
+++ b/src/resources/beta/assistants.ts
@@ -27,6 +27,7 @@ export class Assistants extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -39,6 +40,7 @@ export class Assistants extends APIResource {
return this._client.get(path`/assistants/${assistantID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -52,6 +54,7 @@ export class Assistants extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -68,6 +71,7 @@ export class Assistants extends APIResource {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -80,6 +84,7 @@ export class Assistants extends APIResource {
return this._client.delete(path`/assistants/${assistantID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
}
diff --git a/src/resources/beta/chatkit/sessions.ts b/src/resources/beta/chatkit/sessions.ts
index 6c10d29315..995bf53e84 100644
--- a/src/resources/beta/chatkit/sessions.ts
+++ b/src/resources/beta/chatkit/sessions.ts
@@ -25,6 +25,7 @@ export class Sessions extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -43,6 +44,7 @@ export class Sessions extends APIResource {
return this._client.post(path`/chatkit/sessions/${sessionID}/cancel`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
}
diff --git a/src/resources/beta/chatkit/threads.ts b/src/resources/beta/chatkit/threads.ts
index 58c16d12f9..6a50faa6f0 100644
--- a/src/resources/beta/chatkit/threads.ts
+++ b/src/resources/beta/chatkit/threads.ts
@@ -26,6 +26,7 @@ export class Threads extends APIResource {
return this._client.get(path`/chatkit/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -48,6 +49,7 @@ export class Threads extends APIResource {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -65,6 +67,7 @@ export class Threads extends APIResource {
return this._client.delete(path`/chatkit/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -104,7 +107,12 @@ export class Threads extends APIResource {
| ChatKitThreadItemList.ChatKitTask
| ChatKitThreadItemList.ChatKitTaskGroup
>,
- { query, ...options, headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]) },
+ {
+ query,
+ ...options,
+ headers: buildHeaders([{ 'OpenAI-Beta': 'chatkit_beta=v1' }, options?.headers]),
+ __security: { bearerAuth: true },
+ },
);
}
}
diff --git a/src/resources/beta/realtime/sessions.ts b/src/resources/beta/realtime/sessions.ts
index fbcb23ae15..753934692f 100644
--- a/src/resources/beta/realtime/sessions.ts
+++ b/src/resources/beta/realtime/sessions.ts
@@ -26,6 +26,7 @@ export class Sessions extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
}
diff --git a/src/resources/beta/realtime/transcription-sessions.ts b/src/resources/beta/realtime/transcription-sessions.ts
index 8542f69b6a..c1a76ed647 100644
--- a/src/resources/beta/realtime/transcription-sessions.ts
+++ b/src/resources/beta/realtime/transcription-sessions.ts
@@ -26,6 +26,7 @@ export class TranscriptionSessions extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
}
diff --git a/src/resources/beta/threads/messages.ts b/src/resources/beta/threads/messages.ts
index c98c984dad..238cb37095 100644
--- a/src/resources/beta/threads/messages.ts
+++ b/src/resources/beta/threads/messages.ts
@@ -25,6 +25,7 @@ export class Messages extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -38,6 +39,7 @@ export class Messages extends APIResource {
return this._client.get(path`/threads/${thread_id}/messages/${messageID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -52,6 +54,7 @@ export class Messages extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -69,6 +72,7 @@ export class Messages extends APIResource {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -86,6 +90,7 @@ export class Messages extends APIResource {
return this._client.delete(path`/threads/${thread_id}/messages/${messageID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
}
diff --git a/src/resources/beta/threads/runs/runs.ts b/src/resources/beta/threads/runs/runs.ts
index c47fd5cb4a..5b70d0e1dc 100644
--- a/src/resources/beta/threads/runs/runs.ts
+++ b/src/resources/beta/threads/runs/runs.ts
@@ -78,6 +78,7 @@ export class Runs extends APIResource {
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: params.stream ?? false,
__synthesizeEventData: true,
+ __security: { bearerAuth: true },
}) as APIPromise | APIPromise>;
}
@@ -91,6 +92,7 @@ export class Runs extends APIResource {
return this._client.get(path`/threads/${thread_id}/runs/${runID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -105,6 +107,7 @@ export class Runs extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -122,6 +125,7 @@ export class Runs extends APIResource {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -135,6 +139,7 @@ export class Runs extends APIResource {
return this._client.post(path`/threads/${thread_id}/runs/${runID}/cancel`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -263,6 +268,7 @@ export class Runs extends APIResource {
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: params.stream ?? false,
__synthesizeEventData: true,
+ __security: { bearerAuth: true },
}) as APIPromise | APIPromise>;
}
diff --git a/src/resources/beta/threads/runs/steps.ts b/src/resources/beta/threads/runs/steps.ts
index 4e43f5d7e7..d6155e1ae2 100644
--- a/src/resources/beta/threads/runs/steps.ts
+++ b/src/resources/beta/threads/runs/steps.ts
@@ -26,6 +26,7 @@ export class Steps extends APIResource {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -40,6 +41,7 @@ export class Steps extends APIResource {
query,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
}
diff --git a/src/resources/beta/threads/threads.ts b/src/resources/beta/threads/threads.ts
index 2cab55e691..9a97b5772f 100644
--- a/src/resources/beta/threads/threads.ts
+++ b/src/resources/beta/threads/threads.ts
@@ -91,6 +91,7 @@ export class Threads extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -103,6 +104,7 @@ export class Threads extends APIResource {
return this._client.get(path`/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -116,6 +118,7 @@ export class Threads extends APIResource {
body,
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -128,6 +131,7 @@ export class Threads extends APIResource {
return this._client.delete(path`/threads/${threadID}`, {
...options,
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
+ __security: { bearerAuth: true },
});
}
@@ -155,6 +159,7 @@ export class Threads extends APIResource {
headers: buildHeaders([{ 'OpenAI-Beta': 'assistants=v2' }, options?.headers]),
stream: body.stream ?? false,
__synthesizeEventData: true,
+ __security: { bearerAuth: true },
}) as APIPromise | APIPromise>;
}
diff --git a/src/resources/chat/completions/completions.ts b/src/resources/chat/completions/completions.ts
index efc491e6c9..659db26ee3 100644
--- a/src/resources/chat/completions/completions.ts
+++ b/src/resources/chat/completions/completions.ts
@@ -71,9 +71,12 @@ export class Completions extends APIResource {
body: ChatCompletionCreateParams,
options?: RequestOptions,
): APIPromise | APIPromise> {
- return this._client.post('/chat/completions', { body, ...options, stream: body.stream ?? false }) as
- | APIPromise
- | APIPromise>;
+ return this._client.post('/chat/completions', {
+ body,
+ ...options,
+ stream: body.stream ?? false,
+ __security: { bearerAuth: true },
+ }) as APIPromise | APIPromise>;
}
/**
@@ -87,7 +90,10 @@ export class Completions extends APIResource {
* ```
*/
retrieve(completionID: string, options?: RequestOptions): APIPromise {
- return this._client.get(path`/chat/completions/${completionID}`, options);
+ return this._client.get(path`/chat/completions/${completionID}`, {
+ ...options,
+ __security: { bearerAuth: true },
+ });
}
/**
@@ -108,7 +114,11 @@ export class Completions extends APIResource {
body: ChatCompletionUpdateParams,
options?: RequestOptions,
): APIPromise {
- return this._client.post(path`/chat/completions/${completionID}`, { body, ...options });
+ return this._client.post(path`/chat/completions/${completionID}`, {
+ body,
+ ...options,
+ __security: { bearerAuth: true },
+ });
}
/**
@@ -127,7 +137,11 @@ export class Completions extends APIResource {
query: ChatCompletionListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise {
- return this._client.getAPIList('/chat/completions', CursorPage, { query, ...options });
+ return this._client.getAPIList('/chat/completions', CursorPage, {
+ query,
+ ...options,
+ __security: { bearerAuth: true },
+ });
}
/**
@@ -141,7 +155,10 @@ export class Completions extends APIResource {
* ```
*/
delete(completionID: string, options?: RequestOptions): APIPromise {
- return this._client.delete(path`/chat/completions/${completionID}`, options);
+ return this._client.delete(path`/chat/completions/${completionID}`, {
+ ...options,
+ __security: { bearerAuth: true },
+ });
}
parse>(
diff --git a/src/resources/chat/completions/messages.ts b/src/resources/chat/completions/messages.ts
index 4965212415..692454f4ee 100644
--- a/src/resources/chat/completions/messages.ts
+++ b/src/resources/chat/completions/messages.ts
@@ -33,7 +33,7 @@ export class Messages extends APIResource {
return this._client.getAPIList(
path`/chat/completions/${completionID}/messages`,
CursorPage,
- { query, ...options },
+ { query, ...options, __security: { bearerAuth: true } },
);
}
}
diff --git a/src/resources/completions.ts b/src/resources/completions.ts
index a22f1c2f12..5ae88abe85 100644
--- a/src/resources/completions.ts
+++ b/src/resources/completions.ts
@@ -35,9 +35,12 @@ export class Completions extends APIResource {
body: CompletionCreateParams,
options?: RequestOptions,
): APIPromise | APIPromise> {
- return this._client.post('/completions', { body, ...options, stream: body.stream ?? false }) as
- | APIPromise
- | APIPromise>;
+ return this._client.post('/completions', {
+ body,
+ ...options,
+ stream: body.stream ?? false,
+ __security: { bearerAuth: true },
+ }) as APIPromise | APIPromise>;
}
}
diff --git a/src/resources/containers/containers.ts b/src/resources/containers/containers.ts
index 50b839609a..8dab197920 100644
--- a/src/resources/containers/containers.ts
+++ b/src/resources/containers/containers.ts
@@ -27,14 +27,17 @@ export class Containers extends APIResource {
* Create Container
*/
create(body: ContainerCreateParams, options?: RequestOptions): APIPromise