--- 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.