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
| Field | Type | Required | Description |
|---|---|---|---|
input_text | string | Yes | The text to evaluate |
context | object | No | Additional context (user info, conversation history) |
session_id | string | No | Session 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
| Field | Type | Description |
|---|---|---|
risk_score | float | Risk level from 0.0 (safe) to 1.0 (dangerous) |
decision | string | Action: permit, forbid, divert, or depends |
is_blocked | boolean | Whether the content should be blocked |
matched_rules | array | List of safety rules that matched |
detections | array | Detailed detection information |
decision_time_ms | float | Processing time in milliseconds |
Decisions Explained
| Decision | Meaning | Recommended Action |
|---|---|---|
permit | Content is safe | Process normally |
forbid | Content violates policy | Block and inform user |
divert | Requires human review | Queue for moderation |
depends | Need more context | Request 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
}