Equitas: AI Safety & Observability Platform
Enterprise-grade AI safety wrapper for LLM applications
Equitas is a comprehensive AI safety platform that wraps around OpenAI (and other LLM) APIs to provide real-time toxicity detection, bias checking, hallucination detection, jailbreak prevention, and compliance monitoring. Built for enterprises who need to ensure their AI applications are safe, unbiased, and compliant.
Key Features
- Multi-Layer Safety Detection - Toxicity, bias, hallucination, and jailbreak detection
- Custom ML Models - No vendor lock-in, uses open-source transformer models
- Credit-Based System - Flexible usage-based billing and credit management
- Real-Time Analytics - Comprehensive dashboard with metrics and incident tracking
- Enterprise Ready - Multi-tenant architecture with data isolation
- Easy Integration - Drop-in replacement for OpenAI API
Quick Start
Installation
pip install equitas
Basic Usage
from equitas_sdk import Equitas, SafetyConfig
# Initialize client
client = Equitas(
openai_api_key="sk-your-openai-key",
equitas_api_key="your-equitas-key",
tenant_id="your-org-id",
backend_api_url="http://localhost:8000", # Optional
)
# Make safe API calls
response = await client.chat.completions.create_async(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}],
safety_config=SafetyConfig(
on_flag="auto-correct", # strict | auto-correct | warn-only
enable_hallucination_check=True,
)
)
# Access safety metadata
print(f"Toxicity Score: {response.safety_scores.toxicity_score}")
print(f"Hallucination Score: {response.safety_scores.hallucination_score}")
print(f"Bias Flags: {response.safety_scores.bias_flags}")
print(f"Jailbreak Detected: {response.safety_scores.jailbreak_flag}")
Architecture
┌─────────────────┐
│ Your App │
│ + Equitas SDK │
└────────┬────────┘
│
└──────────────► Equitas Backend API
├── Custom Toxicity Detection
├── Bias Detection
├── Jailbreak Prevention
├── Hallucination Detection
└── Credit Management
↓
Database (Logs, Metrics, Credits)
↓
Dashboard & Analytics
Safety Features
1. Custom Toxicity Detection
- Library: Uses
detoxifylibrary (pre-trained models) - Models:
original,unbiased,multilingualvariants available - No OpenAI Dependency: Fully independent, no vendor lock-in
- Categories: Detects toxic, severe toxic, obscene, threat, insult, identity hate
- Cost: 1 credit per analysis
2. Hallucination Detection
- Multi-Component: Semantic consistency, contradiction detection, factuality checking
- Pattern Analysis: Detects overconfident language and unsupported claims
- Context Aware: Can verify against knowledge base
- Cost: 3 credits per analysis
3. Advanced Jailbreak Detection
- Pattern Matching: Detects known jailbreak patterns
- Semantic Analysis: Catches paraphrased attempts
- Behavioral Detection: Identifies suspicious indicators
- Adversarial Detection: Catches encoding tricks
- Cost: 1.5 credits per analysis
4. Enhanced Bias Detection
- Stereotype Association: Detects stereotype reinforcement
- Demographic Parity: Tests fairness across demographics
- Fairness Metrics: Statistical parity and equalized odds
- Intersectional Analysis: Detects compounding bias
- Cost: 2 credits per analysis
5. Credit Management System
- Balance Tracking: Real-time credit balance monitoring
- Transaction History: Full audit trail
- Usage-Based Billing: Pay only for what you use
- Flexible Plans: Add credits as needed
Project Structure
equitas/
├── equitas_sdk/ # Client SDK
│ ├── client.py # Main SDK client
│ ├── models.py # Data models
│ └── exceptions.py # Custom exceptions
│
├── backend_api/ # Backend API
│ ├── main.py # FastAPI application
│ ├── api/v1/ # API endpoints
│ │ ├── analysis.py # Safety analysis endpoints
│ │ ├── credits.py # Credit management
│ │ ├── metrics.py # Analytics
│ │ └── incidents.py # Incident tracking
│ ├── services/ # ML services
│ │ ├── custom_toxicity.py
│ │ ├── hallucination.py
│ │ ├── advanced_jailbreak.py
│ │ └── enhanced_bias.py
│ └── models/ # Database models
│
└── examples/ # Usage examples
Setup & Configuration
1. Install Dependencies
pip install equitas
2. Start Backend API
# Option 1: Direct run
python -m backend_api.main
# Option 2: Using uvicorn
uvicorn backend_api.main:app --reload --port 8000
Backend will be available at http://localhost:8000
3. Configure Environment
Create .env file:
# OpenAI (for LLM calls)
OPENAI_API_KEY=sk-your-key-here
# Database
DATABASE_URL=sqlite+aiosqlite:///.equitas.db
# Security
SECRET_KEY=your-secret-key-change-in-production
4. Add Credits to Tenant
import httpx
# Add credits via API
response = httpx.post(
"http://localhost:8000/v1/credits/add",
headers={
"Authorization": "Bearer your-api-key",
"X-Tenant-ID": "your-tenant-id",
},
json={
"amount": 1000.0,
"description": "Initial credits",
}
)
API Endpoints
Safety Analysis
POST /v1/analysis/toxicity
Analyze text for toxicity using custom ML models.
{
"text": "Text to analyze",
"tenant_id": "org123"
}
POST /v1/analysis/bias
Check for demographic bias.
{
"prompt": "Original prompt",
"response": "LLM response",
"tenant_id": "org123"
}
POST /v1/analysis/jailbreak
Detect jailbreak attempts.
{
"text": "Text to check",
"tenant_id": "org123"
}
POST /v1/analysis/hallucination
Detect hallucinations in responses.
{
"prompt": "Original prompt",
"response": "LLM response",
"tenant_id": "org123",
"context": ["fact1", "fact2"] // Optional
}
Credit Management
GET /v1/credits/balance
Get current credit balance.
POST /v1/credits/add
Add credits to account.
{
"amount": 1000.0,
"description": "Monthly subscription",
"reference_type": "subscription"
}
GET /v1/credits/transactions
Get transaction history with pagination.
POST /v1/credits/calculate-cost
Calculate cost before executing operations.
{
"operation_types": ["toxicity", "bias", "jailbreak"]
}
Analytics & Metrics
GET /v1/metrics
Get aggregated metrics (usage, safety scores, incidents).
GET /v1/incidents
Query flagged incidents with filters.
Credit System
Credit Costs
| Operation | Cost (Credits) |
|---|---|
| Toxicity Detection | 1.0 |
| Bias Detection | 2.0 |
| Jailbreak Detection | 1.5 |
| Hallucination Detection | 3.0 |
| Remediation | 2.0 |
| Full Analysis | 7.5 |
Handling Insufficient Credits
from equitas_sdk.exceptions import InsufficientCreditsException
try:
response = await client.chat.completions.create_async(...)
except InsufficientCreditsException as e:
print(f"Insufficient credits!")
print(f"Required: {e.required}")
print(f"Available: {e.available}")
# Handle error - prompt user to add credits
Testing
Run Dataset Tests
# Test all components
python tests/run_dataset_tests.py
# Test specific component
python tests/run_dataset_tests.py toxicity datasets/toxicity/test.csv
See tests/DATASET_TESTING_GUIDE.md for details.
Safety Configuration
SafetyConfig(
on_flag="auto-correct", # strict | auto-correct | warn-only
toxicity_threshold=0.7,
enable_bias_check=True,
enable_jailbreak_check=True,
enable_hallucination_check=True,
enable_remediation=True,
)
Action Modes
- strict: Raises exception on safety violation
- auto-correct: Automatically remediates unsafe content
- warn-only: Returns warnings but allows content
Deployment
Docker
docker build -t equitas .
docker run -p 8000:8000 --env-file .env equitas
Production Considerations
- Use PostgreSQL instead of SQLite
- Configure proper CORS origins
- Set up Redis for caching
- Enable rate limiting
- Use GPU for faster ML inference
- Set up monitoring and alerting
Documentation
- Technical Roadmap - Detailed technical documentation
- Credit System - Credit management guide
- Dataset Testing - Testing framework guide
- API Docs - Interactive Swagger UI (when running)
What Makes Equitas Stand Out
- No Vendor Lock-In - Custom ML models, no dependency on external APIs
- Comprehensive - Covers toxicity, bias, hallucination, jailbreak, and more
- Enterprise Ready - Multi-tenant, credit system, audit trails
- Explainable - Detailed explanations for every safety flag
- Production Ready - Low latency, scalable, battle-tested
- Easy Integration - Drop-in replacement for OpenAI API
Contributing
Contributions welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE file
Support
- GitHub Issues: github.com/aryan4codes/Equitas/issues
- Email: av.rajpurkar@gmail.com
- Documentation: github.com/aryan4codes/Equitas#readme
Built for AI Safety
Start protecting your AI applications today with Equitas.
Metadata
Release files for equitas 2.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| equitas-2.0.4.tar.gz | 1.6 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| equitas-2.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.7 MB
Release files / equitas-2.0.4.tar.gz
| Download URL | equitas-2.0.4.tar.gz |
|---|---|
| Size | 1.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a45712a32f8d634881a122bbca909d01661ee0e16c47e1685b248cd23e9093d
|
|
BLAKE2b-256 checksum How to use checksums |
ee7f0b43c8269c611d8d32369805dac68159f8b6b6e0c234b9d856d9e693562d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / equitas-2.0.4-py3-none-any.whl
| Download URL | equitas-2.0.4-py3-none-any.whl |
|---|---|
| Size | 91.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37b443c7f84ac21f03c1bde80f33c110ba35883bd217be6f7e6388b0515a1388
|
|
BLAKE2b-256 checksum How to use checksums |
3457a2cb579f6bcafd77309703f32bee0c199c0f672dac8607f8631868e63c49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|