Getting Started β’ Documentation β’ Contributing β’ Community
- About
- Features
- Getting Started
- Usage
- Configuration
- Architecture
- Tools
- Development
- Documentation
- Roadmap
- Contributing
- License
- Community
- Acknowledgments
Cortex is a high-performance AI infrastructure project written in Rust. Its primary component, Rook, acts as an intelligent AI proxy and router designed to simplify and harden your AI application stack.
In an ecosystem with multiple LLM providers (OpenAI, Anthropic, Google, etc.), Cortex provides a unified, OpenAI-compatible interface with enterprise-grade features out of the box. It solves common challenges such as provider outages, high latency, and lack of observability by providing automatic failover, efficient caching, and comprehensive audit logging.
- π OpenAI-compatible API: Drop-in replacement for existing OpenAI clients.
- β¨ Multi-provider routing: Support for OpenAI, Anthropic, Ollama, Gemini, and Groq.
- π Automatic fallback: Resilience against provider failures with configurable fallback chains.
- π Built-in caching: Reduce costs and latency with TTL-based in-memory caching.
- π Audit logging: Full traceability of requests and responses backed by SQLite.
- ποΈ Clean Architecture: Built with Domain-Driven Design (DDD) for high maintainability.
- π¦ Rust-powered: Exceptional performance, memory safety, and concurrency.
- π Production-ready: Includes health checks, observability (tracing, metrics), and encryption.
- Rust 1.81 or later (the version is pinned in
rust-toolchain.toml) - Cargo (included with Rust)
- (Optional) Just task runner:
cargo install just - (Optional for dashboard) Node.js 18+ and pnpm
git clone https://github.com/dallay/cortex.git
cd cortex
cargo build --release -p rookDownload pre-built binaries from Releases for:
- Linux (x86_64, aarch64)
- macOS (Intel, Apple Silicon)
- Windows (x86_64, aarch64)
-
Configure Rook: Create a config file at
./rook.toml(or use theROOK_CONFIGenv var to point elsewhere):[server] host = "127.0.0.1" port = 3773 [providers.openai] api_key = "sk-..." enabled = true
-
Run the server:
# Using cargo ROOK_CONFIG=./rook.toml cargo run --release -p rook # Using binary ./target/release/rook
-
Test the proxy:
curl http://localhost:3773/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-4", "messages": [{"role": "user", "content": "Hello!"}] }'
Configure a fallback chain to ensure your application stays online even if a provider fails:
# In your rook.toml
[[fallback_chains]]
name = "robust-gpt4"
chain = ["openai/gpt-4", "anthropic/claude-3-opus"]Cortex comes with a built-in dashboard for management.
On a fresh database, Rook enters bootstrap mode. Check the logs for a setup token and open the dashboard (if running locally, typically http://localhost:4747 if you run it via just run-dashboard).
See the Configuration Guide for detailed options.
Quick reference:
- Server: host, port, timeouts, encryption settings.
- Providers: API keys, endpoints, health check intervals.
- Cache: TTL, size limits.
- Audit: log location, rotation.
Cortex follows Clean Architecture principles with clear separation of concerns:
cortex/
βββ apps/rook/ # Binary entry point, DI bootstrap
βββ crates/
β βββ domain/ # Business logic
β β βββ shared-kernel/ # Zero-deps common types
β β βββ rook-core/ # Domain models and ports
β βββ application/ # Use cases
β β βββ rook-usecases/ # Orchestration logic
β βββ infrastructure/ # External adapters
β βββ providers-*/ # LLM provider clients
β βββ cache-memory/ # Caching implementation
β βββ audit-sqlite/ # Audit logging
β βββ transport-axum/ # HTTP server
βββ docs/ # Documentation
See Architecture Documentation for details.
| Tool | Status | Description |
|---|---|---|
| Rook | β Active | AI proxy/router with multi-provider support |
| Future tools | π§ Planned | TBD |
# Clone and setup
git clone https://github.com/dallay/cortex.git
cd cortex
just setup# Format code
just fmt
# Run linter
just clippy
# Run tests
just test
# Watch mode (auto-check, test, clippy)
just dev
# Full CI locally
just ci-local# Run all tests
cargo test --workspace
# Run specific crate tests
cargo test -p rook-core
# Run E2E tests (requires Docker)
just test-e2e- π¨ Dynamic provider registry
- π Enhanced authentication and authorization
- π Advanced metrics and observability
- Rate limiting and quota management
- Request/response transformation
- Plugin system
- WebUI dashboard enhancements
- Streaming support optimization
- Additional provider integrations
We welcome contributions! Please see our Contributing Guide for details.
Follow the Rust Code of Conduct.
This project is licensed under the MIT License.
- π¬ GitHub Discussions - Questions and ideas
- π Issue Tracker - Bug reports and feature requests
Built with:
- Rust - Systems programming language
- Tokio - Async runtime
- Axum - Web framework
- Rusqlite - SQLite bindings
Special thanks to all contributors and the Rust community.