SpyBara
Go Premium

go/resources/admin/index.md 2026-05-05 23:00 UTC to 2026-05-07 21:57 UTC

36 added, 0 removed.

2026
Wed 27 06:42 Fri 22 06:33 Wed 20 06:35 Tue 19 06:34 Mon 18 22:01 Mon 11 18:00 Thu 7 21:57 Tue 5 23:00 Sat 2 05:57

Admin

Organization

Audit Logs

List audit logs

client.Admin.Organization.AuditLogs.List(ctx, query) (*ConversationCursorPage[AdminOrganizationAuditLogListResponse], error)

get /organization/audit_logs

List user actions and configuration changes within this organization.

Parameters

  • query AdminOrganizationAuditLogListParams

    • ActorEmails param.Field[[]string]

      Return only events performed by users with these emails.

    • ActorIDs param.Field[[]string]

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

    • After param.Field[string]

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

    • Before param.Field[string]

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

    • EffectiveAt param.Field[AdminOrganizationAuditLogListParamsEffectiveAt]

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

      • Gt int64

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

      • Gte int64

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

      • Lt int64

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

      • Lte int64

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

    • EventTypes param.Field[[]string]

      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.

      • const AdminOrganizationAuditLogListParamsEventTypeAPIKeyCreated AdminOrganizationAuditLogListParamsEventType = "api_key.created"

      • const AdminOrganizationAuditLogListParamsEventTypeAPIKeyUpdated AdminOrganizationAuditLogListParamsEventType = "api_key.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeAPIKeyDeleted AdminOrganizationAuditLogListParamsEventType = "api_key.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeCertificateCreated AdminOrganizationAuditLogListParamsEventType = "certificate.created"

      • const AdminOrganizationAuditLogListParamsEventTypeCertificateUpdated AdminOrganizationAuditLogListParamsEventType = "certificate.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeCertificateDeleted AdminOrganizationAuditLogListParamsEventType = "certificate.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeCertificatesActivated AdminOrganizationAuditLogListParamsEventType = "certificates.activated"

      • const AdminOrganizationAuditLogListParamsEventTypeCertificatesDeactivated AdminOrganizationAuditLogListParamsEventType = "certificates.deactivated"

      • const AdminOrganizationAuditLogListParamsEventTypeCheckpointPermissionCreated AdminOrganizationAuditLogListParamsEventType = "checkpoint.permission.created"

      • const AdminOrganizationAuditLogListParamsEventTypeCheckpointPermissionDeleted AdminOrganizationAuditLogListParamsEventType = "checkpoint.permission.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeExternalKeyRegistered AdminOrganizationAuditLogListParamsEventType = "external_key.registered"

      • const AdminOrganizationAuditLogListParamsEventTypeExternalKeyRemoved AdminOrganizationAuditLogListParamsEventType = "external_key.removed"

      • const AdminOrganizationAuditLogListParamsEventTypeGroupCreated AdminOrganizationAuditLogListParamsEventType = "group.created"

      • const AdminOrganizationAuditLogListParamsEventTypeGroupUpdated AdminOrganizationAuditLogListParamsEventType = "group.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeGroupDeleted AdminOrganizationAuditLogListParamsEventType = "group.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeInviteSent AdminOrganizationAuditLogListParamsEventType = "invite.sent"

      • const AdminOrganizationAuditLogListParamsEventTypeInviteAccepted AdminOrganizationAuditLogListParamsEventType = "invite.accepted"

      • const AdminOrganizationAuditLogListParamsEventTypeInviteDeleted AdminOrganizationAuditLogListParamsEventType = "invite.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeIPAllowlistCreated AdminOrganizationAuditLogListParamsEventType = "ip_allowlist.created"

      • const AdminOrganizationAuditLogListParamsEventTypeIPAllowlistUpdated AdminOrganizationAuditLogListParamsEventType = "ip_allowlist.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeIPAllowlistDeleted AdminOrganizationAuditLogListParamsEventType = "ip_allowlist.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeIPAllowlistConfigActivated AdminOrganizationAuditLogListParamsEventType = "ip_allowlist.config.activated"

      • const AdminOrganizationAuditLogListParamsEventTypeIPAllowlistConfigDeactivated AdminOrganizationAuditLogListParamsEventType = "ip_allowlist.config.deactivated"

      • const AdminOrganizationAuditLogListParamsEventTypeLoginSucceeded AdminOrganizationAuditLogListParamsEventType = "login.succeeded"

      • const AdminOrganizationAuditLogListParamsEventTypeLoginFailed AdminOrganizationAuditLogListParamsEventType = "login.failed"

      • const AdminOrganizationAuditLogListParamsEventTypeLogoutSucceeded AdminOrganizationAuditLogListParamsEventType = "logout.succeeded"

      • const AdminOrganizationAuditLogListParamsEventTypeLogoutFailed AdminOrganizationAuditLogListParamsEventType = "logout.failed"

      • const AdminOrganizationAuditLogListParamsEventTypeOrganizationUpdated AdminOrganizationAuditLogListParamsEventType = "organization.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeProjectCreated AdminOrganizationAuditLogListParamsEventType = "project.created"

      • const AdminOrganizationAuditLogListParamsEventTypeProjectUpdated AdminOrganizationAuditLogListParamsEventType = "project.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeProjectArchived AdminOrganizationAuditLogListParamsEventType = "project.archived"

      • const AdminOrganizationAuditLogListParamsEventTypeProjectDeleted AdminOrganizationAuditLogListParamsEventType = "project.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeRateLimitUpdated AdminOrganizationAuditLogListParamsEventType = "rate_limit.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeRateLimitDeleted AdminOrganizationAuditLogListParamsEventType = "rate_limit.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeResourceDeleted AdminOrganizationAuditLogListParamsEventType = "resource.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeTunnelCreated AdminOrganizationAuditLogListParamsEventType = "tunnel.created"

      • const AdminOrganizationAuditLogListParamsEventTypeTunnelUpdated AdminOrganizationAuditLogListParamsEventType = "tunnel.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeTunnelDeleted AdminOrganizationAuditLogListParamsEventType = "tunnel.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeRoleCreated AdminOrganizationAuditLogListParamsEventType = "role.created"

      • const AdminOrganizationAuditLogListParamsEventTypeRoleUpdated AdminOrganizationAuditLogListParamsEventType = "role.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeRoleDeleted AdminOrganizationAuditLogListParamsEventType = "role.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeRoleAssignmentCreated AdminOrganizationAuditLogListParamsEventType = "role.assignment.created"

      • const AdminOrganizationAuditLogListParamsEventTypeRoleAssignmentDeleted AdminOrganizationAuditLogListParamsEventType = "role.assignment.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeScimEnabled AdminOrganizationAuditLogListParamsEventType = "scim.enabled"

      • const AdminOrganizationAuditLogListParamsEventTypeScimDisabled AdminOrganizationAuditLogListParamsEventType = "scim.disabled"

      • const AdminOrganizationAuditLogListParamsEventTypeServiceAccountCreated AdminOrganizationAuditLogListParamsEventType = "service_account.created"

      • const AdminOrganizationAuditLogListParamsEventTypeServiceAccountUpdated AdminOrganizationAuditLogListParamsEventType = "service_account.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeServiceAccountDeleted AdminOrganizationAuditLogListParamsEventType = "service_account.deleted"

      • const AdminOrganizationAuditLogListParamsEventTypeUserAdded AdminOrganizationAuditLogListParamsEventType = "user.added"

      • const AdminOrganizationAuditLogListParamsEventTypeUserUpdated AdminOrganizationAuditLogListParamsEventType = "user.updated"

      • const AdminOrganizationAuditLogListParamsEventTypeUserDeleted AdminOrganizationAuditLogListParamsEventType = "user.deleted"

    • Limit param.Field[int64]

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

    • ProjectIDs param.Field[[]string]

      Return only events for these projects.

    • ResourceIDs param.Field[[]string]

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

