AI Detector Pro — Public API

Detect AI-generated text via a simple REST API

Authentication

If the space owner has set an API_KEY environment variable, include it with every request:

MethodExample
HeaderX-API-Key: your-key-here
Query param?api_key=your-key-here
If no API_KEY is configured, all requests are accepted without authentication.

Base URL

When running on HuggingFace Spaces:

https://<owner>-<space-name>.hf.space

Locally:

http://localhost:7860

Endpoints

POST/api/v1/detect

Analyze a text string for AI-generated content.

Request body (JSON)

FieldTypeDescription
textstringrequiredThe text to analyze (min 10 chars)

Example request

curl -X POST https://<space-url>/api/v1/detect \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-key" \
  -d '{"text": "Paste the text you want to analyze here."}'

Example response

{
  "status": "success",
  "ai_score": 0.87,
  "ai_score_percent": "87.0%",
  "confidence": "high",
  "verdict": "AI-generated",
  "detector_results": {
    "tmr_detector": { "score": 0.91, "confidence": "very_high", ... },
    "pattern":      { "score": 0.12, "confidence": "low", ... }
  },
  "text_stats": { "word_count": 120, "char_count": 680, ... }
}

POST/api/v1/detect/file

Upload a file (PDF, DOCX, or TXT) and analyze its content.

Request — multipart/form-data

FieldTypeDescription
filefilerequiredPDF, DOCX, or TXT (max 50 MB)

Example request

curl -X POST https://<space-url>/api/v1/detect/file \
  -H "X-API-Key: your-key" \
  -F "file=@essay.pdf"

Response

Same shape as /api/v1/detect plus a filename field.

GET/api/v1/status

Returns the current detector configuration and API status. No auth required.

Example response

{
  "status": "ok",
  "timestamp": "2025-01-01T00:00:00Z",
  "api_version": "1.0",
  "auth_required": false,
  "enabled_detectors": ["tmr_detector", "pattern"],
  "aggregation_method": "weighted_average"
}

Response codes

CodeMeaning
200Success
400Bad request (missing/invalid input)
401Missing API key
403Invalid API key
500Internal server error