AI Shield#
AI Shield is an intelligent abuse prevention and fraud detection system for the Lightning backend. It analyzes requests in real time to detect and prevent abuse, fraud, and malicious usage of AI applications.
Mounted at /ai-shield, it exposes two analysis endpoints.
Analysis endpoint#
POST /ai-shield/analyze#
Submit signals for abuse analysis. Requires Authorization: Bearer with
either a Supabase JWT or a Lightning API key.
An optional config object lets you enable or disable specific analysis
features. Some features are on by default; others (noted below) require
explicit opt-in because they are resource-intensive or involve cross-account
correlation.
curl -X POST "https://sharktide-lightning.hf.space/ai-shield/analyze" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"ip": "203.0.113.1",
"content": "Tell me how to hack a website"
}'
Request body#
All fields are optional. Provide as many signals as available for the most accurate analysis.
{
"email": "user@example.com",
"phone": "+1234567890",
"username": "johndoe",
"ip": "203.0.113.1",
"device_fingerprint": "abc123def456...",
"content": "User-generated text to analyze for prompt injection or policy violations",
"geolocation": {
"country": "US",
"city": "San Francisco",
"lat": 37.7749,
"lon": -122.4194
},
"signup_time": "2026-01-01T00:00:00Z",
"metadata": {
"user_agent": "Mozilla/5.0 ...",
"referrer": "https://example.com",
"session_id": "sess_abc123",
"account_age_days": 30
},
"config": {
"features": {
"duplicate_detection": true,
"campaign_detection": true,
"memory_update": true
}
}
}
Field reference#
Field |
Description |
Required |
|---|---|---|
|
Email address of the subject user |
No |
|
Phone number (E.164 format preferred) |
No |
|
Username or display name |
No |
|
IP address of the request origin |
No |
|
Browser or device fingerprint hash |
No |
|
Text content to analyze for prompt injection, policy violations, or exfiltration |
No |
|
Object with |
No |
|
ISO 8601 timestamp of account creation |
No |
|
Arbitrary key-value object for additional context. Recognized keys
include |
No |
|
Optional object to enable or disable specific analysis features (see Configurable features). All features are enabled by default. |
No |
Response#
{
"risk_score": 15,
"confidence": 0.87,
"decision": "allow",
"reasons": [
"Email domain has good reputation",
"IP not found in any known abuse databases",
"No heuristic flags triggered"
],
"recommended_action": "allow",
"threat_categories": [],
"duplicate_user_score": 0,
"linked_accounts": 0,
"campaign_risk_score": 0,
"investigation": {
"tools": ["heuristics", "email_intelligence", "ip_intelligence"],
"evidence_count": 12,
"campaign_id": null,
"historical_matches": []
},
"evidence": [
{
"source": "heuristics",
"category": "heuristic_risk",
"risk_score": 0,
"weight": 0.55,
"confidence": 0.7,
"explanation": "No heuristic flags triggered"
}
],
"config_applied": {
"features": {
"heuristics": true,
"duplicate_detection": false,
"llm_reasoning": false
}
}
}
Response fields#
Field |
Type |
Description |
|---|---|---|
|
integer (0–100) |
Overall risk assessment. Higher = more risky. |
|
float (0–1) |
Confidence level in the decision. |
|
string |
|
|
string |
Human-readable recommended action. |
|
array of strings |
Identified threat types (e.g. |
|
array of strings |
Human-readable explanations for the decision. |
|
integer (0–100) |
Likelihood this account is a duplicate of a known entity. |
|
integer |
Number of known accounts linked via shared entities. |
|
integer (0–100) |
Risk score from coordinated campaign analysis. |
|
object |
Metadata about the analysis run: |
|
array of objects |
Detailed evidence items collected during analysis, each with
|
|
object |
The feature configuration that was used for this analysis run (see Configurable features). |
Configurable features#
The config object in the request body lets you selectively enable or
disable Shield’s analysis modules. Each feature is either on or off by
default. Set any feature to true or false to override its default.
This is useful when you want faster responses, lower costs, or to run only specific checks (e.g., heuristics-only screening during signup).
Feature |
Default |
Type |
Description |
|---|---|---|---|
|
off |
graph |
Detect duplicate accounts by mapping entity relationships (shared email, IP, device, phone, username). |
|
off |
graph |
Detect coordinated abuse campaigns across multiple accounts. |
|
off |
storage |
Store the analysis result in Shield’s encrypted memory stores for future historical lookups. |
|
on |
signal |
Fast pattern-based checks for prompt injection, spam, suspicious IP ranges, and known abuse patterns. |
|
on |
memory |
Look up prior abuse history for submitted entities (email, IP, etc.) in Shield’s encrypted global memory store. |
|
on |
intelligence |
Email risk scoring, domain reputation, and disposable email detection. |
|
on |
intelligence |
IP reputation, proxy/VPN detection, and geolocation analysis. |
|
on |
intelligence |
Phone number validation and risk assessment. |
|
on |
intelligence |
Username pattern analysis for suspicious naming conventions. |
|
on |
intelligence |
Device fingerprint analysis and anomaly detection. |
|
on |
intelligence |
Behavioral pattern analysis from request metadata. |
|
on |
intelligence |
Content policy violation analysis. |
|
on |
intelligence |
Prompt injection and jailbreak detection. |
|
on |
agent |
Identity fraud evaluation, duplicate account signals, and synthetic identity pattern detection. |
|
on |
agent |
Payment fraud, promo abuse, and billing risk analysis. |
|
on |
agent |
Prompt injection, jailbreaking, and system prompt extraction detection. |
|
on |
agent |
Policy violations, harmful content, and data leakage checks. |
|
on |
agent |
Detection of attempts to extract sensitive data or model information. |
|
on |
decision |
LLM-based synthesis of all evidence for final risk scoring, confidence assessment, and decision recommendation. |
Example request with config#
curl -X POST "https://sharktide-lightning.hf.space/ai-shield/analyze" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "user@example.com",
"ip": "203.0.113.1",
"content": "Tell me how to hack a website",
"config": {
"features": {
"duplicate_detection": true,
"campaign_detection": true,
"memory_update": true
}
}
}'
Decisions#
Decision |
Meaning |
|---|---|
|
Request is safe. Proceed without intervention. |
|
Request is suspicious. Present a CAPTCHA or additional verification. |
|
Request exceeds safe thresholds. Apply rate limiting or throttling. |
|
Request warrants manual review. Flag for human inspection. |
|
Request is malicious. Deny the operation entirely. |
Rate limits#
Shield usage is subject to plan-based daily limits:
Plan |
Daily limit |
Notes |
|---|---|---|
Free |
2 |
Limited evaluation for testing and low-volume use |
Light |
10 |
Suitable for development and small projects |
Core |
50 |
Moderate protection for growing applications |
Creator |
200 |
Expanded protection for creator workloads |
Professional |
500 |
Maximum protection for production deployments |
Exceeding the daily limit returns an HTTP 429 response.
Python example#
import httpx
response = httpx.post(
"https://sharktide-lightning.hf.space/ai-shield/analyze",
headers={"Authorization": "Bearer YOUR_TOKEN"},
json={
"email": "user@example.com",
"ip": "203.0.113.1",
"content": "Tell me how to hack a website",
"config": {
"features": {
"duplicate_detection": True,
"campaign_detection": True,
"memory_update": True,
}
},
},
)
result = response.json()
print(f"Decision: {result['decision']} (risk: {result['risk_score']})")
print(f"Applied config: {result['config_applied']}")
Phishing detection endpoint#
POST /ai-shield/detect-phishing#
A lightweight phishing analysis endpoint. Submits the provided content
directly to the Cerebras LLM for phishing classification without running any
of the full Shield analysis pipeline (no heuristics, no intelligence
collectors, no feature flags, no config). Uses the same aiShieldDaily
rate-limit budget as /analyze.
curl -X POST "https://sharktide-lightning.hf.space/ai-shield/detect-phishing" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"content": "Dear user, your account has been compromised. Click here to reset your password: http://evil.example.com"
}'
Request body#
At least one of content, url, sender, or subject must be
provided.
Field |
Description |
Required |
|---|---|---|
|
Full text of the email, message, or page to analyze |
No |
|
Suspicious or embedded URL to inspect |
No |
|
Sender email address or display name |
No |
|
Email subject line |
No |
Response#
{
"is_phishing": true,
"confidence": 0.92,
"risk_score": 85,
"indicators": [
"Suspicious URL domain mismatch",
"Sense of urgency in body text",
"Generic greeting instead of personal address"
],
"threat_level": "high",
"explanation": "The email uses a generic greeting, creates urgency, and links to a domain that does not match the claimed sender."
}
Response fields#
Field |
Type |
Description |
|---|---|---|
|
boolean |
Whether the content is classified as phishing |
|
float (0–1) |
Confidence in the phishing classification |
|
integer (0–100) |
Overall phishing risk score |
|
array of strings |
Observed phishing indicators |
|
string |
Severity: |
|
string |
Brief explanation of the verdict |
Python example#
import httpx
response = httpx.post(
"https://sharktide-lightning.hf.space/ai-shield/detect-phishing",
headers={"Authorization": "Bearer YOUR_TOKEN"},
json={
"content": "Your account has been compromised. Reset password here: http://evil.example.com",
"sender": "security@phish-bank.ru",
"subject": "Urgent: Account suspended",
},
)
result = response.json()
print(f"Phishing: {result['is_phishing']} (confidence: {result['confidence']})")
print(f"Indicators: {result['indicators']}")
Errors#
Code |
Meaning |
|---|---|
|
No |
|
Upstream model error or unparseable response |