Returns

  • type AdminOrganizationAuditLogListResponse struct{…}

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

    • ID string

      The ID of this log.

    • EffectiveAt int64

      The Unix timestamp (in seconds) of the event.

    • Type AdminOrganizationAuditLogListResponseType

      The event type.

      • const AdminOrganizationAuditLogListResponseTypeAPIKeyCreated AdminOrganizationAuditLogListResponseType = "api_key.created"

      • const AdminOrganizationAuditLogListResponseTypeAPIKeyUpdated AdminOrganizationAuditLogListResponseType = "api_key.updated"

      • const AdminOrganizationAuditLogListResponseTypeAPIKeyDeleted AdminOrganizationAuditLogListResponseType = "api_key.deleted"

      • const AdminOrganizationAuditLogListResponseTypeCertificateCreated AdminOrganizationAuditLogListResponseType = "certificate.created"

      • const AdminOrganizationAuditLogListResponseTypeCertificateUpdated AdminOrganizationAuditLogListResponseType = "certificate.updated"

      • const AdminOrganizationAuditLogListResponseTypeCertificateDeleted AdminOrganizationAuditLogListResponseType = "certificate.deleted"

      • const AdminOrganizationAuditLogListResponseTypeCertificatesActivated AdminOrganizationAuditLogListResponseType = "certificates.activated"

      • const AdminOrganizationAuditLogListResponseTypeCertificatesDeactivated AdminOrganizationAuditLogListResponseType = "certificates.deactivated"

      • const AdminOrganizationAuditLogListResponseTypeCheckpointPermissionCreated AdminOrganizationAuditLogListResponseType = "checkpoint.permission.created"

      • const AdminOrganizationAuditLogListResponseTypeCheckpointPermissionDeleted AdminOrganizationAuditLogListResponseType = "checkpoint.permission.deleted"

      • const AdminOrganizationAuditLogListResponseTypeExternalKeyRegistered AdminOrganizationAuditLogListResponseType = "external_key.registered"

      • const AdminOrganizationAuditLogListResponseTypeExternalKeyRemoved AdminOrganizationAuditLogListResponseType = "external_key.removed"

      • const AdminOrganizationAuditLogListResponseTypeGroupCreated AdminOrganizationAuditLogListResponseType = "group.created"

      • const AdminOrganizationAuditLogListResponseTypeGroupUpdated AdminOrganizationAuditLogListResponseType = "group.updated"

      • const AdminOrganizationAuditLogListResponseTypeGroupDeleted AdminOrganizationAuditLogListResponseType = "group.deleted"

      • const AdminOrganizationAuditLogListResponseTypeInviteSent AdminOrganizationAuditLogListResponseType = "invite.sent"

      • const AdminOrganizationAuditLogListResponseTypeInviteAccepted AdminOrganizationAuditLogListResponseType = "invite.accepted"

      • const AdminOrganizationAuditLogListResponseTypeInviteDeleted AdminOrganizationAuditLogListResponseType = "invite.deleted"

      • const AdminOrganizationAuditLogListResponseTypeIPAllowlistCreated AdminOrganizationAuditLogListResponseType = "ip_allowlist.created"

      • const AdminOrganizationAuditLogListResponseTypeIPAllowlistUpdated AdminOrganizationAuditLogListResponseType = "ip_allowlist.updated"

      • const AdminOrganizationAuditLogListResponseTypeIPAllowlistDeleted AdminOrganizationAuditLogListResponseType = "ip_allowlist.deleted"

      • const AdminOrganizationAuditLogListResponseTypeIPAllowlistConfigActivated AdminOrganizationAuditLogListResponseType = "ip_allowlist.config.activated"

      • const AdminOrganizationAuditLogListResponseTypeIPAllowlistConfigDeactivated AdminOrganizationAuditLogListResponseType = "ip_allowlist.config.deactivated"

      • const AdminOrganizationAuditLogListResponseTypeLoginSucceeded AdminOrganizationAuditLogListResponseType = "login.succeeded"

      • const AdminOrganizationAuditLogListResponseTypeLoginFailed AdminOrganizationAuditLogListResponseType = "login.failed"

      • const AdminOrganizationAuditLogListResponseTypeLogoutSucceeded AdminOrganizationAuditLogListResponseType = "logout.succeeded"

      • const AdminOrganizationAuditLogListResponseTypeLogoutFailed AdminOrganizationAuditLogListResponseType = "logout.failed"

      • const AdminOrganizationAuditLogListResponseTypeOrganizationUpdated AdminOrganizationAuditLogListResponseType = "organization.updated"

      • const AdminOrganizationAuditLogListResponseTypeProjectCreated AdminOrganizationAuditLogListResponseType = "project.created"

      • const AdminOrganizationAuditLogListResponseTypeProjectUpdated AdminOrganizationAuditLogListResponseType = "project.updated"

      • const AdminOrganizationAuditLogListResponseTypeProjectArchived AdminOrganizationAuditLogListResponseType = "project.archived"

      • const AdminOrganizationAuditLogListResponseTypeProjectDeleted AdminOrganizationAuditLogListResponseType = "project.deleted"

      • const AdminOrganizationAuditLogListResponseTypeRateLimitUpdated AdminOrganizationAuditLogListResponseType = "rate_limit.updated"

      • const AdminOrganizationAuditLogListResponseTypeRateLimitDeleted AdminOrganizationAuditLogListResponseType = "rate_limit.deleted"

      • const AdminOrganizationAuditLogListResponseTypeResourceDeleted AdminOrganizationAuditLogListResponseType = "resource.deleted"

      • const AdminOrganizationAuditLogListResponseTypeTunnelCreated AdminOrganizationAuditLogListResponseType = "tunnel.created"

      • const AdminOrganizationAuditLogListResponseTypeTunnelUpdated AdminOrganizationAuditLogListResponseType = "tunnel.updated"

      • const AdminOrganizationAuditLogListResponseTypeTunnelDeleted AdminOrganizationAuditLogListResponseType = "tunnel.deleted"

      • const AdminOrganizationAuditLogListResponseTypeRoleCreated AdminOrganizationAuditLogListResponseType = "role.created"

      • const AdminOrganizationAuditLogListResponseTypeRoleUpdated AdminOrganizationAuditLogListResponseType = "role.updated"

      • const AdminOrganizationAuditLogListResponseTypeRoleDeleted AdminOrganizationAuditLogListResponseType = "role.deleted"

      • const AdminOrganizationAuditLogListResponseTypeRoleAssignmentCreated AdminOrganizationAuditLogListResponseType = "role.assignment.created"

      • const AdminOrganizationAuditLogListResponseTypeRoleAssignmentDeleted AdminOrganizationAuditLogListResponseType = "role.assignment.deleted"

      • const AdminOrganizationAuditLogListResponseTypeScimEnabled AdminOrganizationAuditLogListResponseType = "scim.enabled"

      • const AdminOrganizationAuditLogListResponseTypeScimDisabled AdminOrganizationAuditLogListResponseType = "scim.disabled"

      • const AdminOrganizationAuditLogListResponseTypeServiceAccountCreated AdminOrganizationAuditLogListResponseType = "service_account.created"

      • const AdminOrganizationAuditLogListResponseTypeServiceAccountUpdated AdminOrganizationAuditLogListResponseType = "service_account.updated"

      • const AdminOrganizationAuditLogListResponseTypeServiceAccountDeleted AdminOrganizationAuditLogListResponseType = "service_account.deleted"

      • const AdminOrganizationAuditLogListResponseTypeUserAdded AdminOrganizationAuditLogListResponseType = "user.added"

      • const AdminOrganizationAuditLogListResponseTypeUserUpdated AdminOrganizationAuditLogListResponseType = "user.updated"

      • const AdminOrganizationAuditLogListResponseTypeUserDeleted AdminOrganizationAuditLogListResponseType = "user.deleted"

    • Actor AdminOrganizationAuditLogListResponseActor

      The actor who performed the audit logged action.

      • APIKey AdminOrganizationAuditLogListResponseActorAPIKey

        The API Key used to perform the audit logged action.

        • ID string

          The tracking id of the API key.

        • ServiceAccount AdminOrganizationAuditLogListResponseActorAPIKeyServiceAccount

          The service account that performed the audit logged action.

          • ID string

            The service account id.

        • Type string

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

          • const AdminOrganizationAuditLogListResponseActorAPIKeyTypeUser AdminOrganizationAuditLogListResponseActorAPIKeyType = "user"

          • const AdminOrganizationAuditLogListResponseActorAPIKeyTypeServiceAccount AdminOrganizationAuditLogListResponseActorAPIKeyType = "service_account"

        • User AdminOrganizationAuditLogListResponseActorAPIKeyUser

          The user who performed the audit logged action.

          • ID string

            The user id.

          • Email string

            The user email.

      • Session AdminOrganizationAuditLogListResponseActorSession

        The session in which the audit logged action was performed.

        • IPAddress string

          The IP address from which the action was performed.

        • User AdminOrganizationAuditLogListResponseActorSessionUser

          The user who performed the audit logged action.

          • ID string

            The user id.

          • Email string

            The user email.

      • Type string

        The type of actor. Is either session or api_key.

        • const AdminOrganizationAuditLogListResponseActorTypeSession AdminOrganizationAuditLogListResponseActorType = "session"

        • const AdminOrganizationAuditLogListResponseActorTypeAPIKey AdminOrganizationAuditLogListResponseActorType = "api_key"

    • APIKeyCreated AdminOrganizationAuditLogListResponseAPIKeyCreated

      The details for events with this type.

      • ID string

        The tracking ID of the API key.

      • Data AdminOrganizationAuditLogListResponseAPIKeyCreatedData

        The payload used to create the API key.

        • Scopes []string

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

    • APIKeyDeleted AdminOrganizationAuditLogListResponseAPIKeyDeleted

      The details for events with this type.

      • ID string

        The tracking ID of the API key.

    • APIKeyUpdated AdminOrganizationAuditLogListResponseAPIKeyUpdated

      The details for events with this type.

      • ID string

        The tracking ID of the API key.

      • ChangesRequested AdminOrganizationAuditLogListResponseAPIKeyUpdatedChangesRequested

        The payload used to update the API key.

        • Scopes []string

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

    • CertificateCreated AdminOrganizationAuditLogListResponseCertificateCreated

      The details for events with this type.

      • ID string

        The certificate ID.

      • Name string

        The name of the certificate.

    • CertificateDeleted AdminOrganizationAuditLogListResponseCertificateDeleted

      The details for events with this type.

      • ID string

        The certificate ID.

      • Certificate string

        The certificate content in PEM format.

      • Name string

        The name of the certificate.

    • CertificateUpdated AdminOrganizationAuditLogListResponseCertificateUpdated

      The details for events with this type.

      • ID string

        The certificate ID.

      • Name string

        The name of the certificate.

    • CertificatesActivated AdminOrganizationAuditLogListResponseCertificatesActivated

      The details for events with this type.

      • Certificates []AdminOrganizationAuditLogListResponseCertificatesActivatedCertificate

        • ID string

          The certificate ID.

        • Name string

          The name of the certificate.

    • CertificatesDeactivated AdminOrganizationAuditLogListResponseCertificatesDeactivated

      The details for events with this type.

      • Certificates []AdminOrganizationAuditLogListResponseCertificatesDeactivatedCertificate

        • ID string

          The certificate ID.

        • Name string

          The name of the certificate.

    • CheckpointPermissionCreated AdminOrganizationAuditLogListResponseCheckpointPermissionCreated

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

      • ID string

        The ID of the checkpoint permission.

      • Data AdminOrganizationAuditLogListResponseCheckpointPermissionCreatedData

        The payload used to create the checkpoint permission.

        • FineTunedModelCheckpoint string

          The ID of the fine-tuned model checkpoint.

        • ProjectID string

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

    • CheckpointPermissionDeleted AdminOrganizationAuditLogListResponseCheckpointPermissionDeleted

      The details for events with this type.

      • ID string

        The ID of the checkpoint permission.

    • ExternalKeyRegistered AdminOrganizationAuditLogListResponseExternalKeyRegistered

      The details for events with this type.

      • ID string

        The ID of the external key configuration.

      • Data any

        The configuration for the external key.

    • ExternalKeyRemoved AdminOrganizationAuditLogListResponseExternalKeyRemoved

      The details for events with this type.

      • ID string

        The ID of the external key configuration.

    • GroupCreated AdminOrganizationAuditLogListResponseGroupCreated

      The details for events with this type.

      • ID string

        The ID of the group.

      • Data AdminOrganizationAuditLogListResponseGroupCreatedData

        Information about the created group.

        • GroupName string

          The group name.

    • GroupDeleted AdminOrganizationAuditLogListResponseGroupDeleted

      The details for events with this type.

      • ID string

        The ID of the group.

    • GroupUpdated AdminOrganizationAuditLogListResponseGroupUpdated

      The details for events with this type.

      • ID string

        The ID of the group.

      • ChangesRequested AdminOrganizationAuditLogListResponseGroupUpdatedChangesRequested

        The payload used to update the group.

        • GroupName string

          The updated group name.

    • InviteAccepted AdminOrganizationAuditLogListResponseInviteAccepted

      The details for events with this type.

      • ID string

        The ID of the invite.

    • InviteDeleted AdminOrganizationAuditLogListResponseInviteDeleted

      The details for events with this type.

      • ID string

        The ID of the invite.

    • InviteSent AdminOrganizationAuditLogListResponseInviteSent

      The details for events with this type.

      • ID string

        The ID of the invite.

      • Data AdminOrganizationAuditLogListResponseInviteSentData

        The payload used to create the invite.

        • Email string

          The email invited to the organization.

        • Role string

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

    • IPAllowlistConfigActivated AdminOrganizationAuditLogListResponseIPAllowlistConfigActivated

      The details for events with this type.

      • Configs []AdminOrganizationAuditLogListResponseIPAllowlistConfigActivatedConfig

        The configurations that were activated.

        • ID string

          The ID of the IP allowlist configuration.

        • Name string

          The name of the IP allowlist configuration.

    • IPAllowlistConfigDeactivated AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivated

      The details for events with this type.

      • Configs []AdminOrganizationAuditLogListResponseIPAllowlistConfigDeactivatedConfig

        The configurations that were deactivated.

        • ID string

          The ID of the IP allowlist configuration.

        • Name string

          The name of the IP allowlist configuration.

    • IPAllowlistCreated AdminOrganizationAuditLogListResponseIPAllowlistCreated

      The details for events with this type.

      • ID string

        The ID of the IP allowlist configuration.

      • AllowedIPs []string

        The IP addresses or CIDR ranges included in the configuration.

      • Name string

        The name of the IP allowlist configuration.

    • IPAllowlistDeleted AdminOrganizationAuditLogListResponseIPAllowlistDeleted

      The details for events with this type.

      • ID string

        The ID of the IP allowlist configuration.

      • AllowedIPs []string

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

      • Name string

        The name of the IP allowlist configuration.

    • IPAllowlistUpdated AdminOrganizationAuditLogListResponseIPAllowlistUpdated

      The details for events with this type.

      • ID string

        The ID of the IP allowlist configuration.

      • AllowedIPs []string

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

    • LoginFailed AdminOrganizationAuditLogListResponseLoginFailed

      The details for events with this type.

      • ErrorCode string

        The error code of the failure.

      • ErrorMessage string

        The error message of the failure.

    • LoginSucceeded any

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

    • LogoutFailed AdminOrganizationAuditLogListResponseLogoutFailed

      The details for events with this type.

      • ErrorCode string

        The error code of the failure.

      • ErrorMessage string

        The error message of the failure.

    • LogoutSucceeded any

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

    • OrganizationUpdated AdminOrganizationAuditLogListResponseOrganizationUpdated

      The details for events with this type.

      • ID string

        The organization ID.

      • ChangesRequested AdminOrganizationAuditLogListResponseOrganizationUpdatedChangesRequested

        The payload used to update the organization settings.

        • APICallLogging string

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

        • APICallLoggingProjectIDs string

          The list of project ids if api_call_logging is set to enabled_for_selected_projects

        • Description string

          The organization description.

        • Name string

          The organization name.

        • ThreadsUiVisibility string

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

        • Title string

          The organization title.

        • UsageDashboardVisibility string

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

    • Project AdminOrganizationAuditLogListResponseProject

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

      • ID string

        The project ID.

      • Name string

        The project title.

    • ProjectArchived AdminOrganizationAuditLogListResponseProjectArchived

      The details for events with this type.

      • ID string

        The project ID.

    • ProjectCreated AdminOrganizationAuditLogListResponseProjectCreated

      The details for events with this type.

      • ID string

        The project ID.

      • Data AdminOrganizationAuditLogListResponseProjectCreatedData

        The payload used to create the project.

        • Name string

          The project name.

        • Title string

          The title of the project as seen on the dashboard.

    • ProjectDeleted AdminOrganizationAuditLogListResponseProjectDeleted

      The details for events with this type.

      • ID string

        The project ID.

    • ProjectUpdated AdminOrganizationAuditLogListResponseProjectUpdated

      The details for events with this type.

      • ID string

        The project ID.

      • ChangesRequested AdminOrganizationAuditLogListResponseProjectUpdatedChangesRequested

        The payload used to update the project.

        • Title string

          The title of the project as seen on the dashboard.

    • RateLimitDeleted AdminOrganizationAuditLogListResponseRateLimitDeleted

      The details for events with this type.

      • ID string

        The rate limit ID

    • RateLimitUpdated AdminOrganizationAuditLogListResponseRateLimitUpdated

      The details for events with this type.

      • ID string

        The rate limit ID

      • ChangesRequested AdminOrganizationAuditLogListResponseRateLimitUpdatedChangesRequested

        The payload used to update the rate limits.

        • Batch1DayMaxInputTokens int64

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

        • MaxAudioMegabytesPer1Minute int64

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

        • MaxImagesPer1Minute int64

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

        • MaxRequestsPer1Day int64

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

        • MaxRequestsPer1Minute int64

          The maximum requests per minute.

        • MaxTokensPer1Minute int64

          The maximum tokens per minute.

    • RoleAssignmentCreated AdminOrganizationAuditLogListResponseRoleAssignmentCreated

      The details for events with this type.

      • ID string

        The identifier of the role assignment.

      • PrincipalID string

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

      • PrincipalType string

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

      • ResourceID string

        The resource the role assignment is scoped to.

      • ResourceType string

        The type of resource the role assignment is scoped to.

    • RoleAssignmentDeleted AdminOrganizationAuditLogListResponseRoleAssignmentDeleted

      The details for events with this type.

      • ID string

        The identifier of the role assignment.

      • PrincipalID string

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

      • PrincipalType string

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

      • ResourceID string

        The resource the role assignment was scoped to.

      • ResourceType string

        The type of resource the role assignment was scoped to.

    • RoleCreated AdminOrganizationAuditLogListResponseRoleCreated

      The details for events with this type.

      • ID string

        The role ID.

      • Permissions []string

        The permissions granted by the role.

      • ResourceID string

        The resource the role is scoped to.

      • ResourceType string

        The type of resource the role belongs to.

      • RoleName string

        The name of the role.

    • RoleDeleted AdminOrganizationAuditLogListResponseRoleDeleted

      The details for events with this type.

      • ID string

        The role ID.

    • RoleUpdated AdminOrganizationAuditLogListResponseRoleUpdated

      The details for events with this type.

      • ID string

        The role ID.

      • ChangesRequested AdminOrganizationAuditLogListResponseRoleUpdatedChangesRequested

        The payload used to update the role.

        • Description string

          The updated role description, when provided.

        • Metadata any

          Additional metadata stored on the role.

        • PermissionsAdded []string

          The permissions added to the role.

        • PermissionsRemoved []string

          The permissions removed from the role.

        • ResourceID string

          The resource the role is scoped to.

        • ResourceType string

          The type of resource the role belongs to.

        • RoleName string

          The updated role name, when provided.

    • ScimDisabled AdminOrganizationAuditLogListResponseScimDisabled

      The details for events with this type.

      • ID string

        The ID of the SCIM was disabled for.

    • ScimEnabled AdminOrganizationAuditLogListResponseScimEnabled

      The details for events with this type.

      • ID string

        The ID of the SCIM was enabled for.

    • ServiceAccountCreated AdminOrganizationAuditLogListResponseServiceAccountCreated

      The details for events with this type.

      • ID string

        The service account ID.

      • Data AdminOrganizationAuditLogListResponseServiceAccountCreatedData

        The payload used to create the service account.

        • Role string

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

    • ServiceAccountDeleted AdminOrganizationAuditLogListResponseServiceAccountDeleted

      The details for events with this type.

      • ID string

        The service account ID.

    • ServiceAccountUpdated AdminOrganizationAuditLogListResponseServiceAccountUpdated

      The details for events with this type.

      • ID string

        The service account ID.

      • ChangesRequested AdminOrganizationAuditLogListResponseServiceAccountUpdatedChangesRequested

        The payload used to updated the service account.

        • Role string

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

    • UserAdded AdminOrganizationAuditLogListResponseUserAdded

      The details for events with this type.

      • ID string

        The user ID.

      • Data AdminOrganizationAuditLogListResponseUserAddedData

        The payload used to add the user to the project.

        • Role string

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

    • UserDeleted AdminOrganizationAuditLogListResponseUserDeleted

      The details for events with this type.

      • ID string

        The user ID.

    • UserUpdated AdminOrganizationAuditLogListResponseUserUpdated

      The details for events with this type.

      • ID string

        The project ID.

      • ChangesRequested AdminOrganizationAuditLogListResponseUserUpdatedChangesRequested

        The payload used to update the user.

        • Role string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.AuditLogs.List(context.TODO(), openai.AdminOrganizationAuditLogListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

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

Admin API Keys

List all organization and project API keys.

client.Admin.Organization.AdminAPIKeys.List(ctx, query) (*CursorPage[AdminAPIKey], error)

get /organization/admin_api_keys

List organization API keys

Parameters

  • query AdminOrganizationAdminAPIKeyListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

      Maximum number of keys to return.

    • Order param.Field[AdminOrganizationAdminAPIKeyListParamsOrder]

      Order results by creation time, ascending or descending.

      • const AdminOrganizationAdminAPIKeyListParamsOrderAsc AdminOrganizationAdminAPIKeyListParamsOrder = "asc"

      • const AdminOrganizationAdminAPIKeyListParamsOrderDesc AdminOrganizationAdminAPIKeyListParamsOrder = "desc"

Returns

  • type AdminAPIKey struct{…}

    Represents an individual Admin API key in an org.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationAdminAPIKey

      The object type, which is always organization.admin_api_key

      • const OrganizationAdminAPIKeyOrganizationAdminAPIKey OrganizationAdminAPIKey = "organization.admin_api_key"
    • Owner AdminAPIKeyOwner

      • ID string

        The identifier, which can be referenced in API endpoints

      • CreatedAt int64

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

      • Name string

        The name of the user

      • Object string

        The object type, which is always organization.user

      • Role string

        Always owner

      • Type string

        Always user

    • RedactedValue string

      The redacted value of the API key

    • LastUsedAt int64

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

    • Name string

      The name of the API key

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.AdminAPIKeys.List(context.TODO(), openai.AdminOrganizationAdminAPIKeyListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

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

Create admin API key

client.Admin.Organization.AdminAPIKeys.New(ctx, body) (*AdminOrganizationAdminAPIKeyNewResponse, error)

post /organization/admin_api_keys

Create an organization admin API key

Parameters

  • body AdminOrganizationAdminAPIKeyNewParams

    • Name param.Field[string]

Returns

  • type AdminOrganizationAdminAPIKeyNewResponse struct{…}

    Represents an individual Admin API key in an org.

    • Value string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  adminAPIKey, err := client.Admin.Organization.AdminAPIKeys.New(context.TODO(), openai.AdminOrganizationAdminAPIKeyNewParams{
    Name: "New Admin Key",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", adminAPIKey)
}

Response

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

Retrieve admin API key

client.Admin.Organization.AdminAPIKeys.Get(ctx, keyID) (*AdminAPIKey, error)

get /organization/admin_api_keys/{key_id}

Retrieve a single organization API key

Parameters

  • keyID string

    The ID of the API key.

Returns

  • type AdminAPIKey struct{…}

    Represents an individual Admin API key in an org.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationAdminAPIKey

      The object type, which is always organization.admin_api_key

      • const OrganizationAdminAPIKeyOrganizationAdminAPIKey OrganizationAdminAPIKey = "organization.admin_api_key"
    • Owner AdminAPIKeyOwner

      • ID string

        The identifier, which can be referenced in API endpoints

      • CreatedAt int64

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

      • Name string

        The name of the user

      • Object string

        The object type, which is always organization.user

      • Role string

        Always owner

      • Type string

        Always user

    • RedactedValue string

      The redacted value of the API key

    • LastUsedAt int64

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

    • Name string

      The name of the API key

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  adminAPIKey, err := client.Admin.Organization.AdminAPIKeys.Get(context.TODO(), "key_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", adminAPIKey.ID)
}

Response

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

Delete admin API key

client.Admin.Organization.AdminAPIKeys.Delete(ctx, keyID) (*AdminOrganizationAdminAPIKeyDeleteResponse, error)

delete /organization/admin_api_keys/{key_id}

Delete an organization admin API key

Parameters

  • keyID string

    The ID of the API key to be deleted.

Returns

  • type AdminOrganizationAdminAPIKeyDeleteResponse struct{…}

    • ID string

    • Deleted bool

    • Object OrganizationAdminAPIKeyDeleted

      • const OrganizationAdminAPIKeyDeletedOrganizationAdminAPIKeyDeleted OrganizationAdminAPIKeyDeleted = "organization.admin_api_key.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  adminAPIKey, err := client.Admin.Organization.AdminAPIKeys.Delete(context.TODO(), "key_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", adminAPIKey.ID)
}

Response

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

Domain Types

Admin API Key

  • type AdminAPIKey struct{…}

    Represents an individual Admin API key in an org.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationAdminAPIKey

      The object type, which is always organization.admin_api_key

      • const OrganizationAdminAPIKeyOrganizationAdminAPIKey OrganizationAdminAPIKey = "organization.admin_api_key"
    • Owner AdminAPIKeyOwner

      • ID string

        The identifier, which can be referenced in API endpoints

      • CreatedAt int64

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

      • Name string

        The name of the user

      • Object string

        The object type, which is always organization.user

      • Role string

        Always owner

      • Type string

        Always user

    • RedactedValue string

      The redacted value of the API key

    • LastUsedAt int64

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

    • Name string

      The name of the API key

Usage

Audio speeches

client.Admin.Organization.Usage.AudioSpeeches(ctx, query) (*AdminOrganizationUsageAudioSpeechesResponse, error)

get /organization/usage/audio_speeches

Get audio speeches usage details for the organization.

Parameters

  • query AdminOrganizationUsageAudioSpeechesParams

    • StartTime param.Field[int64]

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

    • APIKeyIDs param.Field[[]string]

      Return only usage for these API keys.

    • BucketWidth param.Field[AdminOrganizationUsageAudioSpeechesParamsBucketWidth]

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

      • const AdminOrganizationUsageAudioSpeechesParamsBucketWidth1m AdminOrganizationUsageAudioSpeechesParamsBucketWidth = "1m"

      • const AdminOrganizationUsageAudioSpeechesParamsBucketWidth1h AdminOrganizationUsageAudioSpeechesParamsBucketWidth = "1h"

      • const AdminOrganizationUsageAudioSpeechesParamsBucketWidth1d AdminOrganizationUsageAudioSpeechesParamsBucketWidth = "1d"

    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

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

      • const AdminOrganizationUsageAudioSpeechesParamsGroupByProjectID AdminOrganizationUsageAudioSpeechesParamsGroupBy = "project_id"

      • const AdminOrganizationUsageAudioSpeechesParamsGroupByUserID AdminOrganizationUsageAudioSpeechesParamsGroupBy = "user_id"

      • const AdminOrganizationUsageAudioSpeechesParamsGroupByAPIKeyID AdminOrganizationUsageAudioSpeechesParamsGroupBy = "api_key_id"

      • const AdminOrganizationUsageAudioSpeechesParamsGroupByModel AdminOrganizationUsageAudioSpeechesParamsGroupBy = "model"

    • Limit param.Field[int64]

      Specifies the number of buckets to return.

      • bucket_width=1d: default: 7, max: 31
      • bucket_width=1h: default: 24, max: 168
      • bucket_width=1m: default: 60, max: 1440
    • Models param.Field[[]string]

      Return only usage for these models.

    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only usage for these projects.

    • UserIDs param.Field[[]string]

      Return only usage for these users.

Returns

  • type AdminOrganizationUsageAudioSpeechesResponse struct{…}

    • Data []AdminOrganizationUsageAudioSpeechesResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageAudioSpeechesResponseDataResultUnion

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageAudioSpeechesResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.AudioSpeeches(context.TODO(), openai.AdminOrganizationUsageAudioSpeechesParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Audio transcriptions

client.Admin.Organization.Usage.AudioTranscriptions(ctx, query) (*AdminOrganizationUsageAudioTranscriptionsResponse, error)

get /organization/usage/audio_transcriptions

Get audio transcriptions usage details for the organization.

Parameters

  • query AdminOrganizationUsageAudioTranscriptionsParams

    • StartTime param.Field[int64]

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

    • APIKeyIDs param.Field[[]string]

      Return only usage for these API keys.

    • BucketWidth param.Field[AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth]

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

      • const AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth1m AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth = "1m"

      • const AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth1h AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth = "1h"

      • const AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth1d AdminOrganizationUsageAudioTranscriptionsParamsBucketWidth = "1d"

    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

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

      • const AdminOrganizationUsageAudioTranscriptionsParamsGroupByProjectID AdminOrganizationUsageAudioTranscriptionsParamsGroupBy = "project_id"

      • const AdminOrganizationUsageAudioTranscriptionsParamsGroupByUserID AdminOrganizationUsageAudioTranscriptionsParamsGroupBy = "user_id"

      • const AdminOrganizationUsageAudioTranscriptionsParamsGroupByAPIKeyID AdminOrganizationUsageAudioTranscriptionsParamsGroupBy = "api_key_id"

      • const AdminOrganizationUsageAudioTranscriptionsParamsGroupByModel AdminOrganizationUsageAudioTranscriptionsParamsGroupBy = "model"

    • Limit param.Field[int64]

      Specifies the number of buckets to return.

      • bucket_width=1d: default: 7, max: 31
      • bucket_width=1h: default: 24, max: 168
      • bucket_width=1m: default: 60, max: 1440
    • Models param.Field[[]string]

      Return only usage for these models.

    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only usage for these projects.

    • UserIDs param.Field[[]string]

      Return only usage for these users.

Returns

  • type AdminOrganizationUsageAudioTranscriptionsResponse struct{…}

    • Data []AdminOrganizationUsageAudioTranscriptionsResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageAudioTranscriptionsResponseDataResultUnion

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageAudioTranscriptionsResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.AudioTranscriptions(context.TODO(), openai.AdminOrganizationUsageAudioTranscriptionsParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Code interpreter sessions

client.Admin.Organization.Usage.CodeInterpreterSessions(ctx, query) (*AdminOrganizationUsageCodeInterpreterSessionsResponse, error)

get /organization/usage/code_interpreter_sessions

Get code interpreter sessions usage details for the organization.

Parameters

  • query AdminOrganizationUsageCodeInterpreterSessionsParams

    • StartTime param.Field[int64]

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

    • BucketWidth param.Field[AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth]

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

      • const AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1m AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1m"

      • const AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1h AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1h"

      • const AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth1d AdminOrganizationUsageCodeInterpreterSessionsParamsBucketWidth = "1d"

    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

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

      • const AdminOrganizationUsageCodeInterpreterSessionsParamsGroupByProjectID AdminOrganizationUsageCodeInterpreterSessionsParamsGroupBy = "project_id"
    • Limit param.Field[int64]

      Specifies the number of buckets to return.

      • bucket_width=1d: default: 7, max: 31
      • bucket_width=1h: default: 24, max: 168
      • bucket_width=1m: default: 60, max: 1440
    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only usage for these projects.

Returns

  • type AdminOrganizationUsageCodeInterpreterSessionsResponse struct{…}

    • Data []AdminOrganizationUsageCodeInterpreterSessionsResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultUnion

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageCodeInterpreterSessionsResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.CodeInterpreterSessions(context.TODO(), openai.AdminOrganizationUsageCodeInterpreterSessionsParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Completions

client.Admin.Organization.Usage.Completions(ctx, query) (*AdminOrganizationUsageCompletionsResponse, error)

get /organization/usage/completions

Get completions usage details for the organization.

Parameters

  • query AdminOrganizationUsageCompletionsParams

    • StartTime param.Field[int64]

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

    • APIKeyIDs param.Field[[]string]

      Return only usage for these API keys.

    • Batch param.Field[bool]

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

    • BucketWidth param.Field[AdminOrganizationUsageCompletionsParamsBucketWidth]

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

      • const AdminOrganizationUsageCompletionsParamsBucketWidth1m AdminOrganizationUsageCompletionsParamsBucketWidth = "1m"

      • const AdminOrganizationUsageCompletionsParamsBucketWidth1h AdminOrganizationUsageCompletionsParamsBucketWidth = "1h"

      • const AdminOrganizationUsageCompletionsParamsBucketWidth1d AdminOrganizationUsageCompletionsParamsBucketWidth = "1d"

    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

      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.

      • const AdminOrganizationUsageCompletionsParamsGroupByProjectID AdminOrganizationUsageCompletionsParamsGroupBy = "project_id"

      • const AdminOrganizationUsageCompletionsParamsGroupByUserID AdminOrganizationUsageCompletionsParamsGroupBy = "user_id"

      • const AdminOrganizationUsageCompletionsParamsGroupByAPIKeyID AdminOrganizationUsageCompletionsParamsGroupBy = "api_key_id"

      • const AdminOrganizationUsageCompletionsParamsGroupByModel AdminOrganizationUsageCompletionsParamsGroupBy = "model"

      • const AdminOrganizationUsageCompletionsParamsGroupByBatch AdminOrganizationUsageCompletionsParamsGroupBy = "batch"

      • const AdminOrganizationUsageCompletionsParamsGroupByServiceTier AdminOrganizationUsageCompletionsParamsGroupBy = "service_tier"

    • Limit param.Field[int64]

      Specifies the number of buckets to return.

      • bucket_width=1d: default: 7, max: 31
      • bucket_width=1h: default: 24, max: 168
      • bucket_width=1m: default: 60, max: 1440
    • Models param.Field[[]string]

      Return only usage for these models.

    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only usage for these projects.

    • UserIDs param.Field[[]string]

      Return only usage for these users.

Returns

  • type AdminOrganizationUsageCompletionsResponse struct{…}

    • Data []AdminOrganizationUsageCompletionsResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageCompletionsResponseDataResultUnion

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageCompletionsResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.Completions(context.TODO(), openai.AdminOrganizationUsageCompletionsParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Embeddings

client.Admin.Organization.Usage.Embeddings(ctx, query) (*AdminOrganizationUsageEmbeddingsResponse, error)

get /organization/usage/embeddings

Get embeddings usage details for the organization.

Parameters

  • query AdminOrganizationUsageEmbeddingsParams

    • StartTime param.Field[int64]

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

    • APIKeyIDs param.Field[[]string]

      Return only usage for these API keys.

    • BucketWidth param.Field[AdminOrganizationUsageEmbeddingsParamsBucketWidth]

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

      • const AdminOrganizationUsageEmbeddingsParamsBucketWidth1m AdminOrganizationUsageEmbeddingsParamsBucketWidth = "1m"

      • const AdminOrganizationUsageEmbeddingsParamsBucketWidth1h AdminOrganizationUsageEmbeddingsParamsBucketWidth = "1h"

      • const AdminOrganizationUsageEmbeddingsParamsBucketWidth1d AdminOrganizationUsageEmbeddingsParamsBucketWidth = "1d"

    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

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

      • const AdminOrganizationUsageEmbeddingsParamsGroupByProjectID AdminOrganizationUsageEmbeddingsParamsGroupBy = "project_id"

      • const AdminOrganizationUsageEmbeddingsParamsGroupByUserID AdminOrganizationUsageEmbeddingsParamsGroupBy = "user_id"

      • const AdminOrganizationUsageEmbeddingsParamsGroupByAPIKeyID AdminOrganizationUsageEmbeddingsParamsGroupBy = "api_key_id"

      • const AdminOrganizationUsageEmbeddingsParamsGroupByModel AdminOrganizationUsageEmbeddingsParamsGroupBy = "model"

    • Limit param.Field[int64]

      Specifies the number of buckets to return.

      • bucket_width=1d: default: 7, max: 31
      • bucket_width=1h: default: 24, max: 168
      • bucket_width=1m: default: 60, max: 1440
    • Models param.Field[[]string]

      Return only usage for these models.

    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only usage for these projects.

    • UserIDs param.Field[[]string]

      Return only usage for these users.

Returns

  • type AdminOrganizationUsageEmbeddingsResponse struct{…}

    • Data []AdminOrganizationUsageEmbeddingsResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageEmbeddingsResponseDataResultUnion

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageEmbeddingsResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.Embeddings(context.TODO(), openai.AdminOrganizationUsageEmbeddingsParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Images

client.Admin.Organization.Usage.Images(ctx, query) (*AdminOrganizationUsageImagesResponse, error)

get /organization/usage/images

Get images usage details for the organization.

Parameters

  • query AdminOrganizationUsageImagesParams

    • StartTime param.Field[int64]

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

    • APIKeyIDs param.Field[[]string]

      Return only usage for these API keys.

    • BucketWidth param.Field[AdminOrganizationUsageImagesParamsBucketWidth]

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

      • const AdminOrganizationUsageImagesParamsBucketWidth1m AdminOrganizationUsageImagesParamsBucketWidth = "1m"

      • const AdminOrganizationUsageImagesParamsBucketWidth1h AdminOrganizationUsageImagesParamsBucketWidth = "1h"

      • const AdminOrganizationUsageImagesParamsBucketWidth1d AdminOrganizationUsageImagesParamsBucketWidth = "1d"

    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

      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.

      • const AdminOrganizationUsageImagesParamsGroupByProjectID AdminOrganizationUsageImagesParamsGroupBy = "project_id"

      • const AdminOrganizationUsageImagesParamsGroupByUserID AdminOrganizationUsageImagesParamsGroupBy = "user_id"

      • const AdminOrganizationUsageImagesParamsGroupByAPIKeyID AdminOrganizationUsageImagesParamsGroupBy = "api_key_id"

      • const AdminOrganizationUsageImagesParamsGroupByModel AdminOrganizationUsageImagesParamsGroupBy = "model"

      • const AdminOrganizationUsageImagesParamsGroupBySize AdminOrganizationUsageImagesParamsGroupBy = "size"

      • const AdminOrganizationUsageImagesParamsGroupBySource AdminOrganizationUsageImagesParamsGroupBy = "source"

    • Limit param.Field[int64]

      Specifies the number of buckets to return.

      • bucket_width=1d: default: 7, max: 31
      • bucket_width=1h: default: 24, max: 168
      • bucket_width=1m: default: 60, max: 1440
    • Models param.Field[[]string]

      Return only usage for these models.

    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only usage for these projects.

    • Sizes param.Field[[]string]

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

      • const AdminOrganizationUsageImagesParamsSize256x256 AdminOrganizationUsageImagesParamsSize = "256x256"

      • const AdminOrganizationUsageImagesParamsSize512x512 AdminOrganizationUsageImagesParamsSize = "512x512"

      • const AdminOrganizationUsageImagesParamsSize1024x1024 AdminOrganizationUsageImagesParamsSize = "1024x1024"

      • const AdminOrganizationUsageImagesParamsSize1792x1792 AdminOrganizationUsageImagesParamsSize = "1792x1792"

      • const AdminOrganizationUsageImagesParamsSize1024x1792 AdminOrganizationUsageImagesParamsSize = "1024x1792"

    • Sources param.Field[[]string]

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

      • const AdminOrganizationUsageImagesParamsSourceImageGeneration AdminOrganizationUsageImagesParamsSource = "image.generation"

      • const AdminOrganizationUsageImagesParamsSourceImageEdit AdminOrganizationUsageImagesParamsSource = "image.edit"

      • const AdminOrganizationUsageImagesParamsSourceImageVariation AdminOrganizationUsageImagesParamsSource = "image.variation"

    • UserIDs param.Field[[]string]

      Return only usage for these users.

Returns

  • type AdminOrganizationUsageImagesResponse struct{…}

    • Data []AdminOrganizationUsageImagesResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageImagesResponseDataResultUnion

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageImagesResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.Images(context.TODO(), openai.AdminOrganizationUsageImagesParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Moderations

client.Admin.Organization.Usage.Moderations(ctx, query) (*AdminOrganizationUsageModerationsResponse, error)

get /organization/usage/moderations

Get moderations usage details for the organization.

Parameters

  • query AdminOrganizationUsageModerationsParams

    • StartTime param.Field[int64]

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

    • APIKeyIDs param.Field[[]string]

      Return only usage for these API keys.

    • BucketWidth param.Field[AdminOrganizationUsageModerationsParamsBucketWidth]

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

      • const AdminOrganizationUsageModerationsParamsBucketWidth1m AdminOrganizationUsageModerationsParamsBucketWidth = "1m"

      • const AdminOrganizationUsageModerationsParamsBucketWidth1h AdminOrganizationUsageModerationsParamsBucketWidth = "1h"

      • const AdminOrganizationUsageModerationsParamsBucketWidth1d AdminOrganizationUsageModerationsParamsBucketWidth = "1d"

    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

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

      • const AdminOrganizationUsageModerationsParamsGroupByProjectID AdminOrganizationUsageModerationsParamsGroupBy = "project_id"

      • const AdminOrganizationUsageModerationsParamsGroupByUserID AdminOrganizationUsageModerationsParamsGroupBy = "user_id"

      • const AdminOrganizationUsageModerationsParamsGroupByAPIKeyID AdminOrganizationUsageModerationsParamsGroupBy = "api_key_id"

      • const AdminOrganizationUsageModerationsParamsGroupByModel AdminOrganizationUsageModerationsParamsGroupBy = "model"

    • Limit param.Field[int64]

      Specifies the number of buckets to return.

      • bucket_width=1d: default: 7, max: 31
      • bucket_width=1h: default: 24, max: 168
      • bucket_width=1m: default: 60, max: 1440
    • Models param.Field[[]string]

      Return only usage for these models.

    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only usage for these projects.

    • UserIDs param.Field[[]string]

      Return only usage for these users.

Returns

  • type AdminOrganizationUsageModerationsResponse struct{…}

    • Data []AdminOrganizationUsageModerationsResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageModerationsResponseDataResultUnion

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageModerationsResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.Moderations(context.TODO(), openai.AdminOrganizationUsageModerationsParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Vector stores

client.Admin.Organization.Usage.VectorStores(ctx, query) (*AdminOrganizationUsageVectorStoresResponse, error)

get /organization/usage/vector_stores

Get vector stores usage details for the organization.

Parameters

  • query AdminOrganizationUsageVectorStoresParams

    • StartTime param.Field[int64]

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

    • BucketWidth param.Field[AdminOrganizationUsageVectorStoresParamsBucketWidth]

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

      • const AdminOrganizationUsageVectorStoresParamsBucketWidth1m AdminOrganizationUsageVectorStoresParamsBucketWidth = "1m"

      • const AdminOrganizationUsageVectorStoresParamsBucketWidth1h AdminOrganizationUsageVectorStoresParamsBucketWidth = "1h"

      • const AdminOrganizationUsageVectorStoresParamsBucketWidth1d AdminOrganizationUsageVectorStoresParamsBucketWidth = "1d"

    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

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

      • const AdminOrganizationUsageVectorStoresParamsGroupByProjectID AdminOrganizationUsageVectorStoresParamsGroupBy = "project_id"
    • Limit param.Field[int64]

      Specifies the number of buckets to return.

      • bucket_width=1d: default: 7, max: 31
      • bucket_width=1h: default: 24, max: 168
      • bucket_width=1m: default: 60, max: 1440
    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only usage for these projects.

Returns

  • type AdminOrganizationUsageVectorStoresResponse struct{…}

    • Data []AdminOrganizationUsageVectorStoresResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageVectorStoresResponseDataResultUnion

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageVectorStoresResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.VectorStores(context.TODO(), openai.AdminOrganizationUsageVectorStoresParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Costs

client.Admin.Organization.Usage.Costs(ctx, query) (*AdminOrganizationUsageCostsResponse, error)

get /organization/costs

Get costs details for the organization.

Parameters

  • query AdminOrganizationUsageCostsParams

    • StartTime param.Field[int64]

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

    • APIKeyIDs param.Field[[]string]

      Return only costs for these API keys.

    • BucketWidth param.Field[AdminOrganizationUsageCostsParamsBucketWidth]

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

      • const AdminOrganizationUsageCostsParamsBucketWidth1d AdminOrganizationUsageCostsParamsBucketWidth = "1d"
    • EndTime param.Field[int64]

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

    • GroupBy param.Field[[]string]

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

      • const AdminOrganizationUsageCostsParamsGroupByProjectID AdminOrganizationUsageCostsParamsGroupBy = "project_id"

      • const AdminOrganizationUsageCostsParamsGroupByLineItem AdminOrganizationUsageCostsParamsGroupBy = "line_item"

      • const AdminOrganizationUsageCostsParamsGroupByAPIKeyID AdminOrganizationUsageCostsParamsGroupBy = "api_key_id"

    • Limit param.Field[int64]

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

    • Page param.Field[string]

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

    • ProjectIDs param.Field[[]string]

      Return only costs for these projects.

Returns

  • type AdminOrganizationUsageCostsResponse struct{…}

    • Data []AdminOrganizationUsageCostsResponseData

      • EndTime int64

      • Object Bucket

        • const BucketBucket Bucket = "bucket"
      • Results []AdminOrganizationUsageCostsResponseDataResultUnion

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCompletionsResult struct{…}

          The aggregated completions usage details of the specific time bucket.

          • InputTokens int64

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageCompletionsResult

            • const OrganizationUsageCompletionsResultOrganizationUsageCompletionsResult OrganizationUsageCompletionsResult = "organization.usage.completions.result"
          • OutputTokens int64

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

          • APIKeyID string

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

          • Batch bool

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

          • InputAudioTokens int64

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

          • InputCachedTokens int64

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

          • Model string

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

          • OutputAudioTokens int64

            The aggregated number of audio output tokens used.

          • ProjectID string

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

          • ServiceTier string

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

          • UserID string

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

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageEmbeddingsResult struct{…}

          The aggregated embeddings usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageEmbeddingsResult

            • const OrganizationUsageEmbeddingsResultOrganizationUsageEmbeddingsResult OrganizationUsageEmbeddingsResult = "organization.usage.embeddings.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageModerationsResult struct{…}

          The aggregated moderations usage details of the specific time bucket.

          • InputTokens int64

            The aggregated number of input tokens used.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageModerationsResult

            • const OrganizationUsageModerationsResultOrganizationUsageModerationsResult OrganizationUsageModerationsResult = "organization.usage.moderations.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageImagesResult struct{…}

          The aggregated images usage details of the specific time bucket.

          • Images int64

            The number of images processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageImagesResult

            • const OrganizationUsageImagesResultOrganizationUsageImagesResult OrganizationUsageImagesResult = "organization.usage.images.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • Size string

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

          • Source string

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

          • UserID string

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

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioSpeechesResult struct{…}

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

          • Characters int64

            The number of characters processed.

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioSpeechesResult

            • const OrganizationUsageAudioSpeechesResultOrganizationUsageAudioSpeechesResult OrganizationUsageAudioSpeechesResult = "organization.usage.audio_speeches.result"
          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageAudioTranscriptionsResult struct{…}

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

          • NumModelRequests int64

            The count of requests made to the model.

          • Object OrganizationUsageAudioTranscriptionsResult

            • const OrganizationUsageAudioTranscriptionsResultOrganizationUsageAudioTranscriptionsResult OrganizationUsageAudioTranscriptionsResult = "organization.usage.audio_transcriptions.result"
          • Seconds int64

            The number of seconds processed.

          • APIKeyID string

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

          • Model string

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

          • ProjectID string

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

          • UserID string

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

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageVectorStoresResult struct{…}

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

          • Object OrganizationUsageVectorStoresResult

            • const OrganizationUsageVectorStoresResultOrganizationUsageVectorStoresResult OrganizationUsageVectorStoresResult = "organization.usage.vector_stores.result"
          • UsageBytes int64

            The vector stores usage in bytes.

          • ProjectID string

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

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationUsageCodeInterpreterSessionsResult struct{…}

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

          • NumSessions int64

            The number of code interpreter sessions.

          • Object OrganizationUsageCodeInterpreterSessionsResult

            • const OrganizationUsageCodeInterpreterSessionsResultOrganizationUsageCodeInterpreterSessionsResult OrganizationUsageCodeInterpreterSessionsResult = "organization.usage.code_interpreter_sessions.result"
          • ProjectID string

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

        • type AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResult struct{…}

          The aggregated costs details of the specific time bucket.

          • Object OrganizationCostsResult

            • const OrganizationCostsResultOrganizationCostsResult OrganizationCostsResult = "organization.costs.result"
          • Amount AdminOrganizationUsageCostsResponseDataResultOrganizationCostsResultAmount

            The monetary value in its associated currency.

            • Currency string

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

            • Value float64

              The numeric value of the cost.

          • APIKeyID string

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

          • LineItem string

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

          • ProjectID string

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

          • Quantity float64

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

      • StartTime int64

    • HasMore bool

    • NextPage string

    • Object Page

      • const PagePage Page = "page"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  response, err := client.Admin.Organization.Usage.Costs(context.TODO(), openai.AdminOrganizationUsageCostsParams{
    StartTime: 0,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.Data)
}

Response

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

Invites

List invites

client.Admin.Organization.Invites.List(ctx, query) (*ConversationCursorPage[Invite], error)

get /organization/invites

Returns a list of invites in the organization.

Parameters

  • query AdminOrganizationInviteListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

Returns

  • type Invite struct{…}

    Represents an individual invite to the organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Email string

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

    • Object OrganizationInvite

      The object type, which is always organization.invite

      • const OrganizationInviteOrganizationInvite OrganizationInvite = "organization.invite"
    • Projects []InviteProject

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

      • ID string

        Project's public ID

      • Role string

        Project membership role

        • const InviteProjectRoleMember InviteProjectRole = "member"

        • const InviteProjectRoleOwner InviteProjectRole = "owner"

    • Role InviteRole

      owner or reader

      • const InviteRoleOwner InviteRole = "owner"

      • const InviteRoleReader InviteRole = "reader"

    • Status InviteStatus

      accepted,expired, or pending

      • const InviteStatusAccepted InviteStatus = "accepted"

      • const InviteStatusExpired InviteStatus = "expired"

      • const InviteStatusPending InviteStatus = "pending"

    • AcceptedAt int64

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

    • ExpiresAt int64

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Invites.List(context.TODO(), openai.AdminOrganizationInviteListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "email": "email",
      "object": "organization.invite",
      "projects": [
        {
          "id": "id",
          "role": "member"
        }
      ],
      "role": "owner",
      "status": "accepted",
      "accepted_at": 0,
      "expires_at": 0
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Create invite

client.Admin.Organization.Invites.New(ctx, body) (*Invite, error)

post /organization/invites

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

Parameters

  • body AdminOrganizationInviteNewParams

    • Email param.Field[string]

      Send an email to this address

    • Role param.Field[AdminOrganizationInviteNewParamsRole]

      owner or reader

      • const AdminOrganizationInviteNewParamsRoleReader AdminOrganizationInviteNewParamsRole = "reader"

      • const AdminOrganizationInviteNewParamsRoleOwner AdminOrganizationInviteNewParamsRole = "owner"

    • Projects param.Field[[]AdminOrganizationInviteNewParamsProject]

      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.

      • ID string

        Project's public ID

      • Role string

        Project membership role

        • const AdminOrganizationInviteNewParamsProjectRoleMember AdminOrganizationInviteNewParamsProjectRole = "member"

        • const AdminOrganizationInviteNewParamsProjectRoleOwner AdminOrganizationInviteNewParamsProjectRole = "owner"

Returns

  • type Invite struct{…}

    Represents an individual invite to the organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Email string

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

    • Object OrganizationInvite

      The object type, which is always organization.invite

      • const OrganizationInviteOrganizationInvite OrganizationInvite = "organization.invite"
    • Projects []InviteProject

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

      • ID string

        Project's public ID

      • Role string

        Project membership role

        • const InviteProjectRoleMember InviteProjectRole = "member"

        • const InviteProjectRoleOwner InviteProjectRole = "owner"

    • Role InviteRole

      owner or reader

      • const InviteRoleOwner InviteRole = "owner"

      • const InviteRoleReader InviteRole = "reader"

    • Status InviteStatus

      accepted,expired, or pending

      • const InviteStatusAccepted InviteStatus = "accepted"

      • const InviteStatusExpired InviteStatus = "expired"

      • const InviteStatusPending InviteStatus = "pending"

    • AcceptedAt int64

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

    • ExpiresAt int64

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  invite, err := client.Admin.Organization.Invites.New(context.TODO(), openai.AdminOrganizationInviteNewParams{
    Email: "email",
    Role: openai.AdminOrganizationInviteNewParamsRoleReader,
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", invite.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "email": "email",
  "object": "organization.invite",
  "projects": [
    {
      "id": "id",
      "role": "member"
    }
  ],
  "role": "owner",
  "status": "accepted",
  "accepted_at": 0,
  "expires_at": 0
}

Retrieve invite

client.Admin.Organization.Invites.Get(ctx, inviteID) (*Invite, error)

get /organization/invites/{invite_id}

Retrieves an invite.

Parameters

  • inviteID string

Returns

  • type Invite struct{…}

    Represents an individual invite to the organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Email string

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

    • Object OrganizationInvite

      The object type, which is always organization.invite

      • const OrganizationInviteOrganizationInvite OrganizationInvite = "organization.invite"
    • Projects []InviteProject

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

      • ID string

        Project's public ID

      • Role string

        Project membership role

        • const InviteProjectRoleMember InviteProjectRole = "member"

        • const InviteProjectRoleOwner InviteProjectRole = "owner"

    • Role InviteRole

      owner or reader

      • const InviteRoleOwner InviteRole = "owner"

      • const InviteRoleReader InviteRole = "reader"

    • Status InviteStatus

      accepted,expired, or pending

      • const InviteStatusAccepted InviteStatus = "accepted"

      • const InviteStatusExpired InviteStatus = "expired"

      • const InviteStatusPending InviteStatus = "pending"

    • AcceptedAt int64

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

    • ExpiresAt int64

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  invite, err := client.Admin.Organization.Invites.Get(context.TODO(), "invite_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", invite.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "email": "email",
  "object": "organization.invite",
  "projects": [
    {
      "id": "id",
      "role": "member"
    }
  ],
  "role": "owner",
  "status": "accepted",
  "accepted_at": 0,
  "expires_at": 0
}

Delete invite

client.Admin.Organization.Invites.Delete(ctx, inviteID) (*AdminOrganizationInviteDeleteResponse, error)

delete /organization/invites/{invite_id}

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

Parameters

  • inviteID string

Returns

  • type AdminOrganizationInviteDeleteResponse struct{…}

    • ID string

    • Deleted bool

    • Object OrganizationInviteDeleted

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

      • const OrganizationInviteDeletedOrganizationInviteDeleted OrganizationInviteDeleted = "organization.invite.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  invite, err := client.Admin.Organization.Invites.Delete(context.TODO(), "invite_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", invite.ID)
}

Response

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

Domain Types

Invite

  • type Invite struct{…}

    Represents an individual invite to the organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Email string

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

    • Object OrganizationInvite

      The object type, which is always organization.invite

      • const OrganizationInviteOrganizationInvite OrganizationInvite = "organization.invite"
    • Projects []InviteProject

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

      • ID string

        Project's public ID

      • Role string

        Project membership role

        • const InviteProjectRoleMember InviteProjectRole = "member"

        • const InviteProjectRoleOwner InviteProjectRole = "owner"

    • Role InviteRole

      owner or reader

      • const InviteRoleOwner InviteRole = "owner"

      • const InviteRoleReader InviteRole = "reader"

    • Status InviteStatus

      accepted,expired, or pending

      • const InviteStatusAccepted InviteStatus = "accepted"

      • const InviteStatusExpired InviteStatus = "expired"

      • const InviteStatusPending InviteStatus = "pending"

    • AcceptedAt int64

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

    • ExpiresAt int64

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

Users

List users

client.Admin.Organization.Users.List(ctx, query) (*ConversationCursorPage[OrganizationUser], error)

get /organization/users

Lists all of the users in the organization.

Parameters

  • query AdminOrganizationUserListParams

    • After param.Field[string]

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

    • Emails param.Field[[]string]

      Filter by the email address of users.

    • Limit param.Field[int64]

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

Returns

  • type OrganizationUser struct{…}

    Represents an individual user within an organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationUser

      The object type, which is always organization.user

      • const OrganizationUserOrganizationUser OrganizationUser = "organization.user"
    • APIKeyLastUsedAt int64

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

    • Created int64

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

    • DeveloperPersona string

      The developer persona metadata for the user.

    • Email string

      The email address of the user

    • IsDefault bool

      Whether this is the organization's default user.

    • IsScaleTierAuthorizedPurchaser bool

      Whether the user is an authorized purchaser for Scale Tier.

    • IsScimManaged bool

      Whether the user is managed through SCIM.

    • IsServiceAccount bool

      Whether the user is a service account.

    • Name string

      The name of the user

    • Projects OrganizationUserProjects

      Projects associated with the user, if included.

      • Data []OrganizationUserProjectsData

        • ID string

        • Name string

        • Role string

      • Object List

        • const ListList List = "list"
    • Role string

      owner or reader

    • TechnicalLevel string

      The technical level metadata for the user.

    • User OrganizationUserUser

      Nested user details.

      • ID string

      • Object User

        • const UserUser User = "user"
      • Banned bool

      • BannedAt int64

      • Email string

      • Enabled bool

      • Name string

      • Picture string

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Users.List(context.TODO(), openai.AdminOrganizationUserListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "added_at": 0,
      "object": "organization.user",
      "api_key_last_used_at": 0,
      "created": 0,
      "developer_persona": "developer_persona",
      "email": "email",
      "is_default": true,
      "is_scale_tier_authorized_purchaser": true,
      "is_scim_managed": true,
      "is_service_account": true,
      "name": "name",
      "projects": {
        "data": [
          {
            "id": "id",
            "name": "name",
            "role": "role"
          }
        ],
        "object": "list"
      },
      "role": "role",
      "technical_level": "technical_level",
      "user": {
        "id": "id",
        "object": "user",
        "banned": true,
        "banned_at": 0,
        "email": "email",
        "enabled": true,
        "name": "name",
        "picture": "picture"
      }
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Retrieve user

client.Admin.Organization.Users.Get(ctx, userID) (*OrganizationUser, error)

get /organization/users/{user_id}

Retrieves a user by their identifier.

Parameters

  • userID string

Returns

  • type OrganizationUser struct{…}

    Represents an individual user within an organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationUser

      The object type, which is always organization.user

      • const OrganizationUserOrganizationUser OrganizationUser = "organization.user"
    • APIKeyLastUsedAt int64

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

    • Created int64

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

    • DeveloperPersona string

      The developer persona metadata for the user.

    • Email string

      The email address of the user

    • IsDefault bool

      Whether this is the organization's default user.

    • IsScaleTierAuthorizedPurchaser bool

      Whether the user is an authorized purchaser for Scale Tier.

    • IsScimManaged bool

      Whether the user is managed through SCIM.

    • IsServiceAccount bool

      Whether the user is a service account.

    • Name string

      The name of the user

    • Projects OrganizationUserProjects

      Projects associated with the user, if included.

      • Data []OrganizationUserProjectsData

        • ID string

        • Name string

        • Role string

      • Object List

        • const ListList List = "list"
    • Role string

      owner or reader

    • TechnicalLevel string

      The technical level metadata for the user.

    • User OrganizationUserUser

      Nested user details.

      • ID string

      • Object User

        • const UserUser User = "user"
      • Banned bool

      • BannedAt int64

      • Email string

      • Enabled bool

      • Name string

      • Picture string

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  organizationUser, err := client.Admin.Organization.Users.Get(context.TODO(), "user_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", organizationUser.ID)
}

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.user",
  "api_key_last_used_at": 0,
  "created": 0,
  "developer_persona": "developer_persona",
  "email": "email",
  "is_default": true,
  "is_scale_tier_authorized_purchaser": true,
  "is_scim_managed": true,
  "is_service_account": true,
  "name": "name",
  "projects": {
    "data": [
      {
        "id": "id",
        "name": "name",
        "role": "role"
      }
    ],
    "object": "list"
  },
  "role": "role",
  "technical_level": "technical_level",
  "user": {
    "id": "id",
    "object": "user",
    "banned": true,
    "banned_at": 0,
    "email": "email",
    "enabled": true,
    "name": "name",
    "picture": "picture"
  }
}

Modify user

client.Admin.Organization.Users.Update(ctx, userID, body) (*OrganizationUser, error)

post /organization/users/{user_id}

Modifies a user's role in the organization.

Parameters

  • userID string

  • body AdminOrganizationUserUpdateParams

    • DeveloperPersona param.Field[string]

      Developer persona metadata.

    • Role param.Field[string]

      owner or reader

    • RoleID param.Field[string]

      Role ID to assign to the user.

    • TechnicalLevel param.Field[string]

      Technical level metadata.

Returns

  • type OrganizationUser struct{…}

    Represents an individual user within an organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationUser

      The object type, which is always organization.user

      • const OrganizationUserOrganizationUser OrganizationUser = "organization.user"
    • APIKeyLastUsedAt int64

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

    • Created int64

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

    • DeveloperPersona string

      The developer persona metadata for the user.

    • Email string

      The email address of the user

    • IsDefault bool

      Whether this is the organization's default user.

    • IsScaleTierAuthorizedPurchaser bool

      Whether the user is an authorized purchaser for Scale Tier.

    • IsScimManaged bool

      Whether the user is managed through SCIM.

    • IsServiceAccount bool

      Whether the user is a service account.

    • Name string

      The name of the user

    • Projects OrganizationUserProjects

      Projects associated with the user, if included.

      • Data []OrganizationUserProjectsData

        • ID string

        • Name string

        • Role string

      • Object List

        • const ListList List = "list"
    • Role string

      owner or reader

    • TechnicalLevel string

      The technical level metadata for the user.

    • User OrganizationUserUser

      Nested user details.

      • ID string

      • Object User

        • const UserUser User = "user"
      • Banned bool

      • BannedAt int64

      • Email string

      • Enabled bool

      • Name string

      • Picture string

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  organizationUser, err := client.Admin.Organization.Users.Update(
    context.TODO(),
    "user_id",
    openai.AdminOrganizationUserUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", organizationUser.ID)
}

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.user",
  "api_key_last_used_at": 0,
  "created": 0,
  "developer_persona": "developer_persona",
  "email": "email",
  "is_default": true,
  "is_scale_tier_authorized_purchaser": true,
  "is_scim_managed": true,
  "is_service_account": true,
  "name": "name",
  "projects": {
    "data": [
      {
        "id": "id",
        "name": "name",
        "role": "role"
      }
    ],
    "object": "list"
  },
  "role": "role",
  "technical_level": "technical_level",
  "user": {
    "id": "id",
    "object": "user",
    "banned": true,
    "banned_at": 0,
    "email": "email",
    "enabled": true,
    "name": "name",
    "picture": "picture"
  }
}

Delete user

client.Admin.Organization.Users.Delete(ctx, userID) (*AdminOrganizationUserDeleteResponse, error)

delete /organization/users/{user_id}

Deletes a user from the organization.

Parameters

  • userID string

Returns

  • type AdminOrganizationUserDeleteResponse struct{…}

    • ID string

    • Deleted bool

    • Object OrganizationUserDeleted

      • const OrganizationUserDeletedOrganizationUserDeleted OrganizationUserDeleted = "organization.user.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  user, err := client.Admin.Organization.Users.Delete(context.TODO(), "user_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", user.ID)
}

Response

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

Domain Types

Organization User

  • type OrganizationUser struct{…}

    Represents an individual user within an organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationUser

      The object type, which is always organization.user

      • const OrganizationUserOrganizationUser OrganizationUser = "organization.user"
    • APIKeyLastUsedAt int64

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

    • Created int64

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

    • DeveloperPersona string

      The developer persona metadata for the user.

    • Email string

      The email address of the user

    • IsDefault bool

      Whether this is the organization's default user.

    • IsScaleTierAuthorizedPurchaser bool

      Whether the user is an authorized purchaser for Scale Tier.

    • IsScimManaged bool

      Whether the user is managed through SCIM.

    • IsServiceAccount bool

      Whether the user is a service account.

    • Name string

      The name of the user

    • Projects OrganizationUserProjects

      Projects associated with the user, if included.

      • Data []OrganizationUserProjectsData

        • ID string

        • Name string

        • Role string

      • Object List

        • const ListList List = "list"
    • Role string

      owner or reader

    • TechnicalLevel string

      The technical level metadata for the user.

    • User OrganizationUserUser

      Nested user details.

      • ID string

      • Object User

        • const UserUser User = "user"
      • Banned bool

      • BannedAt int64

      • Email string

      • Enabled bool

      • Name string

      • Picture string

Roles

List user organization role assignments

client.Admin.Organization.Users.Roles.List(ctx, userID, query) (*NextCursorPage[AdminOrganizationUserRoleListResponse], error)

get /organization/users/{user_id}/roles

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

Parameters

  • userID string

  • query AdminOrganizationUserRoleListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

    • Order param.Field[AdminOrganizationUserRoleListParamsOrder]

      Sort order for the returned organization roles.

      • const AdminOrganizationUserRoleListParamsOrderAsc AdminOrganizationUserRoleListParamsOrder = "asc"

      • const AdminOrganizationUserRoleListParamsOrderDesc AdminOrganizationUserRoleListParamsOrder = "desc"

Returns

  • type AdminOrganizationUserRoleListResponse struct{…}

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

    • ID string

      Identifier for the role.

    • CreatedAt int64

      When the role was created.

    • CreatedBy string

      Identifier of the actor who created the role.

    • CreatedByUserObj map[string, any]

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

    • Description string

      Description of the role.

    • Metadata map[string, any]

      Arbitrary metadata stored on the role.

    • Name string

      Name of the role.

    • Permissions []string

      Permissions associated with the role.

    • PredefinedRole bool

      Whether the role is predefined by OpenAI.

    • ResourceType string

      Resource type the role applies to.

    • UpdatedAt int64

      When the role was last updated.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Users.Roles.List(
    context.TODO(),
    "user_id",
    openai.AdminOrganizationUserRoleListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "created_by": "created_by",
      "created_by_user_obj": {
        "foo": "bar"
      },
      "description": "description",
      "metadata": {
        "foo": "bar"
      },
      "name": "name",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type",
      "updated_at": 0
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Assign organization role to user

client.Admin.Organization.Users.Roles.New(ctx, userID, body) (*AdminOrganizationUserRoleNewResponse, error)

post /organization/users/{user_id}/roles

Assigns an organization role to a user within the organization.

Parameters

  • userID string

  • body AdminOrganizationUserRoleNewParams

    • RoleID param.Field[string]

      Identifier of the role to assign.

Returns

  • type AdminOrganizationUserRoleNewResponse struct{…}

    Role assignment linking a user to a role.

    • Object UserRole

      Always user.role.

      • const UserRoleUserRole UserRole = "user.role"
    • Role Role

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

      • ID string

        Identifier for the role.

      • Description string

        Optional description of the role.

      • Name string

        Unique name for the role.

      • Object Role

        Always role.

        • const RoleRole Role = "role"
      • Permissions []string

        Permissions granted by the role.

      • PredefinedRole bool

        Whether the role is predefined and managed by OpenAI.

      • ResourceType string

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

    • User OrganizationUser

      Represents an individual user within an organization.

      • ID string

        The identifier, which can be referenced in API endpoints

      • AddedAt int64

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

      • Object OrganizationUser

        The object type, which is always organization.user

        • const OrganizationUserOrganizationUser OrganizationUser = "organization.user"
      • APIKeyLastUsedAt int64

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

      • Created int64

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

      • DeveloperPersona string

        The developer persona metadata for the user.

      • Email string

        The email address of the user

      • IsDefault bool

        Whether this is the organization's default user.

      • IsScaleTierAuthorizedPurchaser bool

        Whether the user is an authorized purchaser for Scale Tier.

      • IsScimManaged bool

        Whether the user is managed through SCIM.

      • IsServiceAccount bool

        Whether the user is a service account.

      • Name string

        The name of the user

      • Projects OrganizationUserProjects

        Projects associated with the user, if included.

        • Data []OrganizationUserProjectsData

          • ID string

          • Name string

          • Role string

        • Object List

          • const ListList List = "list"
      • Role string

        owner or reader

      • TechnicalLevel string

        The technical level metadata for the user.

      • User OrganizationUserUser

        Nested user details.

        • ID string

        • Object User

          • const UserUser User = "user"
        • Banned bool

        • BannedAt int64

        • Email string

        • Enabled bool

        • Name string

        • Picture string

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Users.Roles.New(
    context.TODO(),
    "user_id",
    openai.AdminOrganizationUserRoleNewParams{
      RoleID: "role_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.Object)
}

Response

{
  "object": "user.role",
  "role": {
    "id": "id",
    "description": "description",
    "name": "name",
    "object": "role",
    "permissions": [
      "string"
    ],
    "predefined_role": true,
    "resource_type": "resource_type"
  },
  "user": {
    "id": "id",
    "added_at": 0,
    "object": "organization.user",
    "api_key_last_used_at": 0,
    "created": 0,
    "developer_persona": "developer_persona",
    "email": "email",
    "is_default": true,
    "is_scale_tier_authorized_purchaser": true,
    "is_scim_managed": true,
    "is_service_account": true,
    "name": "name",
    "projects": {
      "data": [
        {
          "id": "id",
          "name": "name",
          "role": "role"
        }
      ],
      "object": "list"
    },
    "role": "role",
    "technical_level": "technical_level",
    "user": {
      "id": "id",
      "object": "user",
      "banned": true,
      "banned_at": 0,
      "email": "email",
      "enabled": true,
      "name": "name",
      "picture": "picture"
    }
  }
}

Unassign organization role from user

client.Admin.Organization.Users.Roles.Delete(ctx, userID, roleID) (*AdminOrganizationUserRoleDeleteResponse, error)

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

Unassigns an organization role from a user within the organization.

Parameters

  • userID string

  • roleID string

Returns

  • type AdminOrganizationUserRoleDeleteResponse struct{…}

    Confirmation payload returned after unassigning a role.

    • Deleted bool

      Whether the assignment was removed.

    • Object string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Users.Roles.Delete(
    context.TODO(),
    "user_id",
    "role_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.Deleted)
}

Response

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

Groups

List groups

client.Admin.Organization.Groups.List(ctx, query) (*NextCursorPage[Group], error)

get /organization/groups

Lists all groups in the organization.

Parameters

  • query AdminOrganizationGroupListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

    • Order param.Field[AdminOrganizationGroupListParamsOrder]

      Specifies the sort order of the returned groups.

      • const AdminOrganizationGroupListParamsOrderAsc AdminOrganizationGroupListParamsOrder = "asc"

      • const AdminOrganizationGroupListParamsOrderDesc AdminOrganizationGroupListParamsOrder = "desc"

Returns

  • type Group struct{…}

    Details about an organization group.

    • ID string

      Identifier for the group.

    • CreatedAt int64

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

    • GroupType string

      The type of the group.

    • IsScimManaged bool

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

    • Name string

      Display name of the group.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Groups.List(context.TODO(), openai.AdminOrganizationGroupListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

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

Create group

client.Admin.Organization.Groups.New(ctx, body) (*Group, error)

post /organization/groups

Creates a new group in the organization.

Parameters

  • body AdminOrganizationGroupNewParams

    • Name param.Field[string]

      Human readable name for the group.

Returns

  • type Group struct{…}

    Details about an organization group.

    • ID string

      Identifier for the group.

    • CreatedAt int64

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

    • GroupType string

      The type of the group.

    • IsScimManaged bool

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

    • Name string

      Display name of the group.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  group, err := client.Admin.Organization.Groups.New(context.TODO(), openai.AdminOrganizationGroupNewParams{
    Name: "x",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", group.ID)
}

Response

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

Update group

client.Admin.Organization.Groups.Update(ctx, groupID, body) (*AdminOrganizationGroupUpdateResponse, error)

post /organization/groups/{group_id}

Updates a group's information.

Parameters

  • groupID string

  • body AdminOrganizationGroupUpdateParams

    • Name param.Field[string]

      New display name for the group.

Returns

  • type AdminOrganizationGroupUpdateResponse struct{…}

    Response returned after updating a group.

    • ID string

      Identifier for the group.

    • CreatedAt int64

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

    • IsScimManaged bool

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

    • Name string

      Updated display name for the group.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  group, err := client.Admin.Organization.Groups.Update(
    context.TODO(),
    "group_id",
    openai.AdminOrganizationGroupUpdateParams{
      Name: "x",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", group.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "is_scim_managed": true,
  "name": "name"
}

Delete group

client.Admin.Organization.Groups.Delete(ctx, groupID) (*AdminOrganizationGroupDeleteResponse, error)

delete /organization/groups/{group_id}

Deletes a group from the organization.

Parameters

  • groupID string

Returns

  • type AdminOrganizationGroupDeleteResponse struct{…}

    Confirmation payload returned after deleting a group.

    • ID string

      Identifier of the deleted group.

    • Deleted bool

      Whether the group was deleted.

    • Object GroupDeleted

      Always group.deleted.

      • const GroupDeletedGroupDeleted GroupDeleted = "group.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  group, err := client.Admin.Organization.Groups.Delete(context.TODO(), "group_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", group.ID)
}

Response

{
  "id": "id",
  "deleted": true,
  "object": "group.deleted"
}

Domain Types

Group

  • type Group struct{…}

    Details about an organization group.

    • ID string

      Identifier for the group.

    • CreatedAt int64

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

    • GroupType string

      The type of the group.

    • IsScimManaged bool

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

    • Name string

      Display name of the group.

Users

List group users

client.Admin.Organization.Groups.Users.List(ctx, groupID, query) (*NextCursorPage[OrganizationGroupUser], error)

get /organization/groups/{group_id}/users

Lists the users assigned to a group.

Parameters

  • groupID string

  • query AdminOrganizationGroupUserListParams

    • After param.Field[string]

      A cursor for use in pagination. Provide the ID of the last user from the previous list response to retrieve the next page.

    • Limit param.Field[int64]

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

    • Order param.Field[AdminOrganizationGroupUserListParamsOrder]

      Specifies the sort order of users in the list.

      • const AdminOrganizationGroupUserListParamsOrderAsc AdminOrganizationGroupUserListParamsOrder = "asc"

      • const AdminOrganizationGroupUserListParamsOrderDesc AdminOrganizationGroupUserListParamsOrder = "desc"

Returns

  • type OrganizationGroupUser struct{…}

    Represents an individual user returned when inspecting group membership.

    • ID string

      The identifier, which can be referenced in API endpoints

    • Email string

      The email address of the user.

    • Name string

      The name of the user.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Groups.Users.List(
    context.TODO(),
    "group_id",
    openai.AdminOrganizationGroupUserListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "email": "email",
      "name": "name"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Add group user

client.Admin.Organization.Groups.Users.New(ctx, groupID, body) (*AdminOrganizationGroupUserNewResponse, error)

post /organization/groups/{group_id}/users

Adds a user to a group.

Parameters

  • groupID string

  • body AdminOrganizationGroupUserNewParams

    • UserID param.Field[string]

      Identifier of the user to add to the group.

Returns

  • type AdminOrganizationGroupUserNewResponse struct{…}

    Confirmation payload returned after adding a user to a group.

    • GroupID string

      Identifier of the group the user was added to.

    • Object GroupUser

      Always group.user.

      • const GroupUserGroupUser GroupUser = "group.user"
    • UserID string

      Identifier of the user that was added.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  user, err := client.Admin.Organization.Groups.Users.New(
    context.TODO(),
    "group_id",
    openai.AdminOrganizationGroupUserNewParams{
      UserID: "user_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", user.GroupID)
}

Response

{
  "group_id": "group_id",
  "object": "group.user",
  "user_id": "user_id"
}

Remove group user

client.Admin.Organization.Groups.Users.Delete(ctx, groupID, userID) (*AdminOrganizationGroupUserDeleteResponse, error)

delete /organization/groups/{group_id}/users/{user_id}

Removes a user from a group.

Parameters

  • groupID string

  • userID string

Returns

  • type AdminOrganizationGroupUserDeleteResponse struct{…}

    Confirmation payload returned after removing a user from a group.

    • Deleted bool

      Whether the group membership was removed.

    • Object GroupUserDeleted

      Always group.user.deleted.

      • const GroupUserDeletedGroupUserDeleted GroupUserDeleted = "group.user.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  user, err := client.Admin.Organization.Groups.Users.Delete(
    context.TODO(),
    "group_id",
    "user_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", user.Deleted)
}

Response

{
  "deleted": true,
  "object": "group.user.deleted"
}

Domain Types

Organization Group User

  • type OrganizationGroupUser struct{…}

    Represents an individual user returned when inspecting group membership.

    • ID string

      The identifier, which can be referenced in API endpoints

    • Email string

      The email address of the user.

    • Name string

      The name of the user.

Roles

List group organization role assignments

client.Admin.Organization.Groups.Roles.List(ctx, groupID, query) (*NextCursorPage[AdminOrganizationGroupRoleListResponse], error)

get /organization/groups/{group_id}/roles

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

Parameters

  • groupID string

  • query AdminOrganizationGroupRoleListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

    • Order param.Field[AdminOrganizationGroupRoleListParamsOrder]

      Sort order for the returned organization roles.

      • const AdminOrganizationGroupRoleListParamsOrderAsc AdminOrganizationGroupRoleListParamsOrder = "asc"

      • const AdminOrganizationGroupRoleListParamsOrderDesc AdminOrganizationGroupRoleListParamsOrder = "desc"

Returns

  • type AdminOrganizationGroupRoleListResponse struct{…}

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

    • ID string

      Identifier for the role.

    • CreatedAt int64

      When the role was created.

    • CreatedBy string

      Identifier of the actor who created the role.

    • CreatedByUserObj map[string, any]

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

    • Description string

      Description of the role.

    • Metadata map[string, any]

      Arbitrary metadata stored on the role.

    • Name string

      Name of the role.

    • Permissions []string

      Permissions associated with the role.

    • PredefinedRole bool

      Whether the role is predefined by OpenAI.

    • ResourceType string

      Resource type the role applies to.

    • UpdatedAt int64

      When the role was last updated.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Groups.Roles.List(
    context.TODO(),
    "group_id",
    openai.AdminOrganizationGroupRoleListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "created_by": "created_by",
      "created_by_user_obj": {
        "foo": "bar"
      },
      "description": "description",
      "metadata": {
        "foo": "bar"
      },
      "name": "name",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type",
      "updated_at": 0
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Assign organization role to group

client.Admin.Organization.Groups.Roles.New(ctx, groupID, body) (*AdminOrganizationGroupRoleNewResponse, error)

post /organization/groups/{group_id}/roles

Assigns an organization role to a group within the organization.

Parameters

  • groupID string

  • body AdminOrganizationGroupRoleNewParams

    • RoleID param.Field[string]

      Identifier of the role to assign.

Returns

  • type AdminOrganizationGroupRoleNewResponse struct{…}

    Role assignment linking a group to a role.

    • Group AdminOrganizationGroupRoleNewResponseGroup

      Summary information about a group returned in role assignment responses.

      • ID string

        Identifier for the group.

      • CreatedAt int64

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

      • Name string

        Display name of the group.

      • Object Group

        Always group.

        • const GroupGroup Group = "group"
      • ScimManaged bool

        Whether the group is managed through SCIM.

    • Object GroupRole

      Always group.role.

      • const GroupRoleGroupRole GroupRole = "group.role"
    • Role Role

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

      • ID string

        Identifier for the role.

      • Description string

        Optional description of the role.

      • Name string

        Unique name for the role.

      • Object Role

        Always role.

        • const RoleRole Role = "role"
      • Permissions []string

        Permissions granted by the role.

      • PredefinedRole bool

        Whether the role is predefined and managed by OpenAI.

      • ResourceType string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Groups.Roles.New(
    context.TODO(),
    "group_id",
    openai.AdminOrganizationGroupRoleNewParams{
      RoleID: "role_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.Group)
}

Response

{
  "group": {
    "id": "id",
    "created_at": 0,
    "name": "name",
    "object": "group",
    "scim_managed": true
  },
  "object": "group.role",
  "role": {
    "id": "id",
    "description": "description",
    "name": "name",
    "object": "role",
    "permissions": [
      "string"
    ],
    "predefined_role": true,
    "resource_type": "resource_type"
  }
}

Unassign organization role from group

client.Admin.Organization.Groups.Roles.Delete(ctx, groupID, roleID) (*AdminOrganizationGroupRoleDeleteResponse, error)

delete /organization/groups/{group_id}/roles/{role_id}

Unassigns an organization role from a group within the organization.

Parameters

  • groupID string

  • roleID string

Returns

  • type AdminOrganizationGroupRoleDeleteResponse struct{…}

    Confirmation payload returned after unassigning a role.

    • Deleted bool

      Whether the assignment was removed.

    • Object string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Groups.Roles.Delete(
    context.TODO(),
    "group_id",
    "role_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.Deleted)
}

Response

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

Roles

List organization roles

client.Admin.Organization.Roles.List(ctx, query) (*NextCursorPage[Role], error)

get /organization/roles

Lists the roles configured for the organization.

Parameters

  • query AdminOrganizationRoleListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

      A limit on the number of roles to return. Defaults to 1000.

    • Order param.Field[AdminOrganizationRoleListParamsOrder]

      Sort order for the returned roles.

      • const AdminOrganizationRoleListParamsOrderAsc AdminOrganizationRoleListParamsOrder = "asc"

      • const AdminOrganizationRoleListParamsOrderDesc AdminOrganizationRoleListParamsOrder = "desc"

Returns

  • type Role struct{…}

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

    • ID string

      Identifier for the role.

    • Description string

      Optional description of the role.

    • Name string

      Unique name for the role.

    • Object Role

      Always role.

      • const RoleRole Role = "role"
    • Permissions []string

      Permissions granted by the role.

    • PredefinedRole bool

      Whether the role is predefined and managed by OpenAI.

    • ResourceType string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Roles.List(context.TODO(), openai.AdminOrganizationRoleListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "description": "description",
      "name": "name",
      "object": "role",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Create organization role

client.Admin.Organization.Roles.New(ctx, body) (*Role, error)

post /organization/roles

Creates a custom role for the organization.

Parameters

  • body AdminOrganizationRoleNewParams

    • Permissions param.Field[[]string]

      Permissions to grant to the role.

    • RoleName param.Field[string]

      Unique name for the role.

    • Description param.Field[string]

      Optional description of the role.

Returns

  • type Role struct{…}

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

    • ID string

      Identifier for the role.

    • Description string

      Optional description of the role.

    • Name string

      Unique name for the role.

    • Object Role

      Always role.

      • const RoleRole Role = "role"
    • Permissions []string

      Permissions granted by the role.

    • PredefinedRole bool

      Whether the role is predefined and managed by OpenAI.

    • ResourceType string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Roles.New(context.TODO(), openai.AdminOrganizationRoleNewParams{
    Permissions: []string{"string"},
    RoleName: "role_name",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.ID)
}

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Update organization role

client.Admin.Organization.Roles.Update(ctx, roleID, body) (*Role, error)

post /organization/roles/{role_id}

Updates an existing organization role.

Parameters

  • roleID string

  • body AdminOrganizationRoleUpdateParams

    • Description param.Field[string]

      New description for the role.

    • Permissions param.Field[[]string]

      Updated set of permissions for the role.

    • RoleName param.Field[string]

      New name for the role.

Returns

  • type Role struct{…}

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

    • ID string

      Identifier for the role.

    • Description string

      Optional description of the role.

    • Name string

      Unique name for the role.

    • Object Role

      Always role.

      • const RoleRole Role = "role"
    • Permissions []string

      Permissions granted by the role.

    • PredefinedRole bool

      Whether the role is predefined and managed by OpenAI.

    • ResourceType string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Roles.Update(
    context.TODO(),
    "role_id",
    openai.AdminOrganizationRoleUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.ID)
}

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Delete organization role

client.Admin.Organization.Roles.Delete(ctx, roleID) (*AdminOrganizationRoleDeleteResponse, error)

delete /organization/roles/{role_id}

Deletes a custom role from the organization.

Parameters

  • roleID string

Returns

  • type AdminOrganizationRoleDeleteResponse struct{…}

    Confirmation payload returned after deleting a role.

    • ID string

      Identifier of the deleted role.

    • Deleted bool

      Whether the role was deleted.

    • Object RoleDeleted

      Always role.deleted.

      • const RoleDeletedRoleDeleted RoleDeleted = "role.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Roles.Delete(context.TODO(), "role_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.ID)
}

Response

{
  "id": "id",
  "deleted": true,
  "object": "role.deleted"
}

Domain Types

Role

  • type Role struct{…}

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

    • ID string

      Identifier for the role.

    • Description string

      Optional description of the role.

    • Name string

      Unique name for the role.

    • Object Role

      Always role.

      • const RoleRole Role = "role"
    • Permissions []string

      Permissions granted by the role.

    • PredefinedRole bool

      Whether the role is predefined and managed by OpenAI.

    • ResourceType string

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

Certificates

List organization certificates

client.Admin.Organization.Certificates.List(ctx, query) (*ConversationCursorPage[AdminOrganizationCertificateListResponse], error)

get /organization/certificates

List uploaded certificates for this organization.

Parameters

  • query AdminOrganizationCertificateListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

    • Order param.Field[AdminOrganizationCertificateListParamsOrder]

      Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

      • const AdminOrganizationCertificateListParamsOrderAsc AdminOrganizationCertificateListParamsOrder = "asc"

      • const AdminOrganizationCertificateListParamsOrderDesc AdminOrganizationCertificateListParamsOrder = "desc"

Returns

  • type AdminOrganizationCertificateListResponse struct{…}

    Represents an individual certificate configured at the organization level.

    • ID string

      The identifier, which can be referenced in API endpoints

    • Active bool

      Whether the certificate is currently active at the organization level.

    • CertificateDetails AdminOrganizationCertificateListResponseCertificateDetails

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object OrganizationCertificate

      The object type, which is always organization.certificate.

      • const OrganizationCertificateOrganizationCertificate OrganizationCertificate = "organization.certificate"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Certificates.List(context.TODO(), openai.AdminOrganizationCertificateListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.certificate"
    }
  ],
  "first_id": "cert_abc",
  "has_more": true,
  "last_id": "cert_abc",
  "object": "list"
}

Upload certificate

client.Admin.Organization.Certificates.New(ctx, body) (*Certificate, error)

post /organization/certificates

Upload a certificate to the organization. This does not automatically activate the certificate.

Organizations can upload up to 50 certificates.

Parameters

  • body AdminOrganizationCertificateNewParams

    • Certificate param.Field[string]

      The certificate content in PEM format

    • Name param.Field[string]

      An optional name for the certificate

Returns

  • type Certificate struct{…}

    Represents an individual certificate uploaded to the organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CertificateDetails CertificateCertificateDetails

      • Content string

        The content of the certificate in PEM format.

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object CertificateObject

      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.

      • const CertificateObjectCertificate CertificateObject = "certificate"

      • const CertificateObjectOrganizationCertificate CertificateObject = "organization.certificate"

      • const CertificateObjectOrganizationProjectCertificate CertificateObject = "organization.project.certificate"

    • Active bool

      Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  certificate, err := client.Admin.Organization.Certificates.New(context.TODO(), openai.AdminOrganizationCertificateNewParams{
    Certificate: "certificate",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", certificate.ID)
}

Response

{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}

Get certificate

client.Admin.Organization.Certificates.Get(ctx, certificateID, query) (*Certificate, error)

get /organization/certificates/{certificate_id}

Get a certificate that has been uploaded to the organization.

You can get a certificate regardless of whether it is active or not.

Parameters

  • certificateID string

  • query AdminOrganizationCertificateGetParams

    • Include param.Field[[]string]

      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.

      • const AdminOrganizationCertificateGetParamsIncludeContent AdminOrganizationCertificateGetParamsInclude = "content"

Returns

  • type Certificate struct{…}

    Represents an individual certificate uploaded to the organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CertificateDetails CertificateCertificateDetails

      • Content string

        The content of the certificate in PEM format.

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object CertificateObject

      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.

      • const CertificateObjectCertificate CertificateObject = "certificate"

      • const CertificateObjectOrganizationCertificate CertificateObject = "organization.certificate"

      • const CertificateObjectOrganizationProjectCertificate CertificateObject = "organization.project.certificate"

    • Active bool

      Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  certificate, err := client.Admin.Organization.Certificates.Get(
    context.TODO(),
    "certificate_id",
    openai.AdminOrganizationCertificateGetParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", certificate.ID)
}

Response

{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}

Modify certificate

client.Admin.Organization.Certificates.Update(ctx, certificateID, body) (*Certificate, error)

post /organization/certificates/{certificate_id}

Modify a certificate. Note that only the name can be modified.

Parameters

  • certificateID string

  • body AdminOrganizationCertificateUpdateParams

    • Name param.Field[string]

      The updated name for the certificate

Returns

  • type Certificate struct{…}

    Represents an individual certificate uploaded to the organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CertificateDetails CertificateCertificateDetails

      • Content string

        The content of the certificate in PEM format.

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object CertificateObject

      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.

      • const CertificateObjectCertificate CertificateObject = "certificate"

      • const CertificateObjectOrganizationCertificate CertificateObject = "organization.certificate"

      • const CertificateObjectOrganizationProjectCertificate CertificateObject = "organization.project.certificate"

    • Active bool

      Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  certificate, err := client.Admin.Organization.Certificates.Update(
    context.TODO(),
    "certificate_id",
    openai.AdminOrganizationCertificateUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", certificate.ID)
}

Response

{
  "id": "id",
  "certificate_details": {
    "content": "content",
    "expires_at": 0,
    "valid_at": 0
  },
  "created_at": 0,
  "name": "name",
  "object": "certificate",
  "active": true
}

Delete certificate

client.Admin.Organization.Certificates.Delete(ctx, certificateID) (*AdminOrganizationCertificateDeleteResponse, error)

delete /organization/certificates/{certificate_id}

Delete a certificate from the organization.

The certificate must be inactive for the organization and all projects.

Parameters

  • certificateID string

Returns

  • type AdminOrganizationCertificateDeleteResponse struct{…}

    • ID string

      The ID of the certificate that was deleted.

    • Object CertificateDeleted

      The object type, must be certificate.deleted.

      • const CertificateDeletedCertificateDeleted CertificateDeleted = "certificate.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  certificate, err := client.Admin.Organization.Certificates.Delete(context.TODO(), "certificate_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", certificate.ID)
}

Response

{
  "id": "id",
  "object": "certificate.deleted"
}

Activate certificates for organization

client.Admin.Organization.Certificates.Activate(ctx, body) (*Page[AdminOrganizationCertificateActivateResponse], error)

post /organization/certificates/activate

Activate certificates at the organization level.

You can atomically and idempotently activate up to 10 certificates at a time.

Parameters

  • body AdminOrganizationCertificateActivateParams

    • CertificateIDs param.Field[[]string]

Returns

  • type AdminOrganizationCertificateActivateResponse struct{…}

    Represents an individual certificate configured at the organization level.

    • ID string

      The identifier, which can be referenced in API endpoints

    • Active bool

      Whether the certificate is currently active at the organization level.

    • CertificateDetails AdminOrganizationCertificateActivateResponseCertificateDetails

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object OrganizationCertificate

      The object type, which is always organization.certificate.

      • const OrganizationCertificateOrganizationCertificate OrganizationCertificate = "organization.certificate"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Certificates.Activate(context.TODO(), openai.AdminOrganizationCertificateActivateParams{
    CertificateIDs: []string{"cert_abc"},
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.certificate"
    }
  ],
  "object": "organization.certificate.activation"
}

Deactivate certificates for organization

client.Admin.Organization.Certificates.Deactivate(ctx, body) (*Page[AdminOrganizationCertificateDeactivateResponse], error)

post /organization/certificates/deactivate

Deactivate certificates at the organization level.

You can atomically and idempotently deactivate up to 10 certificates at a time.

Parameters

  • body AdminOrganizationCertificateDeactivateParams

    • CertificateIDs param.Field[[]string]

Returns

  • type AdminOrganizationCertificateDeactivateResponse struct{…}

    Represents an individual certificate configured at the organization level.

    • ID string

      The identifier, which can be referenced in API endpoints

    • Active bool

      Whether the certificate is currently active at the organization level.

    • CertificateDetails AdminOrganizationCertificateDeactivateResponseCertificateDetails

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object OrganizationCertificate

      The object type, which is always organization.certificate.

      • const OrganizationCertificateOrganizationCertificate OrganizationCertificate = "organization.certificate"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Certificates.Deactivate(context.TODO(), openai.AdminOrganizationCertificateDeactivateParams{
    CertificateIDs: []string{"cert_abc"},
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.certificate"
    }
  ],
  "object": "organization.certificate.deactivation"
}

Domain Types

Certificate

  • type Certificate struct{…}

    Represents an individual certificate uploaded to the organization.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CertificateDetails CertificateCertificateDetails

      • Content string

        The content of the certificate in PEM format.

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object CertificateObject

      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.

      • const CertificateObjectCertificate CertificateObject = "certificate"

      • const CertificateObjectOrganizationCertificate CertificateObject = "organization.certificate"

      • const CertificateObjectOrganizationProjectCertificate CertificateObject = "organization.project.certificate"

    • Active bool

      Whether the certificate is currently active at the specified scope. Not returned when getting details for a specific certificate.

Projects

List projects

client.Admin.Organization.Projects.List(ctx, query) (*ConversationCursorPage[Project], error)

get /organization/projects

Returns a list of projects.

Parameters

  • query AdminOrganizationProjectListParams

    • After param.Field[string]

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

    • IncludeArchived param.Field[bool]

      If true returns all projects including those that have been archived. Archived projects are not included by default.

    • Limit param.Field[int64]

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

Returns

  • type Project struct{…}

    Represents an individual project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationProject

      The object type, which is always organization.project

      • const OrganizationProjectOrganizationProject OrganizationProject = "organization.project"
    • ArchivedAt int64

      The Unix timestamp (in seconds) of when the project was archived or null.

    • ExternalKeyID string

      The external key associated with the project.

    • Name string

      The name of the project. This appears in reporting.

    • Status string

      active or archived

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.List(context.TODO(), openai.AdminOrganizationProjectListParams{

  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "object": "organization.project",
      "archived_at": 0,
      "external_key_id": "external_key_id",
      "name": "name",
      "status": "status"
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Create project

client.Admin.Organization.Projects.New(ctx, body) (*Project, error)

post /organization/projects

Create a new project in the organization. Projects can be created and archived, but cannot be deleted.

Parameters

  • body AdminOrganizationProjectNewParams

    • Name param.Field[string]

      The friendly name of the project, this name appears in reports.

    • ExternalKeyID param.Field[string]

      External key ID to associate with the project.

    • Geography param.Field[string]

      Create the project with the specified data residency region. Your organization must have access to Data residency functionality in order to use. See data residency controls to review the functionality and limitations of setting this field.

Returns

  • type Project struct{…}

    Represents an individual project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationProject

      The object type, which is always organization.project

      • const OrganizationProjectOrganizationProject OrganizationProject = "organization.project"
    • ArchivedAt int64

      The Unix timestamp (in seconds) of when the project was archived or null.

    • ExternalKeyID string

      The external key associated with the project.

    • Name string

      The name of the project. This appears in reporting.

    • Status string

      active or archived

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  project, err := client.Admin.Organization.Projects.New(context.TODO(), openai.AdminOrganizationProjectNewParams{
    Name: "name",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", project.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}

Retrieve project

client.Admin.Organization.Projects.Get(ctx, projectID) (*Project, error)

get /organization/projects/{project_id}

Retrieves a project.

Parameters

  • projectID string

Returns

  • type Project struct{…}

    Represents an individual project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationProject

      The object type, which is always organization.project

      • const OrganizationProjectOrganizationProject OrganizationProject = "organization.project"
    • ArchivedAt int64

      The Unix timestamp (in seconds) of when the project was archived or null.

    • ExternalKeyID string

      The external key associated with the project.

    • Name string

      The name of the project. This appears in reporting.

    • Status string

      active or archived

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  project, err := client.Admin.Organization.Projects.Get(context.TODO(), "project_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", project.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}

Modify project

client.Admin.Organization.Projects.Update(ctx, projectID, body) (*Project, error)

post /organization/projects/{project_id}

Modifies a project in the organization.

Parameters

  • projectID string

  • body AdminOrganizationProjectUpdateParams

    • ExternalKeyID param.Field[string]

      External key ID to associate with the project.

    • Geography param.Field[string]

      Geography for the project.

    • Name param.Field[string]

      The updated name of the project, this name appears in reports.

Returns

  • type Project struct{…}

    Represents an individual project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationProject

      The object type, which is always organization.project

      • const OrganizationProjectOrganizationProject OrganizationProject = "organization.project"
    • ArchivedAt int64

      The Unix timestamp (in seconds) of when the project was archived or null.

    • ExternalKeyID string

      The external key associated with the project.

    • Name string

      The name of the project. This appears in reporting.

    • Status string

      active or archived

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  project, err := client.Admin.Organization.Projects.Update(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", project.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}

Archive project

client.Admin.Organization.Projects.Archive(ctx, projectID) (*Project, error)

post /organization/projects/{project_id}/archive

Archives a project in the organization. Archived projects cannot be used or updated.

Parameters

  • projectID string

Returns

  • type Project struct{…}

    Represents an individual project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationProject

      The object type, which is always organization.project

      • const OrganizationProjectOrganizationProject OrganizationProject = "organization.project"
    • ArchivedAt int64

      The Unix timestamp (in seconds) of when the project was archived or null.

    • ExternalKeyID string

      The external key associated with the project.

    • Name string

      The name of the project. This appears in reporting.

    • Status string

      active or archived

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  project, err := client.Admin.Organization.Projects.Archive(context.TODO(), "project_id")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", project.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "object": "organization.project",
  "archived_at": 0,
  "external_key_id": "external_key_id",
  "name": "name",
  "status": "status"
}

Domain Types

Project

  • type Project struct{…}

    Represents an individual project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Object OrganizationProject

      The object type, which is always organization.project

      • const OrganizationProjectOrganizationProject OrganizationProject = "organization.project"
    • ArchivedAt int64

      The Unix timestamp (in seconds) of when the project was archived or null.

    • ExternalKeyID string

      The external key associated with the project.

    • Name string

      The name of the project. This appears in reporting.

    • Status string

      active or archived

Users

List project users

client.Admin.Organization.Projects.Users.List(ctx, projectID, query) (*ConversationCursorPage[ProjectUser], error)

get /organization/projects/{project_id}/users

Returns a list of users in the project.

Parameters

  • projectID string

  • query AdminOrganizationProjectUserListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

Returns

  • type ProjectUser struct{…}

    Represents an individual user in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationProjectUser

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

      • const OrganizationProjectUserOrganizationProjectUser OrganizationProjectUser = "organization.project.user"
    • Role string

      owner or member

    • Email string

      The email address of the user

    • Name string

      The name of the user

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.Users.List(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectUserListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "added_at": 0,
      "object": "organization.project.user",
      "role": "role",
      "email": "email",
      "name": "name"
    }
  ],
  "has_more": true,
  "object": "object",
  "first_id": "first_id",
  "last_id": "last_id"
}

Create project user

client.Admin.Organization.Projects.Users.New(ctx, projectID, body) (*ProjectUser, error)

post /organization/projects/{project_id}/users

Adds a user to the project. Users must already be members of the organization to be added to a project.

Parameters

  • projectID string

  • body AdminOrganizationProjectUserNewParams

    • Role param.Field[string]

      owner or member

    • Email param.Field[string]

      Email of the user to add.

    • UserID param.Field[string]

      The ID of the user.

Returns

  • type ProjectUser struct{…}

    Represents an individual user in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationProjectUser

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

      • const OrganizationProjectUserOrganizationProjectUser OrganizationProjectUser = "organization.project.user"
    • Role string

      owner or member

    • Email string

      The email address of the user

    • Name string

      The name of the user

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  projectUser, err := client.Admin.Organization.Projects.Users.New(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectUserNewParams{
      Role: "role",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", projectUser.ID)
}

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}

Retrieve project user

client.Admin.Organization.Projects.Users.Get(ctx, projectID, userID) (*ProjectUser, error)

get /organization/projects/{project_id}/users/{user_id}

Retrieves a user in the project.

Parameters

  • projectID string

  • userID string

Returns

  • type ProjectUser struct{…}

    Represents an individual user in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationProjectUser

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

      • const OrganizationProjectUserOrganizationProjectUser OrganizationProjectUser = "organization.project.user"
    • Role string

      owner or member

    • Email string

      The email address of the user

    • Name string

      The name of the user

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  projectUser, err := client.Admin.Organization.Projects.Users.Get(
    context.TODO(),
    "project_id",
    "user_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", projectUser.ID)
}

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}

Modify project user

client.Admin.Organization.Projects.Users.Update(ctx, projectID, userID, body) (*ProjectUser, error)

post /organization/projects/{project_id}/users/{user_id}

Modifies a user's role in the project.

Parameters

  • projectID string

  • userID string

  • body AdminOrganizationProjectUserUpdateParams

    • Role param.Field[string]

      owner or member

Returns

  • type ProjectUser struct{…}

    Represents an individual user in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationProjectUser

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

      • const OrganizationProjectUserOrganizationProjectUser OrganizationProjectUser = "organization.project.user"
    • Role string

      owner or member

    • Email string

      The email address of the user

    • Name string

      The name of the user

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  projectUser, err := client.Admin.Organization.Projects.Users.Update(
    context.TODO(),
    "project_id",
    "user_id",
    openai.AdminOrganizationProjectUserUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", projectUser.ID)
}

Response

{
  "id": "id",
  "added_at": 0,
  "object": "organization.project.user",
  "role": "role",
  "email": "email",
  "name": "name"
}

Delete project user

client.Admin.Organization.Projects.Users.Delete(ctx, projectID, userID) (*AdminOrganizationProjectUserDeleteResponse, error)

delete /organization/projects/{project_id}/users/{user_id}

Deletes a user from the project.

Returns confirmation of project user deletion, or an error if the project is archived (archived projects have no users).

Parameters

  • projectID string

  • userID string

Returns

  • type AdminOrganizationProjectUserDeleteResponse struct{…}

    • ID string

    • Deleted bool

    • Object OrganizationProjectUserDeleted

      • const OrganizationProjectUserDeletedOrganizationProjectUserDeleted OrganizationProjectUserDeleted = "organization.project.user.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  user, err := client.Admin.Organization.Projects.Users.Delete(
    context.TODO(),
    "project_id",
    "user_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", user.ID)
}

Response

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

Domain Types

Project User

  • type ProjectUser struct{…}

    Represents an individual user in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • AddedAt int64

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

    • Object OrganizationProjectUser

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

      • const OrganizationProjectUserOrganizationProjectUser OrganizationProjectUser = "organization.project.user"
    • Role string

      owner or member

    • Email string

      The email address of the user

    • Name string

      The name of the user

Roles

List project user role assignments

client.Admin.Organization.Projects.Users.Roles.List(ctx, projectID, userID, query) (*NextCursorPage[AdminOrganizationProjectUserRoleListResponse], error)

get /projects/{project_id}/users/{user_id}/roles

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

Parameters

  • projectID string

  • userID string

  • query AdminOrganizationProjectUserRoleListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

    • Order param.Field[AdminOrganizationProjectUserRoleListParamsOrder]

      Sort order for the returned project roles.

      • const AdminOrganizationProjectUserRoleListParamsOrderAsc AdminOrganizationProjectUserRoleListParamsOrder = "asc"

      • const AdminOrganizationProjectUserRoleListParamsOrderDesc AdminOrganizationProjectUserRoleListParamsOrder = "desc"

Returns

  • type AdminOrganizationProjectUserRoleListResponse struct{…}

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

    • ID string

      Identifier for the role.

    • CreatedAt int64

      When the role was created.

    • CreatedBy string

      Identifier of the actor who created the role.

    • CreatedByUserObj map[string, any]

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

    • Description string

      Description of the role.

    • Metadata map[string, any]

      Arbitrary metadata stored on the role.

    • Name string

      Name of the role.

    • Permissions []string

      Permissions associated with the role.

    • PredefinedRole bool

      Whether the role is predefined by OpenAI.

    • ResourceType string

      Resource type the role applies to.

    • UpdatedAt int64

      When the role was last updated.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.Users.Roles.List(
    context.TODO(),
    "project_id",
    "user_id",
    openai.AdminOrganizationProjectUserRoleListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "created_by": "created_by",
      "created_by_user_obj": {
        "foo": "bar"
      },
      "description": "description",
      "metadata": {
        "foo": "bar"
      },
      "name": "name",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type",
      "updated_at": 0
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Assign project role to user

client.Admin.Organization.Projects.Users.Roles.New(ctx, projectID, userID, body) (*AdminOrganizationProjectUserRoleNewResponse, error)

post /projects/{project_id}/users/{user_id}/roles

Assigns a project role to a user within a project.

Parameters

  • projectID string

  • userID string

  • body AdminOrganizationProjectUserRoleNewParams

    • RoleID param.Field[string]

      Identifier of the role to assign.

Returns

  • type AdminOrganizationProjectUserRoleNewResponse struct{…}

    Role assignment linking a user to a role.

    • Object UserRole

      Always user.role.

      • const UserRoleUserRole UserRole = "user.role"
    • Role Role

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

      • ID string

        Identifier for the role.

      • Description string

        Optional description of the role.

      • Name string

        Unique name for the role.

      • Object Role

        Always role.

        • const RoleRole Role = "role"
      • Permissions []string

        Permissions granted by the role.

      • PredefinedRole bool

        Whether the role is predefined and managed by OpenAI.

      • ResourceType string

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

    • User OrganizationUser

      Represents an individual user within an organization.

      • ID string

        The identifier, which can be referenced in API endpoints

      • AddedAt int64

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

      • Object OrganizationUser

        The object type, which is always organization.user

        • const OrganizationUserOrganizationUser OrganizationUser = "organization.user"
      • APIKeyLastUsedAt int64

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

      • Created int64

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

      • DeveloperPersona string

        The developer persona metadata for the user.

      • Email string

        The email address of the user

      • IsDefault bool

        Whether this is the organization's default user.

      • IsScaleTierAuthorizedPurchaser bool

        Whether the user is an authorized purchaser for Scale Tier.

      • IsScimManaged bool

        Whether the user is managed through SCIM.

      • IsServiceAccount bool

        Whether the user is a service account.

      • Name string

        The name of the user

      • Projects OrganizationUserProjects

        Projects associated with the user, if included.

        • Data []OrganizationUserProjectsData

          • ID string

          • Name string

          • Role string

        • Object List

          • const ListList List = "list"
      • Role string

        owner or reader

      • TechnicalLevel string

        The technical level metadata for the user.

      • User OrganizationUserUser

        Nested user details.

        • ID string

        • Object User

          • const UserUser User = "user"
        • Banned bool

        • BannedAt int64

        • Email string

        • Enabled bool

        • Name string

        • Picture string

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Projects.Users.Roles.New(
    context.TODO(),
    "project_id",
    "user_id",
    openai.AdminOrganizationProjectUserRoleNewParams{
      RoleID: "role_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.Object)
}

Response

{
  "object": "user.role",
  "role": {
    "id": "id",
    "description": "description",
    "name": "name",
    "object": "role",
    "permissions": [
      "string"
    ],
    "predefined_role": true,
    "resource_type": "resource_type"
  },
  "user": {
    "id": "id",
    "added_at": 0,
    "object": "organization.user",
    "api_key_last_used_at": 0,
    "created": 0,
    "developer_persona": "developer_persona",
    "email": "email",
    "is_default": true,
    "is_scale_tier_authorized_purchaser": true,
    "is_scim_managed": true,
    "is_service_account": true,
    "name": "name",
    "projects": {
      "data": [
        {
          "id": "id",
          "name": "name",
          "role": "role"
        }
      ],
      "object": "list"
    },
    "role": "role",
    "technical_level": "technical_level",
    "user": {
      "id": "id",
      "object": "user",
      "banned": true,
      "banned_at": 0,
      "email": "email",
      "enabled": true,
      "name": "name",
      "picture": "picture"
    }
  }
}

Unassign project role from user

client.Admin.Organization.Projects.Users.Roles.Delete(ctx, projectID, userID, roleID) (*AdminOrganizationProjectUserRoleDeleteResponse, error)

delete /projects/{project_id}/users/{user_id}/roles/{role_id}

Unassigns a project role from a user within a project.

Parameters

  • projectID string

  • userID string

  • roleID string

Returns

  • type AdminOrganizationProjectUserRoleDeleteResponse struct{…}

    Confirmation payload returned after unassigning a role.

    • Deleted bool

      Whether the assignment was removed.

    • Object string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Projects.Users.Roles.Delete(
    context.TODO(),
    "project_id",
    "user_id",
    "role_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.Deleted)
}

Response

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

Service Accounts

List project service accounts

client.Admin.Organization.Projects.ServiceAccounts.List(ctx, projectID, query) (*ConversationCursorPage[ProjectServiceAccount], error)

get /organization/projects/{project_id}/service_accounts

Returns a list of service accounts in the project.

Parameters

  • projectID string

  • query AdminOrganizationProjectServiceAccountListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

Returns

  • type ProjectServiceAccount struct{…}

    Represents an individual service account in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Name string

      The name of the service account

    • Object OrganizationProjectServiceAccount

      The object type, which is always organization.project.service_account

      • const OrganizationProjectServiceAccountOrganizationProjectServiceAccount OrganizationProjectServiceAccount = "organization.project.service_account"
    • Role ProjectServiceAccountRole

      owner or member

      • const ProjectServiceAccountRoleOwner ProjectServiceAccountRole = "owner"

      • const ProjectServiceAccountRoleMember ProjectServiceAccountRole = "member"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.ServiceAccounts.List(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectServiceAccountListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "name": "name",
      "object": "organization.project.service_account",
      "role": "owner"
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Create project service account

client.Admin.Organization.Projects.ServiceAccounts.New(ctx, projectID, body) (*AdminOrganizationProjectServiceAccountNewResponse, error)

post /organization/projects/{project_id}/service_accounts

Creates a new service account in the project. This also returns an unredacted API key for the service account.

Parameters

  • projectID string

  • body AdminOrganizationProjectServiceAccountNewParams

    • Name param.Field[string]

      The name of the service account being created.

Returns

  • type AdminOrganizationProjectServiceAccountNewResponse struct{…}

    • ID string

    • APIKey AdminOrganizationProjectServiceAccountNewResponseAPIKey

      • ID string

      • CreatedAt int64

      • Name string

      • Object OrganizationProjectServiceAccountAPIKey

        The object type, which is always organization.project.service_account.api_key

        • const OrganizationProjectServiceAccountAPIKeyOrganizationProjectServiceAccountAPIKey OrganizationProjectServiceAccountAPIKey = "organization.project.service_account.api_key"
      • Value string

    • CreatedAt int64

    • Name string

    • Object OrganizationProjectServiceAccount

      • const OrganizationProjectServiceAccountOrganizationProjectServiceAccount OrganizationProjectServiceAccount = "organization.project.service_account"
    • Role Member

      Service accounts can only have one role of type member

      • const MemberMember Member = "member"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  serviceAccount, err := client.Admin.Organization.Projects.ServiceAccounts.New(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectServiceAccountNewParams{
      Name: "name",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", serviceAccount.ID)
}

Response

{
  "id": "id",
  "api_key": {
    "id": "id",
    "created_at": 0,
    "name": "name",
    "object": "organization.project.service_account.api_key",
    "value": "value"
  },
  "created_at": 0,
  "name": "name",
  "object": "organization.project.service_account",
  "role": "member"
}

Retrieve project service account

client.Admin.Organization.Projects.ServiceAccounts.Get(ctx, projectID, serviceAccountID) (*ProjectServiceAccount, error)

get /organization/projects/{project_id}/service_accounts/{service_account_id}

Retrieves a service account in the project.

Parameters

  • projectID string

  • serviceAccountID string

Returns

  • type ProjectServiceAccount struct{…}

    Represents an individual service account in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Name string

      The name of the service account

    • Object OrganizationProjectServiceAccount

      The object type, which is always organization.project.service_account

      • const OrganizationProjectServiceAccountOrganizationProjectServiceAccount OrganizationProjectServiceAccount = "organization.project.service_account"
    • Role ProjectServiceAccountRole

      owner or member

      • const ProjectServiceAccountRoleOwner ProjectServiceAccountRole = "owner"

      • const ProjectServiceAccountRoleMember ProjectServiceAccountRole = "member"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  projectServiceAccount, err := client.Admin.Organization.Projects.ServiceAccounts.Get(
    context.TODO(),
    "project_id",
    "service_account_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", projectServiceAccount.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "name": "name",
  "object": "organization.project.service_account",
  "role": "owner"
}

Delete project service account

client.Admin.Organization.Projects.ServiceAccounts.Delete(ctx, projectID, serviceAccountID) (*AdminOrganizationProjectServiceAccountDeleteResponse, error)

delete /organization/projects/{project_id}/service_accounts/{service_account_id}

Deletes a service account from the project.

Returns confirmation of service account deletion, or an error if the project is archived (archived projects have no service accounts).

Parameters

  • projectID string

  • serviceAccountID string

Returns

  • type AdminOrganizationProjectServiceAccountDeleteResponse struct{…}

    • ID string

    • Deleted bool

    • Object OrganizationProjectServiceAccountDeleted

      • const OrganizationProjectServiceAccountDeletedOrganizationProjectServiceAccountDeleted OrganizationProjectServiceAccountDeleted = "organization.project.service_account.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  serviceAccount, err := client.Admin.Organization.Projects.ServiceAccounts.Delete(
    context.TODO(),
    "project_id",
    "service_account_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", serviceAccount.ID)
}

Response

{
  "id": "id",
  "deleted": true,
  "object": "organization.project.service_account.deleted"
}

Domain Types

Project Service Account

  • type ProjectServiceAccount struct{…}

    Represents an individual service account in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • Name string

      The name of the service account

    • Object OrganizationProjectServiceAccount

      The object type, which is always organization.project.service_account

      • const OrganizationProjectServiceAccountOrganizationProjectServiceAccount OrganizationProjectServiceAccount = "organization.project.service_account"
    • Role ProjectServiceAccountRole

      owner or member

      • const ProjectServiceAccountRoleOwner ProjectServiceAccountRole = "owner"

      • const ProjectServiceAccountRoleMember ProjectServiceAccountRole = "member"

API Keys

List project API keys

client.Admin.Organization.Projects.APIKeys.List(ctx, projectID, query) (*ConversationCursorPage[ProjectAPIKey], error)

get /organization/projects/{project_id}/api_keys

Returns a list of API keys in the project.

Parameters

  • projectID string

  • query AdminOrganizationProjectAPIKeyListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

Returns

  • type ProjectAPIKey struct{…}

    Represents an individual API key in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • LastUsedAt int64

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

    • Name string

      The name of the API key

    • Object OrganizationProjectAPIKey

      The object type, which is always organization.project.api_key

      • const OrganizationProjectAPIKeyOrganizationProjectAPIKey OrganizationProjectAPIKey = "organization.project.api_key"
    • Owner ProjectAPIKeyOwner

      • ServiceAccount ProjectAPIKeyOwnerServiceAccount

        The service account that owns a project API key.

        • ID string

          The identifier, which can be referenced in API endpoints

        • CreatedAt int64

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

        • Name string

          The name of the service account.

        • Role string

          The service account's project role.

      • Type string

        user or service_account

        • const ProjectAPIKeyOwnerTypeUser ProjectAPIKeyOwnerType = "user"

        • const ProjectAPIKeyOwnerTypeServiceAccount ProjectAPIKeyOwnerType = "service_account"

      • User ProjectAPIKeyOwnerUser

        The user that owns a project API key.

        • ID string

          The identifier, which can be referenced in API endpoints

        • CreatedAt int64

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

        • Email string

          The email address of the user.

        • Name string

          The name of the user.

        • Role string

          The user's project role.

    • RedactedValue string

      The redacted value of the API key

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.APIKeys.List(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectAPIKeyListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "last_used_at": 0,
      "name": "name",
      "object": "organization.project.api_key",
      "owner": {
        "service_account": {
          "id": "id",
          "created_at": 0,
          "name": "name",
          "role": "role"
        },
        "type": "user",
        "user": {
          "id": "id",
          "created_at": 0,
          "email": "email",
          "name": "name",
          "role": "role"
        }
      },
      "redacted_value": "redacted_value"
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Retrieve project API key

client.Admin.Organization.Projects.APIKeys.Get(ctx, projectID, apiKeyID) (*ProjectAPIKey, error)

get /organization/projects/{project_id}/api_keys/{api_key_id}

Retrieves an API key in the project.

Parameters

  • projectID string

  • apiKeyID string

Returns

  • type ProjectAPIKey struct{…}

    Represents an individual API key in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • LastUsedAt int64

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

    • Name string

      The name of the API key

    • Object OrganizationProjectAPIKey

      The object type, which is always organization.project.api_key

      • const OrganizationProjectAPIKeyOrganizationProjectAPIKey OrganizationProjectAPIKey = "organization.project.api_key"
    • Owner ProjectAPIKeyOwner

      • ServiceAccount ProjectAPIKeyOwnerServiceAccount

        The service account that owns a project API key.

        • ID string

          The identifier, which can be referenced in API endpoints

        • CreatedAt int64

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

        • Name string

          The name of the service account.

        • Role string

          The service account's project role.

      • Type string

        user or service_account

        • const ProjectAPIKeyOwnerTypeUser ProjectAPIKeyOwnerType = "user"

        • const ProjectAPIKeyOwnerTypeServiceAccount ProjectAPIKeyOwnerType = "service_account"

      • User ProjectAPIKeyOwnerUser

        The user that owns a project API key.

        • ID string

          The identifier, which can be referenced in API endpoints

        • CreatedAt int64

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

        • Email string

          The email address of the user.

        • Name string

          The name of the user.

        • Role string

          The user's project role.

    • RedactedValue string

      The redacted value of the API key

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  projectAPIKey, err := client.Admin.Organization.Projects.APIKeys.Get(
    context.TODO(),
    "project_id",
    "api_key_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", projectAPIKey.ID)
}

Response

{
  "id": "id",
  "created_at": 0,
  "last_used_at": 0,
  "name": "name",
  "object": "organization.project.api_key",
  "owner": {
    "service_account": {
      "id": "id",
      "created_at": 0,
      "name": "name",
      "role": "role"
    },
    "type": "user",
    "user": {
      "id": "id",
      "created_at": 0,
      "email": "email",
      "name": "name",
      "role": "role"
    }
  },
  "redacted_value": "redacted_value"
}

Delete project API key

client.Admin.Organization.Projects.APIKeys.Delete(ctx, projectID, apiKeyID) (*AdminOrganizationProjectAPIKeyDeleteResponse, error)

delete /organization/projects/{project_id}/api_keys/{api_key_id}

Deletes an API key from the project.

Returns confirmation of the key deletion, or an error if the key belonged to a service account.

Parameters

  • projectID string

  • apiKeyID string

Returns

  • type AdminOrganizationProjectAPIKeyDeleteResponse struct{…}

    • ID string

    • Deleted bool

    • Object OrganizationProjectAPIKeyDeleted

      • const OrganizationProjectAPIKeyDeletedOrganizationProjectAPIKeyDeleted OrganizationProjectAPIKeyDeleted = "organization.project.api_key.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  apiKey, err := client.Admin.Organization.Projects.APIKeys.Delete(
    context.TODO(),
    "project_id",
    "api_key_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", apiKey.ID)
}

Response

{
  "id": "id",
  "deleted": true,
  "object": "organization.project.api_key.deleted"
}

Domain Types

Project API Key

  • type ProjectAPIKey struct{…}

    Represents an individual API key in a project.

    • ID string

      The identifier, which can be referenced in API endpoints

    • CreatedAt int64

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

    • LastUsedAt int64

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

    • Name string

      The name of the API key

    • Object OrganizationProjectAPIKey

      The object type, which is always organization.project.api_key

      • const OrganizationProjectAPIKeyOrganizationProjectAPIKey OrganizationProjectAPIKey = "organization.project.api_key"
    • Owner ProjectAPIKeyOwner

      • ServiceAccount ProjectAPIKeyOwnerServiceAccount

        The service account that owns a project API key.

        • ID string

          The identifier, which can be referenced in API endpoints

        • CreatedAt int64

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

        • Name string

          The name of the service account.

        • Role string

          The service account's project role.

      • Type string

        user or service_account

        • const ProjectAPIKeyOwnerTypeUser ProjectAPIKeyOwnerType = "user"

        • const ProjectAPIKeyOwnerTypeServiceAccount ProjectAPIKeyOwnerType = "service_account"

      • User ProjectAPIKeyOwnerUser

        The user that owns a project API key.

        • ID string

          The identifier, which can be referenced in API endpoints

        • CreatedAt int64

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

        • Email string

          The email address of the user.

        • Name string

          The name of the user.

        • Role string

          The user's project role.

    • RedactedValue string

      The redacted value of the API key

Rate Limits

List project rate limits

client.Admin.Organization.Projects.RateLimits.ListRateLimits(ctx, projectID, query) (*ConversationCursorPage[ProjectRateLimit], error)

get /organization/projects/{project_id}/rate_limits

Returns the rate limits per model for a project.

Parameters

  • projectID string

  • query AdminOrganizationProjectRateLimitListRateLimitsParams

    • After param.Field[string]

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

    • Before param.Field[string]

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

    • Limit param.Field[int64]

      A limit on the number of objects to be returned. The default is 100.

Returns

  • type ProjectRateLimit struct{…}

    Represents a project rate limit config.

    • ID string

      The identifier, which can be referenced in API endpoints.

    • MaxRequestsPer1Minute int64

      The maximum requests per minute.

    • MaxTokensPer1Minute int64

      The maximum tokens per minute.

    • Model string

      The model this rate limit applies to.

    • Object ProjectRateLimit

      The object type, which is always project.rate_limit

      • const ProjectRateLimitProjectRateLimit ProjectRateLimit = "project.rate_limit"
    • Batch1DayMaxInputTokens int64

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

    • MaxAudioMegabytesPer1Minute int64

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

    • MaxImagesPer1Minute int64

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

    • MaxRequestsPer1Day int64

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.RateLimits.ListRateLimits(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectRateLimitListRateLimitsParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "max_requests_per_1_minute": 0,
      "max_tokens_per_1_minute": 0,
      "model": "model",
      "object": "project.rate_limit",
      "batch_1_day_max_input_tokens": 0,
      "max_audio_megabytes_per_1_minute": 0,
      "max_images_per_1_minute": 0,
      "max_requests_per_1_day": 0
    }
  ],
  "has_more": true,
  "object": "list",
  "first_id": "first_id",
  "last_id": "last_id"
}

Modify project rate limit

client.Admin.Organization.Projects.RateLimits.UpdateRateLimit(ctx, projectID, rateLimitID, body) (*ProjectRateLimit, error)

post /organization/projects/{project_id}/rate_limits/{rate_limit_id}

Updates a project rate limit.

Parameters

  • projectID string

  • rateLimitID string

  • body AdminOrganizationProjectRateLimitUpdateRateLimitParams

    • Batch1DayMaxInputTokens param.Field[int64]

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

    • MaxAudioMegabytesPer1Minute param.Field[int64]

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

    • MaxImagesPer1Minute param.Field[int64]

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

    • MaxRequestsPer1Day param.Field[int64]

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

    • MaxRequestsPer1Minute param.Field[int64]

      The maximum requests per minute.

    • MaxTokensPer1Minute param.Field[int64]

      The maximum tokens per minute.

Returns

  • type ProjectRateLimit struct{…}

    Represents a project rate limit config.

    • ID string

      The identifier, which can be referenced in API endpoints.

    • MaxRequestsPer1Minute int64

      The maximum requests per minute.

    • MaxTokensPer1Minute int64

      The maximum tokens per minute.

    • Model string

      The model this rate limit applies to.

    • Object ProjectRateLimit

      The object type, which is always project.rate_limit

      • const ProjectRateLimitProjectRateLimit ProjectRateLimit = "project.rate_limit"
    • Batch1DayMaxInputTokens int64

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

    • MaxAudioMegabytesPer1Minute int64

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

    • MaxImagesPer1Minute int64

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

    • MaxRequestsPer1Day int64

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  projectRateLimit, err := client.Admin.Organization.Projects.RateLimits.UpdateRateLimit(
    context.TODO(),
    "project_id",
    "rate_limit_id",
    openai.AdminOrganizationProjectRateLimitUpdateRateLimitParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", projectRateLimit.ID)
}

Response

{
  "id": "id",
  "max_requests_per_1_minute": 0,
  "max_tokens_per_1_minute": 0,
  "model": "model",
  "object": "project.rate_limit",
  "batch_1_day_max_input_tokens": 0,
  "max_audio_megabytes_per_1_minute": 0,
  "max_images_per_1_minute": 0,
  "max_requests_per_1_day": 0
}

Domain Types

Project Rate Limit

  • type ProjectRateLimit struct{…}

    Represents a project rate limit config.

    • ID string

      The identifier, which can be referenced in API endpoints.

    • MaxRequestsPer1Minute int64

      The maximum requests per minute.

    • MaxTokensPer1Minute int64

      The maximum tokens per minute.

    • Model string

      The model this rate limit applies to.

    • Object ProjectRateLimit

      The object type, which is always project.rate_limit

      • const ProjectRateLimitProjectRateLimit ProjectRateLimit = "project.rate_limit"
    • Batch1DayMaxInputTokens int64

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

    • MaxAudioMegabytesPer1Minute int64

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

    • MaxImagesPer1Minute int64

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

    • MaxRequestsPer1Day int64

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

Groups

List project groups

client.Admin.Organization.Projects.Groups.List(ctx, projectID, query) (*NextCursorPage[ProjectGroup], error)

get /organization/projects/{project_id}/groups

Lists the groups that have access to a project.

Parameters

  • projectID string

  • query AdminOrganizationProjectGroupListParams

    • After param.Field[string]

      Cursor for pagination. Provide the ID of the last group from the previous response to fetch the next page.

    • Limit param.Field[int64]

      A limit on the number of project groups to return. Defaults to 20.

    • Order param.Field[AdminOrganizationProjectGroupListParamsOrder]

      Sort order for the returned groups.

      • const AdminOrganizationProjectGroupListParamsOrderAsc AdminOrganizationProjectGroupListParamsOrder = "asc"

      • const AdminOrganizationProjectGroupListParamsOrderDesc AdminOrganizationProjectGroupListParamsOrder = "desc"

Returns

  • type ProjectGroup struct{…}

    Details about a group's membership in a project.

    • CreatedAt int64

      Unix timestamp (in seconds) when the group was granted project access.

    • GroupID string

      Identifier of the group that has access to the project.

    • GroupName string

      Display name of the group.

    • GroupType string

      The type of the group.

    • Object ProjectGroup

      Always project.group.

      • const ProjectGroupProjectGroup ProjectGroup = "project.group"
    • ProjectID string

      Identifier of the project.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.Groups.List(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectGroupListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "created_at": 0,
      "group_id": "group_id",
      "group_name": "group_name",
      "group_type": "group_type",
      "object": "project.group",
      "project_id": "project_id"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Add project group

client.Admin.Organization.Projects.Groups.New(ctx, projectID, body) (*ProjectGroup, error)

post /organization/projects/{project_id}/groups

Grants a group access to a project.

Parameters

  • projectID string

  • body AdminOrganizationProjectGroupNewParams

    • GroupID param.Field[string]

      Identifier of the group to add to the project.

    • Role param.Field[string]

      Identifier of the project role to grant to the group.

Returns

  • type ProjectGroup struct{…}

    Details about a group's membership in a project.

    • CreatedAt int64

      Unix timestamp (in seconds) when the group was granted project access.

    • GroupID string

      Identifier of the group that has access to the project.

    • GroupName string

      Display name of the group.

    • GroupType string

      The type of the group.

    • Object ProjectGroup

      Always project.group.

      • const ProjectGroupProjectGroup ProjectGroup = "project.group"
    • ProjectID string

      Identifier of the project.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  projectGroup, err := client.Admin.Organization.Projects.Groups.New(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectGroupNewParams{
      GroupID: "group_id",
      Role: "role",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", projectGroup.GroupID)
}

Response

{
  "created_at": 0,
  "group_id": "group_id",
  "group_name": "group_name",
  "group_type": "group_type",
  "object": "project.group",
  "project_id": "project_id"
}

Remove project group

client.Admin.Organization.Projects.Groups.Delete(ctx, projectID, groupID) (*AdminOrganizationProjectGroupDeleteResponse, error)

delete /organization/projects/{project_id}/groups/{group_id}

Revokes a group's access to a project.

Parameters

  • projectID string

  • groupID string

Returns

  • type AdminOrganizationProjectGroupDeleteResponse struct{…}

    Confirmation payload returned after removing a group from a project.

    • Deleted bool

      Whether the group membership in the project was removed.

    • Object ProjectGroupDeleted

      Always project.group.deleted.

      • const ProjectGroupDeletedProjectGroupDeleted ProjectGroupDeleted = "project.group.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  group, err := client.Admin.Organization.Projects.Groups.Delete(
    context.TODO(),
    "project_id",
    "group_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", group.Deleted)
}

Response

{
  "deleted": true,
  "object": "project.group.deleted"
}

Domain Types

Project Group

  • type ProjectGroup struct{…}

    Details about a group's membership in a project.

    • CreatedAt int64

      Unix timestamp (in seconds) when the group was granted project access.

    • GroupID string

      Identifier of the group that has access to the project.

    • GroupName string

      Display name of the group.

    • GroupType string

      The type of the group.

    • Object ProjectGroup

      Always project.group.

      • const ProjectGroupProjectGroup ProjectGroup = "project.group"
    • ProjectID string

      Identifier of the project.

Roles

List project group role assignments

client.Admin.Organization.Projects.Groups.Roles.List(ctx, projectID, groupID, query) (*NextCursorPage[AdminOrganizationProjectGroupRoleListResponse], error)

get /projects/{project_id}/groups/{group_id}/roles

Lists the project roles assigned to a group within a project.

Parameters

  • projectID string

  • groupID string

  • query AdminOrganizationProjectGroupRoleListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

    • Order param.Field[AdminOrganizationProjectGroupRoleListParamsOrder]

      Sort order for the returned project roles.

      • const AdminOrganizationProjectGroupRoleListParamsOrderAsc AdminOrganizationProjectGroupRoleListParamsOrder = "asc"

      • const AdminOrganizationProjectGroupRoleListParamsOrderDesc AdminOrganizationProjectGroupRoleListParamsOrder = "desc"

Returns

  • type AdminOrganizationProjectGroupRoleListResponse struct{…}

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

    • ID string

      Identifier for the role.

    • CreatedAt int64

      When the role was created.

    • CreatedBy string

      Identifier of the actor who created the role.

    • CreatedByUserObj map[string, any]

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

    • Description string

      Description of the role.

    • Metadata map[string, any]

      Arbitrary metadata stored on the role.

    • Name string

      Name of the role.

    • Permissions []string

      Permissions associated with the role.

    • PredefinedRole bool

      Whether the role is predefined by OpenAI.

    • ResourceType string

      Resource type the role applies to.

    • UpdatedAt int64

      When the role was last updated.

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.Groups.Roles.List(
    context.TODO(),
    "project_id",
    "group_id",
    openai.AdminOrganizationProjectGroupRoleListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "created_at": 0,
      "created_by": "created_by",
      "created_by_user_obj": {
        "foo": "bar"
      },
      "description": "description",
      "metadata": {
        "foo": "bar"
      },
      "name": "name",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type",
      "updated_at": 0
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Assign project role to group

client.Admin.Organization.Projects.Groups.Roles.New(ctx, projectID, groupID, body) (*AdminOrganizationProjectGroupRoleNewResponse, error)

post /projects/{project_id}/groups/{group_id}/roles

Assigns a project role to a group within a project.

Parameters

  • projectID string

  • groupID string

  • body AdminOrganizationProjectGroupRoleNewParams

    • RoleID param.Field[string]

      Identifier of the role to assign.

Returns

  • type AdminOrganizationProjectGroupRoleNewResponse struct{…}

    Role assignment linking a group to a role.

    • Group AdminOrganizationProjectGroupRoleNewResponseGroup

      Summary information about a group returned in role assignment responses.

      • ID string

        Identifier for the group.

      • CreatedAt int64

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

      • Name string

        Display name of the group.

      • Object Group

        Always group.

        • const GroupGroup Group = "group"
      • ScimManaged bool

        Whether the group is managed through SCIM.

    • Object GroupRole

      Always group.role.

      • const GroupRoleGroupRole GroupRole = "group.role"
    • Role Role

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

      • ID string

        Identifier for the role.

      • Description string

        Optional description of the role.

      • Name string

        Unique name for the role.

      • Object Role

        Always role.

        • const RoleRole Role = "role"
      • Permissions []string

        Permissions granted by the role.

      • PredefinedRole bool

        Whether the role is predefined and managed by OpenAI.

      • ResourceType string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Projects.Groups.Roles.New(
    context.TODO(),
    "project_id",
    "group_id",
    openai.AdminOrganizationProjectGroupRoleNewParams{
      RoleID: "role_id",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.Group)
}

Response

{
  "group": {
    "id": "id",
    "created_at": 0,
    "name": "name",
    "object": "group",
    "scim_managed": true
  },
  "object": "group.role",
  "role": {
    "id": "id",
    "description": "description",
    "name": "name",
    "object": "role",
    "permissions": [
      "string"
    ],
    "predefined_role": true,
    "resource_type": "resource_type"
  }
}

Unassign project role from group

client.Admin.Organization.Projects.Groups.Roles.Delete(ctx, projectID, groupID, roleID) (*AdminOrganizationProjectGroupRoleDeleteResponse, error)

delete /projects/{project_id}/groups/{group_id}/roles/{role_id}

Unassigns a project role from a group within a project.

Parameters

  • projectID string

  • groupID string

  • roleID string

Returns

  • type AdminOrganizationProjectGroupRoleDeleteResponse struct{…}

    Confirmation payload returned after unassigning a role.

    • Deleted bool

      Whether the assignment was removed.

    • Object string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Projects.Groups.Roles.Delete(
    context.TODO(),
    "project_id",
    "group_id",
    "role_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.Deleted)
}

Response

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

Roles

List project roles

client.Admin.Organization.Projects.Roles.List(ctx, projectID, query) (*NextCursorPage[Role], error)

get /projects/{project_id}/roles

Lists the roles configured for a project.

Parameters

  • projectID string

  • query AdminOrganizationProjectRoleListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

      A limit on the number of roles to return. Defaults to 1000.

    • Order param.Field[AdminOrganizationProjectRoleListParamsOrder]

      Sort order for the returned roles.

      • const AdminOrganizationProjectRoleListParamsOrderAsc AdminOrganizationProjectRoleListParamsOrder = "asc"

      • const AdminOrganizationProjectRoleListParamsOrderDesc AdminOrganizationProjectRoleListParamsOrder = "desc"

Returns

  • type Role struct{…}

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

    • ID string

      Identifier for the role.

    • Description string

      Optional description of the role.

    • Name string

      Unique name for the role.

    • Object Role

      Always role.

      • const RoleRole Role = "role"
    • Permissions []string

      Permissions granted by the role.

    • PredefinedRole bool

      Whether the role is predefined and managed by OpenAI.

    • ResourceType string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.Roles.List(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectRoleListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "description": "description",
      "name": "name",
      "object": "role",
      "permissions": [
        "string"
      ],
      "predefined_role": true,
      "resource_type": "resource_type"
    }
  ],
  "has_more": true,
  "next": "next",
  "object": "list"
}

Create project role

client.Admin.Organization.Projects.Roles.New(ctx, projectID, body) (*Role, error)

post /projects/{project_id}/roles

Creates a custom role for a project.

Parameters

  • projectID string

  • body AdminOrganizationProjectRoleNewParams

    • Permissions param.Field[[]string]

      Permissions to grant to the role.

    • RoleName param.Field[string]

      Unique name for the role.

    • Description param.Field[string]

      Optional description of the role.

Returns

  • type Role struct{…}

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

    • ID string

      Identifier for the role.

    • Description string

      Optional description of the role.

    • Name string

      Unique name for the role.

    • Object Role

      Always role.

      • const RoleRole Role = "role"
    • Permissions []string

      Permissions granted by the role.

    • PredefinedRole bool

      Whether the role is predefined and managed by OpenAI.

    • ResourceType string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Projects.Roles.New(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectRoleNewParams{
      Permissions: []string{"string"},
      RoleName: "role_name",
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.ID)
}

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Update project role

client.Admin.Organization.Projects.Roles.Update(ctx, projectID, roleID, body) (*Role, error)

post /projects/{project_id}/roles/{role_id}

Updates an existing project role.

Parameters

  • projectID string

  • roleID string

  • body AdminOrganizationProjectRoleUpdateParams

    • Description param.Field[string]

      New description for the role.

    • Permissions param.Field[[]string]

      Updated set of permissions for the role.

    • RoleName param.Field[string]

      New name for the role.

Returns

  • type Role struct{…}

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

    • ID string

      Identifier for the role.

    • Description string

      Optional description of the role.

    • Name string

      Unique name for the role.

    • Object Role

      Always role.

      • const RoleRole Role = "role"
    • Permissions []string

      Permissions granted by the role.

    • PredefinedRole bool

      Whether the role is predefined and managed by OpenAI.

    • ResourceType string

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

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Projects.Roles.Update(
    context.TODO(),
    "project_id",
    "role_id",
    openai.AdminOrganizationProjectRoleUpdateParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.ID)
}

