AI Operations
Operational status endpoints for monitoring your AI usage. Check rate limits, provider health, session token consumption, and cache state.
Endpoints
| Method | Path | Description | Auth | Rate Limit |
|---|---|---|---|---|
| GET | /ai/operations/rate-limit | Current rate limit status | JWT + Entitlement | 60/min |
| GET | /ai/operations/models/health | AI provider health status | JWT + Entitlement | 60/min |
| GET | /ai/operations/sessions/:sessionId/usage | Token usage for a session | JWT + Entitlement | 60/min |
| GET | /ai/operations/cache/stats | Prompt cache statistics | JWT + Entitlement | 60/min |
GET /ai/operations/rate-limit
Get your current AI rate limit consumption. Returns how many requests remain in the current window and when it resets.
Authentication: JWT Bearer token + active AI entitlement required. Rate limit: 60/min
Request
- Headers:
Authorization: Bearer <token>
Response
Response Example
{
"data": {
"limit": 60,
"remaining": 42,
"resetsAt": "2026-03-17T14:01:00.000Z",
"scope": "account"
}
}Response Fields
| Field | Type | Description |
|---|---|---|
limit | number | Maximum requests allowed in the window |
remaining | number | Requests remaining in the current window |
resetsAt | string | ISO 8601 timestamp when the window resets |
scope | string | Rate limit scope (currently account) |
Code Examples
curl https://api.chainabit.com/api/v1/ai/operations/rate-limit \
-H "Authorization: Bearer $TOKEN"const res = await fetch(`${BASE_URL}/ai/operations/rate-limit`, {
headers: { Authorization: `Bearer ${TOKEN}` },
});
const { data } = await res.json();import requests
res = requests.get(
f"{BASE_URL}/ai/operations/rate-limit",
headers={"Authorization": f"Bearer {TOKEN}"},
)
data = res.json()["data"]GET /ai/operations/models/health
Get the health status of AI provider endpoints. Uses the circuit breaker pattern to report provider availability.
Authentication: JWT Bearer token + active AI entitlement required. Rate limit: 60/min
Request
- Headers:
Authorization: Bearer <token>
Response
Response Example
{
"data": [
{
"provider": "openai",
"status": "healthy",
"circuitState": null,
"lastCheckedAt": null
},
{
"provider": "anthropic",
"status": "healthy",
"circuitState": null,
"lastCheckedAt": null
},
{
"provider": "google",
"status": "degraded",
"circuitState": "half-open",
"lastCheckedAt": "2026-03-17T13:55:00.000Z"
}
]
}Response Fields
| Field | Type | Description |
|---|---|---|
provider | string | Provider name (openai, anthropic, google) |
status | string | healthy, degraded, or unavailable |
circuitState | string | null | Circuit breaker state (closed, half-open, open) |
lastCheckedAt | string | null | ISO 8601 last health check timestamp |
Status meanings:
| Status | Circuit State | Description |
|---|---|---|
healthy | closed or absent | Provider is operating normally |
degraded | half-open | Provider is being tested after a failure |
unavailable | open | Provider is blocked due to repeated failures |
Code Examples
curl https://api.chainabit.com/api/v1/ai/operations/models/health \
-H "Authorization: Bearer $TOKEN"const res = await fetch(`${BASE_URL}/ai/operations/models/health`, {
headers: { Authorization: `Bearer ${TOKEN}` },
});
const { data } = await res.json();import requests
res = requests.get(
f"{BASE_URL}/ai/operations/models/health",
headers={"Authorization": f"Bearer {TOKEN}"},
)
data = res.json()["data"]GET /ai/operations/sessions/:sessionId/usage
Get token usage summary for all AI runs within a session.
Authentication: JWT Bearer token + active AI entitlement required. Rate limit: 60/min
Request
- Headers:
Authorization: Bearer <token> - Path params:
sessionId
Response
Response Example
{
"data": {
"sessionId": "cm5sess01",
"totalInputTokens": 4250,
"totalOutputTokens": 1823,
"totalTokens": 6073,
"estimatedCostUsd": 0.018,
"runCount": 5
}
}Response Fields
| Field | Type | Description |
|---|---|---|
sessionId | string | The queried session ID |
totalInputTokens | number | Total input tokens consumed across all runs |
totalOutputTokens | number | Total output tokens consumed across all runs |
totalTokens | number | Combined input + output tokens |
estimatedCostUsd | number | null | Estimated cost in USD (null if not calculable) |
runCount | number | Number of AI runs in the session |
Code Examples
Use the id from Create a Session response as $SESSION_ID.
curl https://api.chainabit.com/api/v1/ai/operations/sessions/$SESSION_ID/usage \
-H "Authorization: Bearer $TOKEN"const sessionId = process.env.SESSION_ID; // id of the AI session to inspect
const res = await fetch(`${BASE_URL}/ai/operations/sessions/${sessionId}/usage`, {
headers: { Authorization: `Bearer ${TOKEN}` },
});
const { data } = await res.json();import os
import requests
session_id = os.environ["SESSION_ID"] # id of the AI session to inspect
res = requests.get(
f"{BASE_URL}/ai/operations/sessions/{session_id}/usage",
headers={"Authorization": f"Bearer {TOKEN}"},
)
data = res.json()["data"]GET /ai/operations/cache/stats
Get prompt cache statistics for your account. Shows which prompt compilation layers are currently cached.
Authentication: JWT Bearer token + active AI entitlement required. Rate limit: 60/min
Request
- Headers:
Authorization: Bearer <token>
Response
Response Example
{
"data": {
"cachedLayers": 3,
"layers": ["preferences", "persona", "session"]
}
}Response Fields
| Field | Type | Description |
|---|---|---|
cachedLayers | number | Number of cached prompt layers |
layers | string[] | Names of cached layers |
Possible layers:
| Layer | Description |
|---|---|
preferences | Your language and tone preferences |
persona | Active persona profile |
twin | Digital twin context |
session | Session-scoped conversation state |
memory | Long-term memory context |
Code Examples
curl https://api.chainabit.com/api/v1/ai/operations/cache/stats \
-H "Authorization: Bearer $TOKEN"const res = await fetch(`${BASE_URL}/ai/operations/cache/stats`, {
headers: { Authorization: `Bearer ${TOKEN}` },
});
const { data } = await res.json();import requests
res = requests.get(
f"{BASE_URL}/ai/operations/cache/stats",
headers={"Authorization": f"Bearer {TOKEN}"},
)
data = res.json()["data"]