llm-ai-agent / README.md
Yadav122's picture
Upload README.md with huggingface_hub
6f25760 verified
metadata
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:

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

{
  "message": "Your input message",
  "max_length": 200,
  "temperature": 0.7,
  "system_prompt": "Optional system prompt"
}

Response:

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