AI Integrity Platform

AI Integrity Platform

API Documentation

API Documentation

Integrate AI governance and integrity monitoring into your applications with our comprehensive API.

Getting Started

The AI Integrity Platform API provides programmatic access to our Guardian Agent anti-hallucination system, integrity monitoring, and governance tools.

Base URL
https://your-domain.replit.app/api

Quick Start Example

import requests

# Initialize session
session = requests.Session()
base_url = "https://your-domain.replit.app/api"

# Login required for session-based authentication
login_response = session.post("https://your-domain.replit.app/login", data={
    "username": "your_username",
    "password": "your_password"
})

# Analyze text for hallucinations
response = session.post(
    f"{base_url}/analyze-hallucination",
    json={
        "ai_response": "Your AI-generated text to analyze",
        "context": "Optional context for analysis",
        "domain": "general"
    }
)

result = response.json()
print(f"Hallucination probability: {result['hallucination_probability']}")

Authentication

All API requests require session-based authentication. You must login to the platform first to establish a session cookie.

Login Process

curl -X POST https://your-domain.replit.app/login \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "username=your_username&password=your_password" \
  -c cookies.txt

Using Session Cookies

curl -X GET https://your-domain.replit.app/api/systems \
  -H "Content-Type: application/json" \
  -b cookies.txt
Session Management

Sessions are maintained server-side. Ensure your HTTP client supports cookies for persistent authentication.

Guardian Agent API

Access our advanced anti-hallucination detection and correction system.

POST /analyze-hallucination

Analyze AI responses for potential hallucinations using our Guardian Agent system.

Request Body

{
  "ai_response": "AI-generated text to analyze for hallucinations",
  "context": "Optional context for analysis",
  "domain": "general"
}

Response

{
  "is_hallucination": false,
  "confidence": 0.85,
  "hallucination_probability": 0.15,
  "processing_time_ms": 245,
  "method_used": "guardian_agent",
  "detections": [
    {
      "type": "factual_fabrication",
      "confidence": 0.75,
      "evidence": "Statistical claim lacks supporting data",
      "suggested_correction": "Revised text with verification"
    }
  ],
  "recommendations": [
    "Verify statistical claims with authoritative sources",
    "Add citations for factual statements"
  ]
}

POST /batch-hallucination-analysis

Analyze multiple conversation exchanges for hallucination patterns.

Request Body

{
  "conversations": [
    {
      "user_message": "User question",
      "ai_response": "AI response to analyze",
      "context": "Optional context"
    },
    {
      "user_message": "Another user question", 
      "ai_response": "Another AI response to analyze",
      "context": "Optional context"
    }
  ],
  "domain": "general"
}

System Management

Manage AI systems, monitor performance, and track activity.

GET /systems

Retrieve all configured AI systems.

Response

{
  "systems": [
    {
      "id": "sys_123",
      "name": "Production GPT-4",
      "type": "openai_gpt",
      "status": "active",
      "created_at": "2025-01-01T10:00:00Z"
    }
  ]
}

POST /systems

Add a new AI system for monitoring.

Request Body

{
  "name": "My AI System",
  "description": "Description of the AI system",
  "system_type": "openai_gpt",
  "api_endpoint": "https://api.openai.com/v1/chat/completions",
  "model_name": "gpt-4",
  "config": {
    "temperature": 0.7,
    "max_tokens": 1000
  }
}

GET /performance-data

Get real-time performance metrics for AI systems.

Request Body

{
  "interaction_id": "unique_interaction_id",
  "ai_model": "gpt-4o",
  "prompt": "User prompt to AI",
  "response": "AI generated response",
  "metadata": {
    "user_id": "user123",
    "session_id": "session456",
    "timestamp": "2025-01-01T12:00:00Z"
  }
}

Response

{
  "compliance_score": 0.92,
  "integrity_violations": [],
  "recommendations": [
    "Monitor for potential bias in financial advice"
  ],
  "audit_record_id": "audit_789"
}

Platform Integration

Connect and manage AI platforms through our unified interface.

GET /platforms

List connected AI platforms

POST /platforms/connect

Connect new AI platform

GET /platforms/{id}/status

Check platform health status

PUT /platforms/{id}/configure

Update platform configuration

Rate Limits

API usage is subject to rate limits based on your subscription tier.

Research Tier

100

requests per hour

Professional

1,000

requests per hour

Enterprise

10,000

requests per hour

Rate Limit Headers

X-RateLimit-Limit: Request limit per time window

X-RateLimit-Remaining: Requests remaining in current window

X-RateLimit-Reset: Time when the rate limit resets

Error Handling

The API uses standard HTTP status codes and provides detailed error information.

Common Status Codes

200 Success
400 Bad Request
401 Unauthorized
429 Rate Limited
500 Server Error

Error Response Format

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "The request is missing required parameters",
    "details": {
      "missing_fields": ["text", "domain"]
    },
    "request_id": "req_123456789"
  }
}

Ready to Get Started?

Access your API keys and start integrating AI governance into your applications.

Get API Keys