Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	File size: 1,984 Bytes
			
			| 6f25760 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | ---
title: LLM AI Agent API
emoji: π€
colorFrom: blue
colorTo: purple
sdk: docker
app_port: 7860
pinned: false
license: mit
---
# LLM AI Agent API
A secure, production-ready AI agent API powered by local LLM deployment on Hugging Face Spaces.
## π Quick Start
1. **Set Environment Variables** in your Space settings:
   - `API_KEY_1`: Your secure API key
   - `API_KEY_2`: Additional API key (optional)
   - `MODEL_NAME`: LLM model to use (default: microsoft/DialoGPT-medium)
2. **Access your API** at: `https://your-username-your-space.hf.space`
3. **Test the API**:
```bash
curl -X POST "https://your-space-url.hf.space/chat" \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello, how are you?"}'
```
## π Documentation
- **API Docs**: `/docs` (Interactive Swagger UI)
- **Health Check**: `/health`
- **Model Info**: `/models` (requires authentication)
## π Security Features
- API key authentication
- Rate limiting (10 requests/minute per key)
- CORS support
- Request logging
## π οΈ Integration
See `client_examples.py` and `client_examples.js` for integration examples in Python and JavaScript.
## π API Reference
### POST /chat
```json
{
  "message": "Your input message",
  "max_length": 200,
  "temperature": 0.7,
  "system_prompt": "Optional system prompt"
}
```
Response:
```json
{
  "response": "AI response",
  "model_used": "microsoft/DialoGPT-medium",
  "timestamp": "2024-01-01T12:00:00",
  "tokens_used": 45,
  "processing_time": 1.23
}
```
## π§ Configuration
Set these environment variables in your Space:
- `API_KEY_1`, `API_KEY_2`: Authentication keys
- `MODEL_NAME`: Hugging Face model ID
- `MAX_LENGTH`: Maximum response length
- `TEMPERATURE`: Response creativity (0.1-2.0)
- `RATE_LIMIT`: Requests per minute per key
## π License
MIT License - see LICENSE file for details.
 | 
