GET/v1/key-status

Key Status

Check your API key validity, rate limits, token window usage, and monthly budget. Use this endpoint to monitor usage and avoid hitting limits.

Test the key status endpoint:

Bash
curl https://api.mr-coder.io/v1/key-status \
  -H "x-api-key: sk-mr-auth-your-key-here"

Response Format

JSON
{
  "valid": true,
  "keyType": "auth",
  "rateLimit": {
    "rpm": 60
  },
  "tokenWindow": {
    "tokensUsed": 15000,
    "tokensLimit": 1000000,
    "tokensRemaining": 985000,
    "windowStart": "2026-05-25T10:00:00Z",
    "windowHours": 5
  },
  "monthlyBudget": {
    "tokensUsed": 450000,
    "tokensLimit": 5000000,
    "tokensRemaining": 4550000
  },
  "allowedModels": null,
  "maxTokensPerRequest": null
}

Response Fields

FieldTypeDescription
validbooleanWhether the key is active and not expired/revoked.
keyTypestringKey type: 'auth' (OAuth-based) or 'api' (manual).
rateLimit.rpmintegerMaximum requests per minute allowed for this key.
tokenWindowobjectRolling window of token usage and limits.
tokenWindow.tokensUsedintegerTokens consumed in the current window.
tokenWindow.tokensLimitintegerMaximum tokens allowed in the window.
tokenWindow.tokensRemainingintegerTokens remaining in the current window.
tokenWindow.windowStartstringISO timestamp when the current window started.
tokenWindow.windowHoursintegerDuration of the token window in hours.
monthlyBudgetobjectMonthly token budget (null if not configured).
monthlyBudget.tokensUsedintegerTokens consumed this calendar month.
monthlyBudget.tokensLimitintegerMonthly token cap (null if unlimited).
monthlyBudget.tokensRemainingintegerTokens remaining this month.
allowedModelsarrayList of allowed model IDs (null if all allowed).
maxTokensPerRequestintegerMax tokens per request limit (null if unlimited).

Error Response

If the key is invalid, expired, or revoked, the response will indicate this:

JSON
{
  "valid": false,
  "keyType": null,
  "rateLimit": null,
  "tokenWindow": null,
  "monthlyBudget": null,
  "error": {
    "type": "authentication_error",
    "message": "Invalid API key. Please check that your API key is correct and try again."
  }
}

Code Examples

Bash
curl https://api.mr-coder.io/v1/key-status \
  -H "x-api-key: sk-mr-auth-xxxxxxxx"
TypeScript
const response = await fetch(
  'https://api.mr-coder.io/v1/key-status',
  {
    headers: {
      'x-api-key': 'sk-mr-auth-xxxxxxxx',
    },
  }
);

const status = await response.json();

if (!status.valid) {
  console.error('Key is invalid:', status.error?.message);
} else {
  console.log(`Rate limit: ${status.rateLimit?.rpm} RPM`);
  console.log(`Tokens remaining: ${status.tokenWindow?.tokensRemaining}`);
}
Python
import requests

response = requests.get(
    'https://api.mr-coder.io/v1/key-status',
    headers={
        'x-api-key': 'sk-mr-auth-xxxxxxxx',
    }
)

status = response.json()

if not status['valid']:
    print(f"Key is invalid: {status['error']['message']}")
else:
    print(f"Rate limit: {status['rateLimit']['rpm']} RPM")
    print(f"Tokens remaining: {status['tokenWindow']['tokensRemaining']}")