Skip to content

Create an API Key

POST/v1/keys

Authorization

Authorizationstring · headerRequired

Workspace session token sent as Bearer <token>. Authentication guide

Request Body

application/json
workspace_idstringRequired
namestringRequired
kindstring

Values: "api"

scopesstring[]

Default: ["audio.write","models.read"]

Show nested fields

string

spend_limitnumber | null

Minimum 0

rate_limitinteger | null

Requests per minute.

Minimum 1

expires_atstring | null
budgetsobject

A number sets that period's limit in USD, null removes it, and periods left out stay as they are.

Show nested fields
dailynumber | null

Minimum 0 · Maximum 1000000

weeklynumber | null

Minimum 0 · Maximum 1000000

monthlynumber | null

Minimum 0 · Maximum 1000000

access_policyobject | null

The key's own policy. It applies on top of the workspace's, so it can only narrow what the key may use.

Show nested fields
Option 1: object
allowed_modelsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_modelsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

allowed_providersstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_providersstring[]
Show nested fields

See the OpenAPI schema for this nested object.

allowed_productsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_productsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

Option 2: null

null

Responses

201API key created. The raw key is returned once.
application/json
keyobjectRequired
Show nested fields
idstringRequired
workspace_idstringRequired
namestringRequired
prefixstringRequired

Non-secret key prefix for display and lookup.

kindstringRequired

Values: "api"

statestringRequired

Values: "active""disabled""revoked"

scopesstring[]Required
Show nested fields

string

spend_limitnumber | null
rate_limitinteger | null
expires_atstring | null
last_used_atstring | null
created_atstringRequired
revoked_atstring | null
budgetsobject

Spend limits in USD per UTC calendar period. null means no limit.

Show nested fields
dailynumber | nullRequired

Minimum 0

weeklynumber | nullRequired

Weeks start on Monday.

Minimum 0

monthlynumber | nullRequired

Minimum 0

access_policyobject | null
Show nested fields
Option 1: object
allowed_modelsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_modelsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

allowed_providersstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_providersstring[]
Show nested fields

See the OpenAPI schema for this nested object.

allowed_productsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

blocked_productsstring[]
Show nested fields

See the OpenAPI schema for this nested object.

Option 2: null

null

usageobject

USD spent in the current UTC day, week and month, and in total, including holds for requests in progress. Spend counts in the period its request started.

Show nested fields
dailynumberRequired
weeklynumberRequired
monthlynumberRequired
totalnumberRequired
valuestringRequired

Raw API key. Manual keys are returned once; pending default keys remain claimable until acknowledged.

400Request validation failed.
application/json
errorobjectRequired
Show nested fields
codestringRequired
messagestringRequired
paramstring | null
request_idstring | null
metadataobject

Typed detail for some refusals. budget_exceeded (402): limit (key_budget or workspace_budget) and budget with scope, period, limit, usage and resets_at. key_limit_exceeded (402): limit key_spend_limit. access_denied (403): policy (workspace or key), rule (models, providers or products), product, provider and model.

401Authentication is missing or invalid.
application/json
errorobjectRequired
Show nested fields
codestringRequired
messagestringRequired
paramstring | null
request_idstring | null
metadataobject

Typed detail for some refusals. budget_exceeded (402): limit (key_budget or workspace_budget) and budget with scope, period, limit, usage and resets_at. key_limit_exceeded (402): limit key_spend_limit. access_denied (403): policy (workspace or key), rule (models, providers or products), product, provider and model.

403Authenticated principal lacks permission.
application/json
errorobjectRequired
Show nested fields
codestringRequired
messagestringRequired
paramstring | null
request_idstring | null
metadataobject

Typed detail for some refusals. budget_exceeded (402): limit (key_budget or workspace_budget) and budget with scope, period, limit, usage and resets_at. key_limit_exceeded (402): limit key_spend_limit. access_denied (403): policy (workspace or key), rule (models, providers or products), product, provider and model.

500Internal server error.
application/json
errorobjectRequired
Show nested fields
codestringRequired
messagestringRequired
paramstring | null
request_idstring | null
metadataobject

Typed detail for some refusals. budget_exceeded (402): limit (key_budget or workspace_budget) and budget with scope, period, limit, usage and resets_at. key_limit_exceeded (402): limit key_spend_limit. access_denied (403): policy (workspace or key), rule (models, providers or products), product, provider and model.