API Reference
All endpoints are REST. The base URL is http://localhost:8000 (or http://localhost:8000 for local development).
Authentication
AI Guardian uses two authentication mechanisms:
- API Key — for proxy requests. Pass as
Authorization: Bearer aig_.... API keys are tenant-scoped and start withaig_. - JWT Token — for dashboard API endpoints. Obtain via
POST /api/v1/admin/login. Pass asAuthorization: Bearer <jwt>.
Get JWT Token
curl -X POST http://localhost:8000/api/v1/admin/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@example.com", "password": "yourpassword"}'Response:
{"access_token": "eyJ...", "token_type": "bearer"}Proxy
/api/v1/proxy/chat/completionsAuth: API KeyOpenAI-compatible Chat Completions endpoint. Send requests in the exact same format as the OpenAI API. AI Guardian filters the request, routes it, and returns either the LLM response or an error.
curl -X POST http://localhost:8000/api/v1/proxy/chat/completions \
-H "Authorization: Bearer aig_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Hello!"}]
}'Responses
| Status | Meaning | Body |
|---|---|---|
| 200 | Safe — forwarded to LLM | OpenAI completion response |
| 202 | Queued for review | { "error": { "code": "queued_for_review", "review_item_id": "..." } } |
| 403 | Blocked | { "error": { "code": "request_blocked", "risk_score": N } } |
| 401 | Invalid API key | { "detail": "Invalid or missing API key" } |
Review Queue
/api/v1/review/queueAuth: JWTList review items for the current tenant. Supports ?status=pending|approved|rejected, limit, and offset query params.
/api/v1/review/queue/{item_id}Auth: JWTGet a single review item with its associated request.
/api/v1/review/queue/{item_id}/decideAuth: JWTSubmit a decision for a review item.
{ "decision": "approve" | "reject" | "escalate", "note": "optional string" }Audit Logs
/api/v1/audit/logsAuth: JWTList audit log entries for the current tenant. Query params: event_type, severity, limit (max 500), offset. Results are ordered by created_at descending.
Admin
/api/v1/admin/loginAuth: NoneAuthenticate with email + password. Returns JWT access token.
/api/v1/admin/meAuth: JWTGet the current user profile.
/api/v1/admin/tenants/{tenant_id}/policiesAuth: JWTGet the active policy for a tenant.
/api/v1/admin/tenants/{tenant_id}/policiesAuth: JWTUpdate the active policy for a tenant.
/api/v1/admin/api-keysAuth: JWTGenerate a new API key for the current tenant.
Error Codes
| Code | Description |
|---|---|
| request_blocked | Request was blocked by the input or output filter |
| queued_for_review | Request is awaiting human review |
| no_active_policy | Tenant has no active policy configured |
| upstream_error | The upstream LLM returned an error |