Skip to content
For the complete documentation index, see llms.txt. Markdown versions of documentation pages are available by appending .md to the page URL.
Primary navigation

List all organization and project API keys.

admin.organization.admin_api_keys.list(AdminAPIKeyListParams**kwargs) -> SyncCursorPage[AdminAPIKey]
GET/organization/admin_api_keys

List organization API keys

ParametersExpand Collapse
after: Optional[str]

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

limit: Optional[int]

Maximum number of keys to return.

order: Optional[Literal["asc", "desc"]]

Order results by creation time, ascending or descending.

ReturnsExpand Collapse
class AdminAPIKey: …

Represents an individual Admin API key in an org.

id: str

The identifier, which can be referenced in API endpoints

created_at: int

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

formatunixtime
expires_at: Optional[int]

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

formatunixtime
object: Literal["organization.admin_api_key"]

The object type, which is always organization.admin_api_key

redacted_value: str

The redacted value of the API key

last_used_at: Optional[int]

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

formatunixtime
name: Optional[str]

The name of the API key

List all organization and project API keys.

import os
from openai import OpenAI

client = OpenAI(
    admin_api_key=os.environ.get("OPENAI_ADMIN_KEY"),  # This is the default and can be omitted
)
page = client.admin.organization.admin_api_keys.list()
page = page.data[0]
print(page.id)
{
  "object": "list",
  "data": [
    {
      "object": "organization.admin_api_key",
      "id": "key_abc",
      "name": "Main Admin Key",
      "redacted_value": "sk-admin...def",
      "created_at": 1711471533,
      "expires_at": 1714063533,
      "last_used_at": 1711471534,
      "owner": {
        "type": "service_account",
        "object": "organization.service_account",
        "id": "sa_456",
        "name": "My Service Account",
        "created_at": 1711471533,
        "role": "member"
      }
    }
  ],
  "first_id": "key_abc",
  "last_id": "key_abc",
  "has_more": false
}
Returns Examples
{
  "object": "list",
  "data": [
    {
      "object": "organization.admin_api_key",
      "id": "key_abc",
      "name": "Main Admin Key",
      "redacted_value": "sk-admin...def",
      "created_at": 1711471533,
      "expires_at": 1714063533,
      "last_used_at": 1711471534,
      "owner": {
        "type": "service_account",
        "object": "organization.service_account",
        "id": "sa_456",
        "name": "My Service Account",
        "created_at": 1711471533,
        "role": "member"
      }
    }
  ],
  "first_id": "key_abc",
  "last_id": "key_abc",
  "has_more": false
}