Response

{
  "id": "id",
  "description": "description",
  "name": "name",
  "object": "role",
  "permissions": [
    "string"
  ],
  "predefined_role": true,
  "resource_type": "resource_type"
}

Delete project role

client.Admin.Organization.Projects.Roles.Delete(ctx, projectID, roleID) (*AdminOrganizationProjectRoleDeleteResponse, error)

delete /projects/{project_id}/roles/{role_id}

Deletes a custom role from a project.

Parameters

  • projectID string

  • roleID string

Returns

  • type AdminOrganizationProjectRoleDeleteResponse struct{…}

    Confirmation payload returned after deleting a role.

    • ID string

      Identifier of the deleted role.

    • Deleted bool

      Whether the role was deleted.

    • Object RoleDeleted

      Always role.deleted.

      • const RoleDeletedRoleDeleted RoleDeleted = "role.deleted"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  role, err := client.Admin.Organization.Projects.Roles.Delete(
    context.TODO(),
    "project_id",
    "role_id",
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", role.ID)
}

Response

{
  "id": "id",
  "deleted": true,
  "object": "role.deleted"
}

Certificates

List project certificates

client.Admin.Organization.Projects.Certificates.List(ctx, projectID, query) (*ConversationCursorPage[AdminOrganizationProjectCertificateListResponse], error)

