Create a new API key
Changed onCreate a new API key for the authenticated user. The plaintext key is returned only in this response. Treat it as a write-only, sensitive value; it cannot be retrieved later. Authenticate with a management key. The optional external object associates the key with a partner-defined user and lookup key.
Request
- Base URLhttps://openrouter.ai/api/v1
- AuthHTTP bearer
Request body
Optional user ID of the key creator. Only meaningful for organization-owned keys where a specific member is creating the key. A workspace-scoped management key may only name a member of its own workspace.
Optional ISO 8601 UTC expiration timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected.
Optional partner-defined identity associated with the created API key.
Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against limit.
Optional spending limit for the API key in USD
Type of limit reset for the API key (daily, weekly, monthly, or null for no reset). Resets happen automatically at midnight UTC, and weeks are Monday through Sunday.
Name for the new API key
The workspace to create the API key in. Defaults to the default workspace for an organization-scoped management key, or to the management key's own workspace for a workspace-scoped one, which cannot create keys elsewhere.
Example request
{
"expires_at": "2027-12-31T23:59:59Z",
"include_byok_in_limit": true,
"limit": 50,
"limit_reset": "monthly",
"name": "My New API Key"
}Response
API key created successfully
The created API key information
The actual API key string (only shown once)
Example response
{
"data": {
"byok_usage": 0,
"byok_usage_daily": 0,
"byok_usage_monthly": 0,
"byok_usage_weekly": 0,
"created_at": "2025-08-24T10:30:00Z",
"creator_user_id": "user_2dHFtVWx2n56w6HkM0000000000",
"disabled": false,
"expires_at": "2027-12-31T23:59:59Z",
"external_user": null,
"hash": "f01d52606dc8f0a8303a7b5cc3fa07109c2e346cec7c0a16b40de462992ce943",
"include_byok_in_limit": true,
"label": "My New API Key",
"last_used_at": null,
"limit": 50,
"limit_remaining": 50,
"limit_reset": "monthly",
"name": "My New API Key",
"updated_at": null,
"usage": 0,
"usage_daily": 0,
"usage_monthly": 0,
"usage_weekly": 0,
"workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"
},
"key": "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"
}Changes
- warning
the
limitrequest property's exclusiveMaximum was set to1000000.00 - warning
the
namerequest property's maxLength was set to256 - warning
the
limitrequest property's min was set to0.00
- warning