Crates.io | litellm-rs |
lib.rs | litellm-rs |
version | 0.1.1 |
created_at | 2025-07-28 10:04:27.436908+00 |
updated_at | 2025-07-28 10:12:31.617393+00 |
description | A high-performance AI Gateway written in Rust, providing OpenAI-compatible APIs with intelligent routing, load balancing, and enterprise features |
homepage | https://github.com/majiayu000/litellm-rs |
repository | https://github.com/majiayu000/litellm-rs |
max_upload_size | |
id | 1770953 |
size | 1,806,607 |
A blazingly fast AI Gateway written in Rust, providing OpenAI-compatible APIs with intelligent routing, load balancing, caching, and enterprise-grade features.
๐ฏ Inspired by LiteLLM - This project is a high-performance Rust implementation of the popular Python LiteLLM library, designed for production environments requiring maximum throughput and minimal latency.
This Rust implementation brings the power and flexibility of LiteLLM to high-performance production environments. While maintaining full compatibility with the original LiteLLM API, this version leverages Rust's memory safety, zero-cost abstractions, and async capabilities to deliver:
This Rust implementation maintains 100% API compatibility with the original LiteLLM:
Migration is simple: Just replace your Python LiteLLM deployment with this Rust version and enjoy the performance benefits!
Get started in under 2 minutes with minimal configuration!
๐ View Simple Configuration Guide โ ๐
Need detailed installation steps? Check out the Complete Setup Guide โ
Option 1: Using Cargo (Recommended)
cargo install litellm-rs
Option 2: From Source
git clone https://github.com/majiayu000/litellm-rs.git
cd litellm-rs
cargo build --release
Option 3: Docker (Easiest)
docker pull majiayu000/litellm-rs:latest
# Edit configuration file and add your API keys
nano config/gateway.yaml
# Start with cargo (automatically loads config/gateway.yaml)
cargo run
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Need more help? Check out the Quick Start Guide โ
๐ Complete Documentation Index โ - View detailed categorization and navigation of all documentation
Document | Description | Best For |
---|---|---|
๐ฏ Simple Config โญ | 2-step startup with minimal configuration | Users who want immediate experience |
๐ฆ Complete Setup Guide | Detailed installation steps and environment setup | Users who need full installation guidance |
โก Quick Start Guide | Comprehensive quick start tutorial | Users who need systematic learning |
Document | Description |
---|---|
๐ Documentation Overview | Detailed index of all documentation |
โ๏ธ Configuration Guide | Complete configuration reference |
๐๏ธ Architecture Overview | System design and component explanation |
๐ API Reference | Complete API documentation |
๐ Google API Guide | Google API specific configuration |
Document | Description |
---|---|
๐ Deployment Guide | Production deployment strategies |
๐ณ Docker Deployment | Containerized deployment guide |
๐ Deployment Scripts | Automated deployment scripts |
Document | Description |
---|---|
๐งช Usage Examples | Practical usage examples and code |
๐งช API Testing | API test cases |
๐งช Google API Testing | Google API specific tests |
Document | Description |
---|---|
๐ค Contributing Guide | How to contribute to the project |
๐ Changelog | Version history and change records |
graph TB
Client[Client Applications] --> Gateway[Rust LiteLLM Gateway]
Gateway --> Auth[Authentication Layer]
Gateway --> Router[Intelligent Router]
Gateway --> Cache[Multi-tier Cache]
Router --> OpenAI[OpenAI]
Router --> Anthropic[Anthropic]
Router --> Azure[Azure OpenAI]
Router --> Google[Google AI]
Router --> Cohere[Cohere]
Gateway --> DB[(PostgreSQL)]
Gateway --> Redis[(Redis)]
Gateway --> Monitoring[Monitoring & Metrics]
Metric | Python LiteLLM | Rust LiteLLM Gateway | Improvement |
---|---|---|---|
Requests/sec | ~1,000 | 10,000+ | 10x faster |
Latency (p95) | ~50ms | <5ms | 10x lower |
Memory Usage | ~200MB | <50MB | 4x less |
CPU Usage | ~80% | <20% | 4x more efficient |
Cold Start | ~2s | <100ms | 20x faster |
server:
host: "0.0.0.0"
port: 8000
workers: 4
providers:
- name: "openai"
provider_type: "openai"
api_key: "${OPENAI_API_KEY}"
models: ["gpt-4", "gpt-3.5-turbo"]
- name: "anthropic"
provider_type: "anthropic"
api_key: "${ANTHROPIC_API_KEY}"
models: ["claude-3-opus", "claude-3-sonnet"]
router:
strategy: "least_latency"
health_check_interval: 30
retry_attempts: 3
auth:
jwt_secret: "${JWT_SECRET}"
api_key_header: "Authorization"
enable_rbac: true
storage:
database:
url: "${DATABASE_URL}"
max_connections: 10
redis:
url: "${REDIS_URL}"
max_connections: 10
See Configuration Guide for complete options.
# Quick start with Docker
cd deployment/docker
docker-compose up -d
# Deploy to Kubernetes
kubectl apply -f deployment/kubernetes/
See deployment/ directory for detailed deployment guides.
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing"}
],
"temperature": 0.7,
"max_tokens": 150
}'
curl -X POST http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-api-key" \
-d '{
"model": "gpt-4.1",
"messages": [{"role": "user", "content": "Tell me a story"}],
"stream": true
}'
More examples in the examples directory.
litellm-rs/
โโโ ๐ README.md # Project homepage - single documentation entry point โญ
โโโ ๐ src/ # Rust source code
โ โโโ ๐ auth/ # Authentication & authorization
โ โโโ ๐ config/ # Configuration management
โ โโโ ๐ core/ # Core business logic
โ โโโ ๐ monitoring/ # Monitoring & observability
โ โโโ ๐ server/ # HTTP server & routes
โ โโโ ๐ storage/ # Data persistence layer
โ โโโ ๐ utils/ # Utility functions
โ โโโ ๐ lib.rs # Library entry point
โ โโโ ๐ main.rs # Application entry point
โโโ ๐ docs/ # ๐ All documentation lives here
โ โโโ ๐ README.md # Documentation overview & index
โ โโโ ๐ simple_config.md # ๐ฏ Simple configuration guide (2-step startup)
โ โโโ ๐ setup.md # ๐ฆ Complete setup guide
โ โโโ ๐ quickstart.md # โก Quick start guide
โ โโโ ๐ configuration.md # โ๏ธ Configuration reference
โ โโโ ๐ architecture.md # ๐๏ธ System architecture
โ โโโ ๐ api.md # ๐ API reference
โ โโโ ๐ google_api_quickstart.md # ๐ Google API guide
โ โโโ ๐ contributing.md # ๐ค Contributing guide
โ โโโ ๐ changelog.md # ๐ Changelog
โ โโโ ๐ documentation_index.md # ๐ Complete documentation index
โโโ ๐ config/ # Configuration files
โ โโโ ๐ gateway.yaml # Main configuration file (auto-loaded)
โ โโโ ๐ gateway.yaml.example # Configuration file example
โโโ ๐ examples/ # Usage examples
โ โโโ ๐ basic_usage.md # Basic usage examples
โ โโโ ๐ google_api_config.yaml # Google API configuration example
โโโ ๐ deployment/ # Deployment configurations
โ โโโ ๐ README.md # Deployment guide
โ โโโ ๐ docker/ # Docker deployment
โ โโโ ๐ kubernetes/ # Kubernetes manifests
โ โโโ ๐ scripts/ # Deployment scripts
โ โโโ ๐ systemd/ # System service configuration
โโโ ๐ tests/ # Test files
โ โโโ ๐ api_test_examples.md # API test examples
โ โโโ ๐ google_api_tests.md # Google API tests
โ โโโ ๐ integration_tests.rs # Integration tests
โ โโโ ๐ *.postman_collection.json # Postman test collections
โโโ ๐ Cargo.toml # Rust package manifest
โโโ ๐ LICENSE # MIT license
โโโ ๐ LICENSE-LITELLM # Original LiteLLM license
โโโ ๐ Makefile # Development commands
โโโ ๐ build.rs # Build script
โโโ ๐ setup-dev.sh # Development environment setup
โโโ ๐ start.sh # Quick start script
๐ README.md
โญ: Single documentation entry point - Start all documentation navigation from here๐ docs/
โญ: All documentation lives here - Including configuration, API, architecture, and all other docs๐ src/
: All Rust source code, organized by functionality๐ config/
: YAML configuration files, auto-loads gateway.yaml๐ examples/
: Practical usage examples and tutorials๐ deployment/
: Deployment configurations for various platforms๐ tests/
: Test files and Postman collectionsREADME.md
โญ: Project homepage and documentation navigation entrydocs/simple_config.md
โญ: 2-step quick start guidedocs/documentation_index.md
โญ: Complete documentation categorization indexconfig/gateway.yaml
: Main configuration file (auto-loaded)deployment/scripts/quick-start.sh
: One-click startup scriptREADME.md
We welcome contributions from the community! This project aims to be a high-quality, production-ready alternative to the Python LiteLLM.
git clone https://github.com/majiayu000/litellm-rs.git
cd litellm-rs
cargo build
# Start PostgreSQL and Redis
docker-compose -f docker-compose.dev.yml up -d
# Run migrations
cargo run --bin migrate
# Start development server
cargo run
cargo test
This project is licensed under the MIT License - see the LICENSE file for details.
This project is inspired by and maintains compatibility with LiteLLM, which is also licensed under the MIT License. The original LiteLLM license is included in LICENSE-LITELLM as required by the MIT License terms.
This project stands on the shoulders of giants and wouldn't be possible without:
๐ Built with โค๏ธ in Rust | Inspired by LiteLLM
Making AI accessible, one request at a time โก