Errors & Rate Limits

Error responses and rate limiting for Kodey API

Error Responses

Standard Error Format

{
  "error": "Error type",
  "message": "Human-readable error description"
}

Common Error Codes

HTTP StatusErrorDescription
400Bad RequestInvalid request body or missing required fields
401UnauthorizedInvalid or missing API key
403ForbiddenPublishable key used for secret-key-only endpoint
404Not FoundResource not found
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error

Authentication Errors

Invalid API Key:

{
  "message": "Unauthorized: Invalid API key."
}

Publishable Key Access Denied:

{
  "error": "Forbidden",
  "message": "This endpoint requires a secret API key (sk_live_*). You are using a publishable API key (pk_live_*) which only has access to chat and message endpoints.",
  "allowedEndpoints": [
    "POST /chat - Create a chat",
    "GET /chat/:chatId - Get chat details",
    "POST /chat/:chatId/message - Send a message",
    "GET /chat/:chatId/message - List messages"
  ],
  "upgradeInstructions": "Publishable API keys are restricted to chat endpoints. Please use your secret API key (sk_live_*) for full API access."
}

Rate Limits

Key TypeLimitWindow
Publishable (pk_live_)100 requests1 minute
Secret (sk_live_)1000 requests1 minute

Rate Limit Headers

Rate limit headers are included in all responses:

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1705315800
HeaderDescription
X-RateLimit-LimitMaximum requests allowed in the window
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when the window resets

Rate Limit Exceeded Response

When you exceed the rate limit, you'll receive a 429 Too Many Requests response:

{
  "error": "Too Many Requests",
  "message": "Rate limit exceeded. Please retry after 60 seconds.",
  "retryAfter": 60
}