get /organization/projects/{project_id}/certificates

List certificates for this project.

Parameters

  • projectID string

  • query AdminOrganizationProjectCertificateListParams

    • After param.Field[string]

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

    • Limit param.Field[int64]

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

    • Order param.Field[AdminOrganizationProjectCertificateListParamsOrder]

      Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order.

      • const AdminOrganizationProjectCertificateListParamsOrderAsc AdminOrganizationProjectCertificateListParamsOrder = "asc"

      • const AdminOrganizationProjectCertificateListParamsOrderDesc AdminOrganizationProjectCertificateListParamsOrder = "desc"

Returns

  • type AdminOrganizationProjectCertificateListResponse struct{…}

    Represents an individual certificate configured at the project level.

    • ID string

      The identifier, which can be referenced in API endpoints

    • Active bool

      Whether the certificate is currently active at the project level.

    • CertificateDetails AdminOrganizationProjectCertificateListResponseCertificateDetails

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object OrganizationProjectCertificate

      The object type, which is always organization.project.certificate.

      • const OrganizationProjectCertificateOrganizationProjectCertificate OrganizationProjectCertificate = "organization.project.certificate"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.Certificates.List(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectCertificateListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.project.certificate"
    }
  ],
  "first_id": "cert_abc",
  "has_more": true,
  "last_id": "cert_abc",
  "object": "list"
}

