GET
/v1/key-statusKey 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
| Field | Type | Description |
|---|---|---|
| valid | boolean | Whether the key is active and not expired/revoked. |
| keyType | string | Key type: 'auth' (OAuth-based) or 'api' (manual). |
| rateLimit.rpm | integer | Maximum requests per minute allowed for this key. |
| tokenWindow | object | Rolling window of token usage and limits. |
| tokenWindow.tokensUsed | integer | Tokens consumed in the current window. |
| tokenWindow.tokensLimit | integer | Maximum tokens allowed in the window. |
| tokenWindow.tokensRemaining | integer | Tokens remaining in the current window. |
| tokenWindow.windowStart | string | ISO timestamp when the current window started. |
| tokenWindow.windowHours | integer | Duration of the token window in hours. |
| monthlyBudget | object | Monthly token budget (null if not configured). |
| monthlyBudget.tokensUsed | integer | Tokens consumed this calendar month. |
| monthlyBudget.tokensLimit | integer | Monthly token cap (null if unlimited). |
| monthlyBudget.tokensRemaining | integer | Tokens remaining this month. |
| allowedModels | array | List of allowed model IDs (null if all allowed). |
| maxTokensPerRequest | integer | Max 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']}")