Skip to content
Primary navigation

Create admin API key

client.admin.organization.adminAPIKeys.create(AdminAPIKeyCreateParams { name } body, RequestOptionsoptions?): AdminAPIKeyCreateResponse { value }
POST/organization/admin_api_keys

Create an organization admin API key

ParametersExpand Collapse
body: AdminAPIKeyCreateParams { name }
name: string
ReturnsExpand Collapse
AdminAPIKeyCreateResponse extends AdminAPIKey { id, created_at, object, 4 more } { value }

Represents an individual Admin API key in an org.

value: string

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

Create admin API key

import OpenAI from 'openai';

const client = new OpenAI({
  adminAPIKey: process.env['OPENAI_ADMIN_KEY'], // This is the default and can be omitted
});

const adminAPIKey = await client.admin.organization.adminAPIKeys.create({ name: 'New Admin Key' });

console.log(adminAPIKey);
{
  "object": "organization.admin_api_key",
  "id": "key_xyz",
  "name": "New Admin Key",
  "redacted_value": "sk-admin...xyz",
  "created_at": 1711471533,
  "last_used_at": 1711471534,
  "owner": {
    "type": "user",
    "object": "organization.user",
    "id": "user_123",
    "name": "John Doe",
    "created_at": 1711471533,
    "role": "owner"
  },
  "value": "sk-admin-1234abcd"
}
Returns Examples
{
  "object": "organization.admin_api_key",
  "id": "key_xyz",
  "name": "New Admin Key",
  "redacted_value": "sk-admin...xyz",
  "created_at": 1711471533,
  "last_used_at": 1711471534,
  "owner": {
    "type": "user",
    "object": "organization.user",
    "id": "user_123",
    "name": "John Doe",
    "created_at": 1711471533,
    "role": "owner"
  },
  "value": "sk-admin-1234abcd"
}