TypeScript SDK

Tenant

Read and change your tenant's name, monthly quota, and billing switch with the TypeScript SDK.

client.tenant reads and changes settings for the tenant your API key belongs to: its name, an optional monthly quota that stops new turns past a ceiling, and whether usage is billed to your end users. It takes no tenant ID, because a key belongs to exactly one tenant.

const settings = await client.tenant.patch({
  quota: { monthlyTokenLimit: 1_000_000, monthlyRequestLimit: null, resetDay: 1 },
});
console.log(settings.quota);

Every method takes one input object and accepts an optional abortSignal.

Available operations

MethodDescriptionReturns
get()Read your tenant's settingsTenantSettingsResponse
patch()Change the name, quota, or billing switchTenantSettingsResponse

Methods

get()

Reads your tenant's settings.

Signature: get(input?: ResourceRequestOptions): Promise<TenantSettingsResponse>

const settings = await client.tenant.get();
console.log(settings.name, settings.quota?.monthlyTokenLimit);

Returns TenantSettingsResponse.

patch()

Changes one or more settings.

Signature: patch(input: UpdateTenantSettingsBody & ResourceRequestOptions): Promise<TenantSettingsResponse>

await client.tenant.patch({ quota: null });
FieldTypeRequiredDescription
namestringno1 to 80 characters
quotaQuota | nullnoThe whole monthly quota; null removes it
monetizationEnabledbooleannoBill usage to your end users through your merchant account

Pass at least one field; the ones you leave out stay as they are. A quota replaces the whole quota, so send all three of its fields:

Quota fieldTypeDescription
monthlyTokenLimitnumber | nullTokens per month; null for no token limit
monthlyRequestLimitnumber | nullTurns per month; null for no turn limit
resetDaynumberDay of the month, 1 to 28, when the count starts over

At least one limit must be a positive number. Once usage passes a limit, new turns fail with quota_exceeded and task runs end as blocked; turns already running finish. See Usage and quotas.

Turning monetizationEnabled off drops usage events your merchant has not yet accepted. See Monetization before you change it.

Returns TenantSettingsResponse. Errors: validation_failed.

Response types

TenantSettingsResponse

interface TenantSettingsResponse {
  name: string;
  quota: Quota | null;
  monetizationEnabled: boolean;
  deletion: { requestedAt: string; deletesAt: string } | null;
}

interface Quota {
  monthlyTokenLimit: number | null;
  monthlyRequestLimit: number | null;
  resetDay: number;
}

quota is null when you have not set one, so usage is unlimited. deletion is set when someone has asked to delete the tenant from the dashboard; deletesAt is when that happens, and it can be cancelled until then.

Next

On this page