SentinelAI

API Reference

Full reference for the SentinelAI REST API — no external docs needed

API Reference

The SentinelAI REST API is a FastAPI service. This page is the canonical reference — you do not need to visit any external API docs.

Base URL

DeploymentBase URL
Managed cloudhttps://sentinel-ai-dml3.onrender.com
Self-hostedhttp://localhost:8000

Interactive OpenAPI docs remain available at <base_url>/api/docs for your instance, but everything you need is documented here.

Authentication

Every request must include an API key:

Authorization: Bearer sk_...

Endpoints

POST /api/analyze

The core risk-analysis endpoint.

Request body

{
  "prompt": "Summarize the Q3 report",
  "response": "Revenue grew 45% year over year."
}
FieldTypeRequiredDescription
promptstringyesThe user prompt
responsestringyesThe model's response to score

Response

{
  "final_risk_score": 0.72,
  "flags": ["violence", "harmful_instructions"],
  "confidence": 0.88,
  "decision": "block",
  "action_taken": "block",
  "decision_reason": "Multiple high-severity output risk categories triggered",
  "settings_version": 3,
  "thresholds_applied": {"block": 0.6},
  "log_id": "analysis-241"
}
FieldTypeDescription
final_risk_scorefloatAggregated risk score, 0–1
flagsarrayTriggered detectors and risk categories (e.g. prompt_anomaly, jailbreak_detected, unsafe_output, violence)
confidencefloat | nullConfidence of the risk classification
decisionstringallow, warn, block, or escalate
action_takenstringThe action executed by the policy engine
decision_reasonstringHuman-readable explanation from the risk reasoner
settings_versionint | nullWhich policy version produced this verdict
thresholds_appliedany | nullThe exact thresholds used
log_idstring | nullID for feedback reporting

Status codes

CodeMeaning
200Analysis complete
401Missing or invalid API key
422Invalid request body
429Rate limit exceeded
500Internal error — your prompt/response was never served unverified

POST /api/analyze/external

The endpoint the Python SDK calls. Extends /api/analyze with source (your application identifier), plus optional user_id, session_id, and client_metadata for per-user/session tracking.

GET /api/logs

Full interaction audit trail — every analyzed pair with score and disposition.

GET /api/settings

Current detection rules configuration.

POST /api/settings

Update detection rules. Every change is versioned.

GET /api/settings/history

Version history of your detection policy — see exactly what policy was active when any score was produced.

GET /api/baselines · POST /api/baselines

Stored baseline profiles for distribution-shift detection — flag when production traffic drifts from the norm.

Organization usage endpoints

The following endpoints return per-organization usage and risk data. All require the usage.view permission and a valid Authorization: Bearer sk_... header.

Paths use {org_id} — the organization identifier resolved from the request.

GET /api/orgs/{org_id}/usage

Aggregated usage for an organization. Accepts an optional days query parameter (default 30, range 1365) controlling the aggregation window.

Query parameters

ParameterTypeDefaultRangeDescription
daysint301365Aggregation window in days

Response

{
  "total_requests": 1280,
  "requests_24h": 45,
  "success_count": 1263,
  "success_rate": 98.67,
  "error_count": 17,
  "error_rate": 1.33,
  "avg_latency_ms": 142.5
}
FieldTypeDescription
total_requestsintTotal analyzed events for the org
requests_24hintEvents in the last 24 hours
success_countintEvents that completed successfully
success_ratefloatSuccess percentage, 0–100
error_countintFailed events
error_ratefloatError percentage, 0–100
avg_latency_msfloat | nullMean latency in milliseconds

GET /api/orgs/{org_id}/usage/stats

Dashboard usage statistics for an organization. Returns the same aggregated usage shape as /usage, optimized for dashboard widgets.

GET /api/orgs/{org_id}/usage/trend

Daily risk trend buckets for an organization — the data source for the dashboard Risk Trend chart. Returns one bucket per day across the requested window, ordered chronologically.

Query parameters

ParameterTypeDefaultRangeDescription
daysint301365Number of daily buckets to return

Response

A JSON array of daily buckets:

[
  {
    "date": "2026-08-01",
    "avg_risk_score": 0.23,
    "event_count": 45,
    "critical_count": 2
  },
  {
    "date": "2026-08-02",
    "avg_risk_score": 0.31,
    "event_count": 52,
    "critical_count": 4
  }
]
FieldTypeDescription
datestringISO date (YYYY-MM-DD) of the bucket
avg_risk_scorefloatMean risk score for the day, 0–1
event_countintTotal events recorded that day
critical_countintEvents that reached critical risk threshold

Status codes

CodeMeaning
200Trend buckets returned
401Missing or invalid API key
403Caller lacks usage.view permission for this org
422days outside the allowed 1–365 range

Example (curl)

curl -H "Authorization: Bearer sk_..." \
  "https://sentinel-ai-dml3.onrender.com/api/orgs/42/usage/trend?days=30"

SDK

The Python SDK wraps these endpoints with retries, timeouts, and error handling.

pip install sentinelai-risk
from sentinelai import SentinelAIClient

client = SentinelAIClient(api_key="sk_...")
result = client.verify(prompt=prompt, response=llm_output)

On this page