Activate certificates for project

client.Admin.Organization.Projects.Certificates.Activate(ctx, projectID, body) (*Page[AdminOrganizationProjectCertificateActivateResponse], error)

post /organization/projects/{project_id}/certificates/activate

Activate certificates at the project level.

You can atomically and idempotently activate up to 10 certificates at a time.

Parameters

  • projectID string

  • body AdminOrganizationProjectCertificateActivateParams

    • CertificateIDs param.Field[[]string]

Returns

  • type AdminOrganizationProjectCertificateActivateResponse struct{…}

    Represents an individual certificate configured at the project level.

    • ID string

      The identifier, which can be referenced in API endpoints

    • Active bool

      Whether the certificate is currently active at the project level.

    • CertificateDetails AdminOrganizationProjectCertificateActivateResponseCertificateDetails

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object OrganizationProjectCertificate

      The object type, which is always organization.project.certificate.

      • const OrganizationProjectCertificateOrganizationProjectCertificate OrganizationProjectCertificate = "organization.project.certificate"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.Certificates.Activate(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectCertificateActivateParams{
      CertificateIDs: []string{"cert_abc"},
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.project.certificate"
    }
  ],
  "object": "organization.project.certificate.activation"
}

Deactivate certificates for project

client.Admin.Organization.Projects.Certificates.Deactivate(ctx, projectID, body) (*Page[AdminOrganizationProjectCertificateDeactivateResponse], error)

