simply52/ai-text-detector-api-20250818-070606
0
AI Text Detector API
A high-performance Docker-based API that detects whether text was written by AI or humans using a fine-tuned RoBERTa model.
Features
- FastAPI Backend: High-performance async API
- Interactive Web Interface: Built-in HTML interface for testing
- Swagger Documentation: Automatic API docs at
/docs - Docker Deployment: Containerized for reliability and scalability
- CORS Enabled: Ready for frontend integration
Model
This API uses the simply52/roberta-ai-text-detector-20250818-070606 model, a fine-tuned RoBERTa classifier.
API Endpoints
Web Interface
GET /- Interactive web interface for testing
API Endpoints
POST /predict- Analyze text for AI detectionGET /health- Health check endpointGET /docs- Swagger API documentationGET /redoc- Alternative API documentation
Usage Examples
Python
import requests
# Analyze text
response = requests.post(
"https://huggingface.co/spaces/simply52/ai-text-detector-api-20250818-070606/predict",
json={"text": "Your text here"}
)
result = response.json()
print(f"Prediction: {result['prediction']}")
print(f"Confidence: {result['confidence']:.1%}")cURL
curl -X POST "https://huggingface.co/spaces/simply52/ai-text-detector-api-20250818-070606/predict" \
-H "Content-Type: application/json" \
-d '{"text": "Your text here"}'JavaScript/Fetch
const response = await fetch('/predict', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'text': 'Your text here'})
});
const result = await response.json();
console.log(result);Response Format
{
"prediction": "🤖 AI-Generated",
"human_probability": 0.23,
"ai_probability": 0.77,
"confidence": 0.77,
"label": "ai"
}Docker Deployment
This Space runs on Docker for maximum reliability and performance. The container includes:
- FastAPI application server
- RoBERTa model and tokenizer
- All required dependencies
- Health monitoring endpoints
Local Development
# Clone the space
git clone https://huggingface.co/spaces/simply52/ai-text-detector-api-20250818-070606
cd ai-text-detector-api-20250818-070606
# Build and run with Docker
docker build -t ai-text-detector .
docker run -p 7860:7860 ai-text-detector
# Or run directly with Python
pip install -r requirements.txt
python app.py