Alchemy
A unified LLM API abstraction layer in Rust that supports 8+ providers through a consistent interface.

Heavily inspired by and ported from: pi-mono/packages/ai by @badlogic
Supported Providers
- Anthropic (Claude)
- OpenAI (GPT-4, GPT-3.5)
- Google (Gemini)
- AWS Bedrock
- Mistral
- xAI (Grok)
- Groq
- Cerebras
- OpenRouter
Features
- Streaming-first - All providers use async streams
- Type-safe - Leverages Rust's type system
- Provider-agnostic - Switch providers without code changes
- Tool calling - Function/tool support across providers
- Message transformation - Cross-provider message compatibility
Quick Start
use ;
use StreamExt;
async
Setup
-
Clone the repository
-
Configure API keys
# Edit .env and add your API keys -
Build the project
-
Run tests
-
Run the example
Development
See AGENTS.md for detailed development guidelines, architecture, and quality gates.
Quality Checks
Pre-commit hooks automatically run:
cargo fmt- Code formattingcargo clippy- Linting with complexity checkscargo check- Compilation
Run all quality checks:
Or run individually:
Tools used:
- Clippy - Cognitive complexity warnings (threshold: 20)
- polydup - Duplicate code detection (install:
cargo install polydup-cli)
License
MIT