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 Combos (ordered fallback chains,
X-Rook-Combo). - π·οΈ Model aliasing: Normalize variant names (
gpt-4-turboβ dated canonical) with 30+ built-ins plus custom aliases. - π Streaming: OpenAI-compatible SSE streaming, including tool-call deltas.
- π 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.89 toolchain (pinned in
rust-toolchain.toml; MSRV 1.81 perCargo.toml) - Cargo (included with Rust)
- (Optional) Just task runner:
cargo install just - (Optional for dashboard) Node.js and pnpm (
pnpm@11pinned in rootpackage.json)
git clone https://github.com/dallay/cortex.git
cd cortex
cargo build --release -p rookRook GA supports installing directly from its immutable product tag. Publishing the internal crates to crates.io is a later distribution phase and is not a first-release requirement:
cargo install \
--git https://github.com/dallay/cortex.git \
--tag rook@vX.Y.Z \
--locked \
-p rookDownload pre-built binaries from Releases for:
- Linux (x86_64)
- macOS (Intel, Apple Silicon)
- Windows (x86_64)
Rook and Huginn are separate products with separate versions and release tags. See the release and distribution contract before relying on a registry or container channel. Huginn's public distribution remains blocked until its acceptance gates are complete.
-
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 [routing] strategy = "priority" [database] db_path = "~/.local/share/cortex/rook/rook.db"
Providers are not configured in TOML. Create them at runtime via the Provider CRUD API (
POST /api/providers). See the Configuration Guide. -
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!"}] }'
This requires a completion provider configured for Rook; see the Configuration Guide before sending requests.
Define ordered provider/model fallback steps as [[combos]] in rook.toml or
through the /api/combos CRUD API. Select one per request with
X-Rook-Combo, or set routing.default_combo. See the
Configuration Guide
for the schema and execution behavior.
Rook serves an embedded dashboard at /dashboard/ on the same port
(e.g. http://localhost:3773/dashboard/). For frontend development use
just run-dashboard (Vite at http://localhost:4747/dashboard/, proxied to the backend).
On a fresh database Rook enters bootstrap mode β check the logs for the
setup token. See dashboard README.
See the Configuration Guide for detailed options.
Quick reference:
- Server: host, port, health check interval.
- Routing: strategy (
priority|round-robin|model-based), optionaldefault_combo. - Providers: managed through
/api/providers; see the Provider Management guide. - Combos: managed via
/api/combos, selected withX-Rook-Comboorrouting.default_combo. - Model aliases: CRUD at
/api/models/aliases; global aliases resolve before routing (provider-scoped records are not applied during resolution). - Cache / DB / auth / rate limiting: see full schema in the guide.
Cortex follows Clean Architecture principles with clear separation of concerns:
cortex/
βββ apps/rook/ # Binary entry point, DI bootstrap + embedded dashboard
βββ apps/huginn/ # Personal Rust coding agent (CLI)
βββ crates/
β βββ domain/ # Business logic
β β βββ shared-kernel/ # Zero-deps common types
β β βββ rook-core/ # Domain models, ports, Combo entities
β βββ application/
β β βββ rook-usecases/ # Orchestration (RouteRequest, FallbackRouter, CRUD)
β βββ infrastructure/ # External adapters
β β βββ providers-*/ # LLM clients: openai, anthropic, ollama, gemini, groq (+ core)
β β βββ provider-sqlite/# Persisted provider connections
β β βββ combo-sqlite/ # Combo persistence
β β βββ alias-sqlite/ # Model aliases
β β βββ auth-sqlite/ # API keys + auth
β β βββ cache-memory/ # TTL in-memory cache
β β βββ audit-sqlite/ # Audit logging
β β βββ db-migration/ # SQLite migrations
β β βββ models-catalog/ # Model metadata
β β βββ sse-stream/ # Streaming (SSE)
β β βββ observability/ # Tracing + metrics
β β βββ encryption-inmemory/ # Credential encryption boundary
β β βββ transport-axum/ # HTTP server + OpenAI-compatible adapters
β βββ huginn/ # Huginn core, runtime + Ratatui presentation (no Rook dependency)
β βββ test-support/ # Shared test fixtures
βββ docs/ # Documentation
See Architecture Documentation for details.
| Tool | Status | Description |
|---|---|---|
| Rook | β Active | AI proxy/router with multi-provider support |
| Huginn | π§ Personal MVP in progress | Local Rust coding agent: CLI + Ratatui TUI, streaming, native tools, SQLite sessions, MCP stdio |
| 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- Architecture
- Configuration (providers via CRUD API, combos, aliases)
- Providers
- API Reference
- Deployment
- Release and distribution contract
- ADR-0015: Product releases versus Cargo publishing
- API key troubleshooting
- Rook dashboard (Vue SPA, embedded at
/dashboard/) - Local Docker testing (smoke, Playwright E2E, multi-distro)
- Huginn coding agent
Project priorities evolve with active development. See the GitHub issue tracker for current work and planned features rather than relying on a static roadmap in this README.
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.