Spaces:
No application file
No application file
metadata
title: Text Prediction API
emoji: π
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
license: mit
app_port: 7860
Text Prediction API
AI-powered text prediction service built with FastAPI.
Features
- π Secure Authentication - JWT Bearer token verification
- π Fast Performance - Built on FastAPI with async support
- π Health Monitoring - Built-in health check endpoint
- π³ Docker Ready - Optimized for Hugging Face Spaces deployment
API Endpoints
Health Check
GET /health
Returns the service health status.
Prediction
POST /predict
Authorization: Bearer <token>
Content-Type: application/json
{
"text": "Your input text here"
}
Response:
{
"prediction": "Processed: Your input text here",
"confidence": 0.95,
"input_text": "Your input text here"
}
Environment Variables
| Variable | Description | Required |
|---|---|---|
JWT_SECRET |
Secret key for JWT token verification | Yes |
ALLOWED_ORIGINS |
Comma-separated list of allowed CORS origins | No |
Local Development
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export JWT_SECRET=your_secret_key
# Run the server
uvicorn main:app --reload --port 8001
Deployment
This service is designed to run on Hugging Face Spaces with Docker SDK.
- Create a new Space with Docker SDK
- Set the
JWT_SECRETsecret in Space settings - Push this code to the Space repository