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
}
]
}| Field | Type | Required | Description |
|---|---|---|---|
id | string | Always | Key identifier |
name | string | Always | Display name |
suffix | string | Always | Last characters of the key |
permissions | object | Always | Model and endpoint access rules |
expires_at | string | Always | ISO 8601 expiration timestamp |
rate_limit_rpm | number? | Always | Max requests per minute, or null |
rate_limit_tpm | number? | Always | Max tokens per minute, or null |
monthly_budget_usd | string? | Always | Monthly spending cap, or null |
Create a Temporary Key
POST /v1/platform/temp-keys
Create a new temporary key with configurable constraints.
Body Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name |
ttl | number | No | Lifetime in seconds. Default: 86400 (24h) |
expires_at | string | No | ISO 8601 expiration. Use ttl OR expires_at, not both |
permissions | object | No | { models?: string[] | "*", endpoints?: string[] | "*" } |
rate_limit_rpm | number | No | Max requests per minute |
rate_limit_tpm | number | No | Max tokens per minute |
monthly_budget_usd | number | No | Max 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 againResponse
{
"id": "ak_0t1e2m3p4q5r6s7u8v9w0x1",
"key": "temp_ab_proj01_0a1b2c3d...",
"expires_at": "2025-01-15T13:00:00.000Z"
}Store the
keyvalue 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
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The key ID to revoke |
await billing.tempKeys.revoke('ak_0t1e2m3p4q5r6s7u8v9w0x1')Response
{ "success": true }| Status | Cause |
|---|---|
| 400 | Both expires_at and ttl provided |
| 404 | Key not found or doesn't belong to this workspace |