Skip to main content

Class: AIGatewayApiKeysClient

Defined in: src/ai-gateway/api-keys-client.ts:34

Client for AI Gateway API-key operations (data plane).

Service and user keys are separate sub-collections; there is no combined api-keys endpoint (it is OPA-denied).

Constructors​

Constructor​

new AIGatewayApiKeysClient(opts): AIGatewayApiKeysClient;

Defined in: src/ai-gateway/api-keys-client.ts:39

Parameters​

ParameterType
optsAIGatewaySubClientOptions

Returns​

AIGatewayApiKeysClient

Methods​

listService()​

listService(opts): Promise<objectOutputType<{
object: ZodString;
total: ZodNumber;
success: ZodOptional<ZodBoolean>;
has_more: ZodOptional<ZodBoolean>;
data: ZodArray<ZodObject<{
id: ZodString;
name: ZodOptional<ZodString>;
object: ZodOptional<ZodString>;
}, "passthrough", ZodTypeAny, objectOutputType<{
id: ZodString;
name: ZodOptional<ZodString>;
object: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">, objectInputType<{
id: ZodString;
name: ZodOptional<ZodString>;
object: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>, "many">;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:99

List service API keys in a workspace.

Parameters​

ParameterTypeDescription
optsAIGatewayWorkspaceScopedListOptionsMust include the workspace UUID.

Returns​

Promise<objectOutputType<{ object: ZodString; total: ZodNumber; success: ZodOptional<ZodBoolean>; has_more: ZodOptional<ZodBoolean>; data: ZodArray<ZodObject<{ id: ZodString; name: ZodOptional<ZodString>; object: ZodOptional<ZodString>; }, "passthrough", ZodTypeAny, objectOutputType<{ id: ZodString; name: ZodOptional<ZodString>; object: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">, objectInputType<{ id: ZodString; name: ZodOptional<ZodString>; object: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>, "many">; }, ZodTypeAny, "passthrough">>

Service keys; the secret itself is only ever returned at creation.

Example​

import { AIGatewayClient } from '@cdot65/prisma-airs-sdk';
const gw = new AIGatewayClient();

const keys = await gw.apiKeys.listService({ workspaceId: '16f7e90d-382a-4e78-b577-1b01eb5f8297' });
// keys.total => 1

listUser()​

listUser(opts): Promise<objectOutputType<{
object: ZodString;
total: ZodNumber;
success: ZodOptional<ZodBoolean>;
has_more: ZodOptional<ZodBoolean>;
data: ZodArray<ZodObject<{
id: ZodString;
name: ZodOptional<ZodString>;
object: ZodOptional<ZodString>;
}, "passthrough", ZodTypeAny, objectOutputType<{
id: ZodString;
name: ZodOptional<ZodString>;
object: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">, objectInputType<{
id: ZodString;
name: ZodOptional<ZodString>;
object: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>, "many">;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:116

List user API keys in a workspace.

Parameters​

ParameterTypeDescription
optsAIGatewayWorkspaceScopedListOptionsMust include the workspace UUID.

Returns​

Promise<objectOutputType<{ object: ZodString; total: ZodNumber; success: ZodOptional<ZodBoolean>; has_more: ZodOptional<ZodBoolean>; data: ZodArray<ZodObject<{ id: ZodString; name: ZodOptional<ZodString>; object: ZodOptional<ZodString>; }, "passthrough", ZodTypeAny, objectOutputType<{ id: ZodString; name: ZodOptional<ZodString>; object: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">, objectInputType<{ id: ZodString; name: ZodOptional<ZodString>; object: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>, "many">; }, ZodTypeAny, "passthrough">>

User-scoped keys.

Example​

import { AIGatewayClient } from '@cdot65/prisma-airs-sdk';
const gw = new AIGatewayClient();

const keys = await gw.apiKeys.listUser({ workspaceId: '16f7e90d-382a-4e78-b577-1b01eb5f8297' });
// keys.total => 0

getService()​

getService(keyId): Promise<objectOutputType<{
id: ZodString;
name: ZodOptional<ZodString>;
object: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:164

Get a service key.

Parameters​

ParameterType
keyIdstring

Returns​

Promise<objectOutputType<{ id: ZodString; name: ZodOptional<ZodString>; object: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>

Example​

`await gw.apiKeys.getService(keyId);`

getUser()​

getUser(keyId): Promise<objectOutputType<{
id: ZodString;
name: ZodOptional<ZodString>;
object: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:168

Get a user key.

Parameters​

ParameterType
keyIdstring

Returns​

Promise<objectOutputType<{ id: ZodString; name: ZodOptional<ZodString>; object: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>

Example​

`await gw.apiKeys.getUser(keyId);`

deleteService()​

deleteService(keyId): Promise<void>;

Defined in: src/ai-gateway/api-keys-client.ts:172

Permanently delete a service key.

Parameters​

ParameterType
keyIdstring

Returns​

Promise<void>

Example​

`await gw.apiKeys.deleteService(keyId);`

deleteUser()​

deleteUser(keyId): Promise<void>;

Defined in: src/ai-gateway/api-keys-client.ts:176

Permanently delete a user key.

Parameters​

ParameterType
keyIdstring

Returns​

Promise<void>

Example​

`await gw.apiKeys.deleteUser(keyId);`

rotateService()​

rotateService(keyId, body?): Promise<objectOutputType<{
id: ZodString;
key: ZodString;
key_transition_expires_at: ZodString;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:180

Rotate a service key; capture the returned secret.

Parameters​

ParameterType
keyIdstring
body{ key_transition_period_ms?: number; }
body.key_transition_period_ms?number

Returns​

Promise<objectOutputType<{ id: ZodString; key: ZodString; key_transition_expires_at: ZodString; }, ZodTypeAny, "passthrough">>

Example​

`const rotated = await gw.apiKeys.rotateService(keyId);`

rotateUser()​

rotateUser(keyId, body?): Promise<objectOutputType<{
id: ZodString;
key: ZodString;
key_transition_expires_at: ZodString;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:187

Rotate a user key; capture the returned secret.

Parameters​

ParameterType
keyIdstring
body{ key_transition_period_ms?: number; }
body.key_transition_period_ms?number

Returns​

Promise<objectOutputType<{ id: ZodString; key: ZodString; key_transition_expires_at: ZodString; }, ZodTypeAny, "passthrough">>

Example​

`const rotated = await gw.apiKeys.rotateUser(keyId);`

createService()​

createService(body): Promise<objectOutputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
success: ZodOptional<ZodBoolean>;
data: ZodOptional<ZodUnion<[ZodObject<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, "passthrough", ZodTypeAny, objectOutputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">, objectInputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>, ZodString, ZodNumber]>>;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:212

Create a service API key.

Parameters​

ParameterTypeDescription
body{ name: string; description?: string; scopes: GatewayOpenValue< | "agents.invoke" | "completions.write" | "logs.write" | "mcp.invoke" | "prompts.render">[]; rate_limits?: | { type: GatewayOpenValue<"requests" | "tokens">; unit: GatewayOpenValue<"rpd" | "rph" | "rpm" | "rps" | "rpw">; value: number; }[] | null; usage_limits?: | { [key: string]: any; } | null; defaults?: | { metadata?: Record<string, GatewayJsonValue>; config_id?: string; allow_config_override?: boolean; } | null; alert_emails?: string[]; expires_at?: string | null; rotation_policy?: | { [key: string]: any; } | null; organisation_id: string; workspace_id: string; type: string; }Name, scopes, TSG, workspace UUID, and type.
body.namestring-
body.description?string-
body.scopesGatewayOpenValue< | "agents.invoke" | "completions.write" | "logs.write" | "mcp.invoke" | "prompts.render">[]-
body.rate_limits?| { type: GatewayOpenValue<"requests" | "tokens">; unit: GatewayOpenValue<"rpd" | "rph" | "rpm" | "rps" | "rpw">; value: number; }[] | null-
body.usage_limits?| { [key: string]: any; } | null-
body.defaults?| { metadata?: Record<string, GatewayJsonValue>; config_id?: string; allow_config_override?: boolean; } | null-
body.alert_emails?string[]-
body.expires_at?string | null-
body.rotation_policy?| { [key: string]: any; } | null-
body.organisation_idstring-
body.workspace_idstring-
body.typestring-

Returns​

Promise<objectOutputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; success: ZodOptional<ZodBoolean>; data: ZodOptional<ZodUnion<[ZodObject<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, "passthrough", ZodTypeAny, objectOutputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">, objectInputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>, ZodString, ZodNumber]>>; }, ZodTypeAny, "passthrough">>

The raw create response — the only place the key secret appears. Capture it.

Example​

import { AIGatewayClient } from '@cdot65/prisma-airs-sdk';
const gw = new AIGatewayClient();

await gw.apiKeys.createService({
name: 'ci-runner',
scopes: ['completions.write', 'logs.write'],
organisation_id: '1852583913',
workspace_id: '16f7e90d-382a-4e78-b577-1b01eb5f8297',
type: 'workspace',
});

createUser()​

createUser(body): Promise<objectOutputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
success: ZodOptional<ZodBoolean>;
data: ZodOptional<ZodUnion<[ZodObject<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, "passthrough", ZodTypeAny, objectOutputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">, objectInputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>, ZodString, ZodNumber]>>;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:241

Create a user API key.

Parameters​

ParameterTypeDescription
body{ name: string; description?: string; scopes: GatewayOpenValue< | "agents.invoke" | "completions.write" | "logs.write" | "mcp.invoke" | "prompts.render">[]; rate_limits?: | { type: GatewayOpenValue<"requests" | "tokens">; unit: GatewayOpenValue<"rpd" | "rph" | "rpm" | "rps" | "rpw">; value: number; }[] | null; usage_limits?: | { [key: string]: any; } | null; defaults?: | { metadata?: Record<string, GatewayJsonValue>; config_id?: string; allow_config_override?: boolean; } | null; alert_emails?: string[]; expires_at?: string | null; rotation_policy?: | { [key: string]: any; } | null; organisation_id: string; workspace_id: string; type: string; user_id: string; }As createService, plus user_id.
body.namestring-
body.description?string-
body.scopesGatewayOpenValue< | "agents.invoke" | "completions.write" | "logs.write" | "mcp.invoke" | "prompts.render">[]-
body.rate_limits?| { type: GatewayOpenValue<"requests" | "tokens">; unit: GatewayOpenValue<"rpd" | "rph" | "rpm" | "rps" | "rpw">; value: number; }[] | null-
body.usage_limits?| { [key: string]: any; } | null-
body.defaults?| { metadata?: Record<string, GatewayJsonValue>; config_id?: string; allow_config_override?: boolean; } | null-
body.alert_emails?string[]-
body.expires_at?string | null-
body.rotation_policy?| { [key: string]: any; } | null-
body.organisation_idstring-
body.workspace_idstring-
body.typestring-
body.user_idstring-

Returns​

Promise<objectOutputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; success: ZodOptional<ZodBoolean>; data: ZodOptional<ZodUnion<[ZodObject<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, "passthrough", ZodTypeAny, objectOutputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">, objectInputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>, ZodString, ZodNumber]>>; }, ZodTypeAny, "passthrough">>

The raw create response — the only place the key secret appears. Capture it.

Example​

import { AIGatewayClient } from '@cdot65/prisma-airs-sdk';
const gw = new AIGatewayClient();

await gw.apiKeys.createUser({
name: 'calvin-laptop',
scopes: ['completions.write'],
organisation_id: '1852583913',
workspace_id: '16f7e90d-382a-4e78-b577-1b01eb5f8297',
type: 'workspace',
user_id: 'fad91538-65a9-41f7-8b9c-6e4c0e8b9c5f',
});

updateService()​

updateService(keyId, body): Promise<objectOutputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
success: ZodOptional<ZodBoolean>;
data: ZodOptional<ZodUnion<[ZodObject<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, "passthrough", ZodTypeAny, objectOutputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">, objectInputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>, ZodString, ZodNumber]>>;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:270

Update a service API key.

Parameters​

ParameterTypeDescription
keyIdstringKey UUID.
body{ [key: string]: any; }One or more fields to update.

Returns​

Promise<objectOutputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; success: ZodOptional<ZodBoolean>; data: ZodOptional<ZodUnion<[ZodObject<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, "passthrough", ZodTypeAny, objectOutputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">, objectInputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>, ZodString, ZodNumber]>>; }, ZodTypeAny, "passthrough">>

The raw update response. Shape unverified against a live tenant — see the PRD.

Example​

import { AIGatewayClient } from '@cdot65/prisma-airs-sdk';
const gw = new AIGatewayClient();

await gw.apiKeys.updateService('11111111-1111-4111-8111-111111111111', {
name: 'ci-runner',
scopes: ['completions.write'],
organisation_id: '1852583913',
workspace_id: '16f7e90d-382a-4e78-b577-1b01eb5f8297',
type: 'workspace',
});

updateUser()​

updateUser(keyId, body): Promise<objectOutputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
success: ZodOptional<ZodBoolean>;
data: ZodOptional<ZodUnion<[ZodObject<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, "passthrough", ZodTypeAny, objectOutputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">, objectInputType<{
id: ZodOptional<ZodString>;
slug: ZodOptional<ZodString>;
version_id: ZodOptional<ZodString>;
}, ZodTypeAny, "passthrough">>, ZodString, ZodNumber]>>;
}, ZodTypeAny, "passthrough">>;

Defined in: src/ai-gateway/api-keys-client.ts:303

Update a user API key.

Parameters​

ParameterTypeDescription
keyIdstringKey UUID.
body{ [key: string]: any; }One or more fields to update.

Returns​

Promise<objectOutputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; success: ZodOptional<ZodBoolean>; data: ZodOptional<ZodUnion<[ZodObject<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, "passthrough", ZodTypeAny, objectOutputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">, objectInputType<{ id: ZodOptional<ZodString>; slug: ZodOptional<ZodString>; version_id: ZodOptional<ZodString>; }, ZodTypeAny, "passthrough">>, ZodString, ZodNumber]>>; }, ZodTypeAny, "passthrough">>

The raw update response. Shape unverified against a live tenant — see the PRD.

Example​

import { AIGatewayClient } from '@cdot65/prisma-airs-sdk';
const gw = new AIGatewayClient();

await gw.apiKeys.updateUser('11111111-1111-4111-8111-111111111111', {
name: 'calvin-laptop',
scopes: ['completions.write'],
organisation_id: '1852583913',
workspace_id: '16f7e90d-382a-4e78-b577-1b01eb5f8297',
type: 'workspace',
user_id: 'fad91538-65a9-41f7-8b9c-6e4c0e8b9c5f',
});