API Keys

Create a new API key

Changed on

Create 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.

post/keys

Request

  • Base URL
    https://openrouter.ai/api/v1
  • Auth
    HTTP bearer

Request body

object required
creator_user_id, string nullable

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.

expires_at, string date-time nullable

Optional ISO 8601 UTC expiration timestamp. Must include seconds (YYYY-MM-DDTHH:MM:SSZ; fractional seconds allowed); minute-precision timestamps are rejected.

external, object

Optional partner-defined identity associated with the created API key.

include_byok_in_limit, boolean

Whether external BYOK usage counts toward this key's limit. When false, only credit usage is checked against limit.

limit, number double nullable

Optional spending limit for the API key in USD

limit_reset, 'daily' | 'weekly' | 'monthly' | 'null' nullable

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, string required

Name for the new API key

workspace_id, string uuid

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

object required
data, object required

The created API key information

key, string required

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 limit request property's exclusiveMaximum was set to 1000000.00

    • warning

      the name request property's maxLength was set to 256

    • warning

      the limit request property's min was set to 0.00