A production-ready proxy service that bridges OpenAI API compatibility with VLLM (vLLM) servers running large language models, specifically designed to support tool calling and function invocation workflows.
This proxy solves compatibility issues between OpenAI-format API requests (used by n8n workflows and other applications) and VLLM's native response format, enabling seamless integration of large language models in production environments.
- Tool Calling Compatibility: Converts OpenAI tool calling format to VLLM's expected format
- Multi-turn Conversations: Maintains conversation context across multiple requests
- Streaming Support: Provides real-time Server-Sent Events for responsive applications
- Production Reliability: Includes rate limiting, authentication, monitoring, and error handling
- β
Full OpenAI API v1 Compatibility -
/v1/chat/completions,/v1/models,/v1/completions - β Tool Calling Support - Function calling with proper format conversion
- β Multi-turn Dialogs - Conversation state management with Redis
- β Streaming Responses - Server-Sent Events (SSE) support
- β Request/Response Logging - Comprehensive activity tracking
- π‘οΈ Authentication - API key validation middleware
- β‘ Rate Limiting - Configurable request throttling
- π Monitoring - Prometheus metrics and Grafana dashboards
- π Health Checks - Kubernetes/Docker ready endpoints
- π§ Error Handling - Graceful degradation and retry logic
- πΎ State Management - Redis-backed conversation persistence
graph TB
subgraph "Client Applications"
A[n8n Workflows]
B[OpenAI-compatible Apps]
end
subgraph "Proxy Service"
C[FastAPI Router]
D[Format Converter]
E[State Manager]
F[Redis Cache]
end
subgraph "VLLM Backend"
G[VLLM Server]
H[LLM Model]
end
A --> C
B --> C
C --> D
D --> E
E --> F
D --> G
G --> H
- Python 3.11+
- Redis (for conversation state)
- Docker & Docker Compose (recommended deployment)
- VLLM Server running with OpenAI-compatible endpoints
git clone https://github.com/miolamio/oss-vllm-proxy.git
cd oss-vllm-proxy
# Copy environment template
cp .env.example .envEdit .env file with your settings:
# VLLM Configuration
VLLM_BASE_URL=http://your-vllm-server:8000
VLLM_API_KEY=your-vllm-api-key
# Security
PROXY_API_KEY=your-secure-proxy-key
# Redis
REDIS_URL=redis://localhost:6379docker-compose -f docker/docker-compose.yml up -dcurl -X POST http://localhost:5000/v1/chat/completions \
-H "Authorization: Bearer your-proxy-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Hello!"}],
"max_tokens": 100
}'# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
pip install -r requirements-dev.txt
# Run development server
make dev# Unit tests
pytest tests/
# Integration tests
pytest tests/integration/
# With coverage
make test-coverageAccess monitoring dashboards:
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000 (admin/password from .env)
- Proxy Health: http://localhost:5000/health/live
| Variable | Description | Default |
|---|---|---|
VLLM_BASE_URL |
VLLM server URL | http://localhost:8000 |
VLLM_API_KEY |
VLLM API key | None |
PROXY_API_KEY |
Proxy authentication key | None |
REDIS_URL |
Redis connection string | redis://localhost:6379 |
LOG_LEVEL |
Logging level | INFO |
ENABLE_METRICS |
Enable Prometheus metrics | true |
RATE_LIMIT_REQUESTS |
Rate limit per window | 1000 |
RATE_LIMIT_WINDOW |
Rate limit window (seconds) | 60 |
See src/utils/config.py for all configuration options.
Input (OpenAI format):
{
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather info",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"}
}
}
}
}]
}Output (VLLM format):
{
"tools": [{
"type": "function",
"name": "get_weather",
"description": "Get weather info",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"}
}
}
}]
}# Production deployment
docker-compose -f docker/docker-compose.yml up -d
# Check logs
docker-compose logs -f proxyKubernetes manifests available in k8s/ directory:
kubectl apply -f k8s/python scripts/test_tool_calls.pypython scripts/benchmark.pyThis proxy is optimized for n8n workflows:
- Add HTTP Request Node
- Set URL:
http://your-proxy-url:5000/v1/chat/completions - Add Authorization Header:
Bearer your-proxy-api-key - Configure Tool Functions in request body
See docs/n8n-integration.md for detailed setup.
- Tool calls not working: Check VLLM model supports function calling
- Connection refused: Verify VLLM server is running and accessible
- Authentication errors: Confirm API keys are correctly set
# Enable debug logging
export LOG_LEVEL=DEBUG
docker-compose up# Check proxy health
curl http://localhost:5000/health/live
# Check VLLM connection
curl http://localhost:5000/health/vllm- Latency Overhead: <50ms
- Concurrent Requests: 100+ supported
- Memory Usage: <512MB typical
- Throughput: Depends on VLLM backend performance
- β API key authentication
- β Rate limiting protection
- β Input validation and sanitization
- β No credential exposure in logs
- β Secure defaults configuration
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
- Follow PEP 8 style guide
- Add tests for new features
- Update documentation
- Ensure all tests pass
This project is licensed under the MIT License - see LICENSE file for details.
- VLLM Team for the excellent inference server
- FastAPI for the web framework
- n8n Community for workflow automation inspiration
- GitHub Issues: Create an issue
- Documentation: Check the
docs/directory - Community: Join discussions in GitHub Discussions
Made with β€οΈ for the open source AI community