Skip to content
Primary navigation

Create admin API key

AdminApiKeyCreateResponse admin().organization().adminApiKeys().create(AdminApiKeyCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
POST/organization/admin_api_keys

Create an organization admin API key

ParametersExpand Collapse
AdminApiKeyCreateParams params
String name
ReturnsExpand Collapse
class AdminApiKeyCreateResponse:

Represents an individual Admin API key in an org.

String value

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

Create admin API key

package com.openai.example;

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

public final class Main {
    private Main() {}

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

        AdminApiKeyCreateParams params = AdminApiKeyCreateParams.builder()
            .name("New Admin Key")
            .build();
        AdminApiKeyCreateResponse adminApiKey = client.admin().organization().adminApiKeys().create(params);
    }
}
{
  "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"
}