Assistant Billing

Temporary Keys

Short-lived API keys with automatic expiration, budgets, and fine-grained permissions. Use for CI/CD pipelines, trials, or guest access.

Temporary keys work exactly like regular API keys -- the proxy accepts both sk_ab_* and temp_ab_* formats. The difference is that temporary keys always expire (default: 24 hours).

Auth: Session token or platform key with X-Workspace-Id header.

List Temporary Keys

GET /v1/platform/temp-keys

Returns all active temporary keys for the workspace.

No parameters.

const keys = await billing.tempKeys.list()

Response

{
  "data": [
    {
      "id": "ak_0t1e2m3p4q5r6s7u8v9w0x1",
      "name": "CI Pipeline",
      "suffix": "c123",
      "permissions": { "models": ["gpt-4o-mini"], "endpoints": ["*"] },
      "expires_at": "2025-01-15T13:00:00.000Z",
      "rate_limit_rpm": 60,
      "rate_limit_tpm": null,
      "monthly_budget_usd": "5.000000",
      "created_at": "2025-01-15T12:00:00.000Z",
      "last_used_at": null
    }
  ]
}
FieldTypeRequiredDescription
idstringAlwaysKey identifier
namestringAlwaysDisplay name
suffixstringAlwaysLast characters of the key
permissionsobjectAlwaysModel and endpoint access rules
expires_atstringAlwaysISO 8601 expiration timestamp
rate_limit_rpmnumber?AlwaysMax requests per minute, or null
rate_limit_tpmnumber?AlwaysMax tokens per minute, or null
monthly_budget_usdstring?AlwaysMonthly spending cap, or null

Create a Temporary Key

POST /v1/platform/temp-keys

Create a new temporary key with configurable constraints.

Body Parameters

NameTypeRequiredDescription
namestringYesDisplay name
ttlnumberNoLifetime in seconds. Default: 86400 (24h)
expires_atstringNoISO 8601 expiration. Use ttl OR expires_at, not both
permissionsobjectNo{ models?: string[] | "*", endpoints?: string[] | "*" }
rate_limit_rpmnumberNoMax requests per minute
rate_limit_tpmnumberNoMax tokens per minute
monthly_budget_usdnumberNoMax monthly spend in USD
const { key, id, expires_at } = await billing.tempKeys.create({
  name: 'CI Pipeline',
  ttl: 3600,
  permissions: { models: ['gpt-4o-mini'], endpoints: ['*'] },
  rate_limit_rpm: 60,
  monthly_budget_usd: 5,
})
// Store key securely — it cannot be retrieved again

Response

{
  "id": "ak_0t1e2m3p4q5r6s7u8v9w0x1",
  "key": "temp_ab_proj01_0a1b2c3d...",
  "expires_at": "2025-01-15T13:00:00.000Z"
}

Store the key value securely -- it cannot be retrieved again.


Revoke a Temporary Key

DELETE /v1/platform/temp-keys/:id

Permanently revoke a temporary key. Requests using this key will immediately return 401.

Path Parameters

NameTypeRequiredDescription
idstringYesThe key ID to revoke
await billing.tempKeys.revoke('ak_0t1e2m3p4q5r6s7u8v9w0x1')

Response

{ "success": true }
StatusCause
400Both expires_at and ttl provided
404Key not found or doesn't belong to this workspace