OpenAI-Compatible API for Local LLMs
LocalAI+ is a comprehensive platform that wraps local LLMs with missing capabilities found in cloud APIs. It provides an OpenAI-compatible interface with advanced features like function calling, embeddings, code interpretation, and a plugin system.
- ๐ OpenAI-Compatible API - Drop-in replacement for OpenAI's API
- ๐ ๏ธ Function Calling - Structured tool use with JSON schemas
- ๐ Embeddings & RAG - Vector search with Qdrant integration
- ๐ Code Interpreter - Secure Python execution sandbox
- ๐ Plugin System - Extensible architecture for custom tools
- ๐ Enterprise Security - API keys, rate limiting, input sanitization
- ๐ Comprehensive Logging - Structured logging with metrics
- ๐ฏ Developer Experience - Interactive playground, full documentation
- ๐ฅ๏ธ Web Interface - Modern React frontend with dashboard and management tools
- Docker and Docker Compose
- Ollama installed and running
- A local model (e.g.,
ollama pull mistral:latest)
-
Clone the repository
git clone https://github.com/Eamateli/LocalAI-Plus/tree/main cd localai-plus -
Start with Docker Compose
docker-compose up -d
-
Test the API
curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Authorization: Bearer test-key-12345" \ -H "Content-Type: application/json" \ -d '{ "model": "mistral:latest", "messages": [ {"role": "user", "content": "Hello!"} ] }'
-
Access the Web Interface
- Frontend Application: http://localhost:3000
- API Documentation: http://localhost:8000/docs
- Interactive API Playground: http://localhost:3000/playground
- Real-time system metrics (CPU, memory, disk usage)
- API request statistics and activity monitoring
- Service health status and uptime tracking
- Recent activity feed with detailed logs
- View and manage installed models
- Start/stop models with one click
- Download new models from Ollama registry
- Monitor model status and resource usage
- Model performance metrics
- Install and manage plugins
- Enable/disable plugins dynamically
- Browse available plugins from registry
- Create custom plugins with built-in editor
- Plugin function testing and debugging
- Interactive testing of all API endpoints
- Real-time request/response visualization
- Syntax highlighting for JSON
- Copy requests as cURL commands
- Support for all LocalAI+ features (chat, embeddings, tools, code execution)
- Complete API reference with examples
- Step-by-step setup guides
- Plugin development tutorials
- Configuration options reference
POST /v1/chat/completionsOpenAI-compatible chat completions with support for:
- Multi-turn conversations
- Function calling with tools
- Streaming responses
- Temperature and token control
POST /v1/embeddingsGenerate vector embeddings for text input:
{
"input": ["Hello world", "LocalAI+ is awesome"],
"model": "nomic-embed-text"
}Enable your models to use tools:
{
"model": "mistral:latest",
"messages": [{"role": "user", "content": "What's 2+2 and the weather in NYC?"}],
"tools": [
{
"type": "function",
"function": {
"name": "calculator",
"description": "Perform calculations",
"parameters": {
"type": "object",
"properties": {
"expression": {"type": "string"}
}
}
}
}
]
}POST /v1/code/executeExecute Python code securely:
{
"code": "print('Hello from Python!')\nresult = 2 + 2\nprint(f'2 + 2 = {result}')",
"language": "python"
}Configure LocalAI+ using environment variables:
# Ollama Configuration
OLLAMA_BASE_URL=http://localhost:11434
DEFAULT_MODEL=mistral:latest
# Security
API_KEYS=your-api-key-1,your-api-key-2
SECRET_KEY=your-secret-key
# Vector Store
QDRANT_HOST=localhost
QDRANT_PORT=6333
# Code Interpreter
ENABLE_CODE_EXECUTION=true
CODE_TIMEOUT=30
CODE_MEMORY_LIMIT=128
# Database
DATABASE_URL=sqlite:///./localai.dbCreate custom tools by developing plugins:
# plugins/weather_plugin.py
PLUGIN_INFO = {
"name": "weather",
"version": "1.0.0",
"description": "Get weather information",
"functions": [
{
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"}
},
"required": ["location"]
}
}
]
}
async def get_weather(arguments):
location = arguments.get("location")
# Your weather API integration here
return {"location": location, "temperature": "22ยฐC"}- API Key Authentication - Secure your endpoints
- Code Sandboxing - Isolated Python execution
- Input Sanitization - Prevent injection attacks
- Resource Limits - CPU, memory, and timeout controls
- Rate Limiting - Prevent abuse
- Comprehensive Logging - Track all operations
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Frontend โ โ LocalAI+ โ โ Ollama โ
โ (React) โโโโโบโ (FastAPI) โโโโโบโ (LLM Host) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ Qdrant โ
โ (Vector Store) โ
โโโโโโโโโโโโโโโโโโโ
cd backend
pip install -r requirements.txt
python -m uvicorn main:app --reloadnpm install
npm run devcd backend
pytestLocalAI+ includes comprehensive monitoring:
- Health Checks -
/healthendpoint - Metrics - Prometheus-compatible metrics
- Structured Logging - JSON logs with correlation IDs
- Usage Tracking - API usage statistics
- Real-time Dashboard - Web-based monitoring interface
LocalAI+ comes with several built-in tools:
- Calculator - Mathematical expressions and calculations
- Weather - Weather information (mock implementation)
- Web Search - Search functionality (mock implementation)
- Code Interpreter - Secure Python code execution
- React 18 - Modern React with hooks
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first styling
- Framer Motion - Smooth animations
- React Router - Client-side routing
- React Hot Toast - Beautiful notifications
- Syntax Highlighter - Code highlighting
- Lucide React - Beautiful icons
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
LocalAI+ is open source software licensed under the MIT License.
- Ollama - Local LLM runtime
- Qdrant - Vector database
- FastAPI - Modern Python web framework
- React - Frontend framework
- OpenAI - API design inspiration
- ๐ Documentation
- ๐ Issues
- ๐ฌ Discussions
- ๐ Discord Community
Made with โค๏ธ for the AI community