Skip to content

AI Operations

Operational status endpoints for monitoring your AI usage. Check rate limits, provider health, session token consumption, and cache state.

Endpoints

MethodPathDescriptionAuthRate Limit
GET/ai/operations/rate-limitCurrent rate limit statusJWT + Entitlement60/min
GET/ai/operations/models/healthAI provider health statusJWT + Entitlement60/min
GET/ai/operations/sessions/:sessionId/usageToken usage for a sessionJWT + Entitlement60/min
GET/ai/operations/cache/statsPrompt cache statisticsJWT + Entitlement60/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
json
{
  "data": {
    "limit": 60,
    "remaining": 42,
    "resetsAt": "2026-03-17T14:01:00.000Z",
    "scope": "account"
  }
}
Response Fields
FieldTypeDescription
limitnumberMaximum requests allowed in the window
remainingnumberRequests remaining in the current window
resetsAtstringISO 8601 timestamp when the window resets
scopestringRate limit scope (currently account)

Code Examples

bash
curl https://api.chainabit.com/api/v1/ai/operations/rate-limit \
  -H "Authorization: Bearer $TOKEN"
javascript
const res = await fetch(`${BASE_URL}/ai/operations/rate-limit`, {
  headers: { Authorization: `Bearer ${TOKEN}` },
});
const { data } = await res.json();
python
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
json
{
  "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
FieldTypeDescription
providerstringProvider name (openai, anthropic, google)
statusstringhealthy, degraded, or unavailable
circuitStatestring | nullCircuit breaker state (closed, half-open, open)
lastCheckedAtstring | nullISO 8601 last health check timestamp

Status meanings:

StatusCircuit StateDescription
healthyclosed or absentProvider is operating normally
degradedhalf-openProvider is being tested after a failure
unavailableopenProvider is blocked due to repeated failures

Code Examples

bash
curl https://api.chainabit.com/api/v1/ai/operations/models/health \
  -H "Authorization: Bearer $TOKEN"
javascript
const res = await fetch(`${BASE_URL}/ai/operations/models/health`, {
  headers: { Authorization: `Bearer ${TOKEN}` },
});
const { data } = await res.json();
python
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
json
{
  "data": {
    "sessionId": "cm5sess01",
    "totalInputTokens": 4250,
    "totalOutputTokens": 1823,
    "totalTokens": 6073,
    "estimatedCostUsd": 0.018,
    "runCount": 5
  }
}
Response Fields
FieldTypeDescription
sessionIdstringThe queried session ID
totalInputTokensnumberTotal input tokens consumed across all runs
totalOutputTokensnumberTotal output tokens consumed across all runs
totalTokensnumberCombined input + output tokens
estimatedCostUsdnumber | nullEstimated cost in USD (null if not calculable)
runCountnumberNumber of AI runs in the session

Code Examples

Use the id from Create a Session response as $SESSION_ID.

bash
curl https://api.chainabit.com/api/v1/ai/operations/sessions/$SESSION_ID/usage \
  -H "Authorization: Bearer $TOKEN"
javascript
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();
python
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
json
{
  "data": {
    "cachedLayers": 3,
    "layers": ["preferences", "persona", "session"]
  }
}
Response Fields
FieldTypeDescription
cachedLayersnumberNumber of cached prompt layers
layersstring[]Names of cached layers

Possible layers:

LayerDescription
preferencesYour language and tone preferences
personaActive persona profile
twinDigital twin context
sessionSession-scoped conversation state
memoryLong-term memory context

Code Examples

bash
curl https://api.chainabit.com/api/v1/ai/operations/cache/stats \
  -H "Authorization: Bearer $TOKEN"
javascript
const res = await fetch(`${BASE_URL}/ai/operations/cache/stats`, {
  headers: { Authorization: `Bearer ${TOKEN}` },
});
const { data } = await res.json();
python
import requests

res = requests.get(
    f"{BASE_URL}/ai/operations/cache/stats",
    headers={"Authorization": f"Bearer {TOKEN}"},
)
data = res.json()["data"]

Built with purpose.