post /organization/projects/{project_id}/certificates/deactivate

Deactivate certificates at the project level. You can atomically and idempotently deactivate up to 10 certificates at a time.

Parameters

  • projectID string

  • body AdminOrganizationProjectCertificateDeactivateParams

    • CertificateIDs param.Field[[]string]

Returns

  • type AdminOrganizationProjectCertificateDeactivateResponse struct{…}

    Represents an individual certificate configured at the project level.

    • ID string

      The identifier, which can be referenced in API endpoints

    • Active bool

      Whether the certificate is currently active at the project level.

    • CertificateDetails AdminOrganizationProjectCertificateDeactivateResponseCertificateDetails

      • ExpiresAt int64

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

      • ValidAt int64

        The Unix timestamp (in seconds) of when the certificate becomes valid.

    • CreatedAt int64

      The Unix timestamp (in seconds) of when the certificate was uploaded.

    • Name string

      The name of the certificate.

    • Object OrganizationProjectCertificate

      The object type, which is always organization.project.certificate.

      • const OrganizationProjectCertificateOrganizationProjectCertificate OrganizationProjectCertificate = "organization.project.certificate"

Example

package main

import (
  "context"
  "fmt"

  "github.com/openai/openai-go"
  "github.com/openai/openai-go/option"
)

func main() {
  client := openai.NewClient(
    option.WithAdminAPIKey("My Admin API Key"),
  )
  page, err := client.Admin.Organization.Projects.Certificates.Deactivate(
    context.TODO(),
    "project_id",
    openai.AdminOrganizationProjectCertificateDeactivateParams{
      CertificateIDs: []string{"cert_abc"},
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}

Response

{
  "data": [
    {
      "id": "id",
      "active": true,
      "certificate_details": {
        "expires_at": 0,
        "valid_at": 0
      },
      "created_at": 0,
      "name": "name",
      "object": "organization.project.certificate"
    }
  ],
  "object": "organization.project.certificate.deactivation"
}