API Keys

Manage user API keys via OAuth

Overview

Let users create and manage their API keys through your app's interface.

Authentication: OAuth token
Required Scopes: apikeys:read, apikeys:write


List API Keys

Get user's existing API keys.

Endpoint: GET /api/user/api-keys

const response = await fetch('https://hypery.ai/api/user/api-keys', {
  headers: {
    'Authorization': `Bearer ${oauthAccessToken}`
  }
})
 
const { apiKeys } = await response.json()
console.log(apiKeys)

Response:

{
  "success": true,
  "apiKeys": [
    {
      "id": "507f1f77bcf86cd799439011",
      "name": "Production Key",
      "key": "ak_1699564800_abc123...",
      "permissions": ["ai:chat", "ai:models"],
      "lastUsed": "2025-11-16T10:30:00Z",
      "createdAt": "2025-11-01T10:00:00Z"
    }
  ]
}

Output Fields

FieldTypeDescription
idstringAPI key ID
namestringUser-defined name
keystringThe actual API key (starts with ak_)
permissionsarrayScopes granted to this key
lastUsedstring | nullWhen last used (ISO timestamp)
createdAtstringWhen created (ISO timestamp)

Create API Key

Generate a new API key for the user.

Endpoint: POST /api/user/api-keys

const response = await fetch('https://hypery.ai/api/user/api-keys', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${oauthToken}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'My API Key',
    permissions: ['ai:chat', 'ai:models']
  })
})
 
const { apiKey } = await response.json()
console.log('New key:', apiKey.key)

Input Parameters

ParameterTypeRequiredDescription
namestringYesDescriptive name for the key
permissionsarrayYesScopes to grant (at least one)

Available permissions:

  • ai:chat / ai:completions — Chat completions
  • ai:models — List models
  • ai:images — Image generation
  • ai:embeddings — Embeddings
  • ai:audio — TTS, transcriptions, realtime mint
  • billing:read — View credits/usage

See OAuth scopes.

Response:

{
  "success": true,
  "apiKey": {
    "id": "507f...",
    "name": "My API Key",
    "key": "ak_1699564800_abc123...",
    "permissions": ["ai:chat", "ai:models"],
    "createdAt": "2025-11-16T10:30:00Z"
  }
}

Delete API Key

Revoke an API key.

Endpoint: DELETE /api/user/api-keys/:id

await fetch(`https://hypery.ai/api/user/api-keys/${keyId}`, {
  method: 'DELETE',
  headers: {
    'Authorization': `Bearer ${oauthToken}`
  }
})

Response:

{
  "success": true
}

Error Responses

Invalid Permissions

{
  "success": false,
  "error": "At least one permission is required"
}

Status Code: 400

Missing Name

{
  "success": false,
  "error": "API key name is required"
}

Status Code: 400


Next Steps