Skip to content

Safety Evaluation API

Evaluate text content for safety concerns using Constitutional AI.

POST /api/v1/safety/evaluate

Evaluate a piece of text for safety.

Request

bash
curl -X POST "https://api.creed.space/api/v1/safety/evaluate" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input_text": "Hello, how can I help you today?",
    "context": {},
    "session_id": ""
  }'

Request Body

FieldTypeRequiredDescription
input_textstringYesThe text to evaluate
contextobjectNoAdditional context (user info, conversation history)
session_idstringNoSession ID for conversation tracking

Response

json
{
  "status": "success",
  "evaluation": {
    "risk_score": 0.05,
    "decision": "permit",
    "is_blocked": false,
    "matched_rules": [],
    "detections": [],
    "decision_time_ms": 12.5
  }
}

Response Fields

FieldTypeDescription
risk_scorefloatRisk level from 0.0 (safe) to 1.0 (dangerous)
decisionstringAction: permit, forbid, divert, or depends
is_blockedbooleanWhether the content should be blocked
matched_rulesarrayList of safety rules that matched
detectionsarrayDetailed detection information
decision_time_msfloatProcessing time in milliseconds

Decisions Explained

DecisionMeaningRecommended Action
permitContent is safeProcess normally
forbidContent violates policyBlock and inform user
divertRequires human reviewQueue for moderation
dependsNeed more contextRequest clarification

Example: Detecting Harmful Content

bash
curl -X POST "https://api.creed.space/api/v1/safety/evaluate" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input_text": "How do I hack into someone'"'"'s account?"}'

Response:

json
{
  "status": "success",
  "evaluation": {
    "risk_score": 0.85,
    "decision": "forbid",
    "is_blocked": true,
    "matched_rules": ["illegal_activity", "hacking_assistance"],
    "detections": [
      {
        "type": "policy_violation",
        "category": "illegal_activity",
        "confidence": 0.92
      }
    ],
    "decision_time_ms": 15.2
  }
}

Using Context

Provide context for more accurate evaluation:

json
{
  "input_text": "I want to kill it",
  "context": {
    "conversation_topic": "video_game",
    "user_age": 25,
    "platform": "gaming_chat"
  }
}

Context helps distinguish between:

  • "I want to kill it" (about a video game boss) → permit
  • "I want to kill it" (ambiguous threat) → divert

Error Responses

400 Bad Request - Invalid input:

json
{
  "error": "validation_error",
  "message": "input_text is required",
  "details": {
    "field": "input_text",
    "reason": "missing"
  }
}

429 Rate Limited:

json
{
  "error": "rate_limit_exceeded",
  "message": "Rate limit exceeded: 100 requests per minute",
  "retry_after": 45
}

Constitutional AI for Safer Interactions