Skip to main content
The api_keys functions are currently in ALPHA. The API may change without notice. A one-time warning is emitted on first use.

List API Keys

import { listApiKeys } from "@arizeai/ax-client";

const apiKeys = await listApiKeys({
  keyType: "user",
  limit: 10,
});

Create an API Key

import { createApiKey } from "@arizeai/ax-client";

const apiKey = await createApiKey({
  name: "CI pipeline key",
  description: "Key for CI/CD pipeline",
  keyType: "user",
});
// Store apiKey.key securely — it is only returned once

Create a Service Key

Service keys require a spaceId and optionally accept roles.
import { createApiKey } from "@arizeai/ax-client";

const serviceKey = await createApiKey({
  name: "service-key",
  keyType: "service",
  spaceId: "your_space_id",
  expiresAt: "2025-12-31T00:00:00Z",
});

Delete an API Key

import { deleteApiKey } from "@arizeai/ax-client";

await deleteApiKey({ apiKeyId: "your_api_key_id" });

Refresh an API Key

Atomically revokes the existing key and issues a replacement with the same metadata (name, description, and key type). There is no window where neither key is valid.
import { refreshApiKey } from "@arizeai/ax-client";

const refreshed = await refreshApiKey({ apiKeyId: "your_api_key_id" });
// Store refreshed.key securely — it is only returned once

With a New Expiration Date

import { refreshApiKey } from "@arizeai/ax-client";

const refreshed = await refreshApiKey({
  apiKeyId: "your_api_key_id",
  expiresAt: "2026-12-31T00:00:00Z",
});