Overview
Rig is a Rust library for building scalable, modular, and ergonomic LLM-powered applications. It gives you a single unified interface over more than 20 model providers and more than 10 vector store integrations, so provider choice becomes a configuration detail rather than something threaded through your application code. Alongside completion and embedding workflows it also covers transcription, audio generation, and image generation model capabilities.
The crate separates portable contracts from orchestration. rig-core holds provider-neutral messages, completion models, portable tools, and the memory and vector-store contracts along with built-in provider mappings; rig-agent holds the classic agent builder, prompt and streaming traits, typed hooks, contextual tools, extraction, and the serializable AgentRun state machine. The root rig facade re-exports both at their familiar paths, so most code only ever depends on rig. Integrations are opt-in behind one Cargo feature each — bedrock, lancedb, milvus, mongodb, fastembed, vertexai and more — which keeps builds lean.
Rig targets agentic workflows with multi-turn streaming and prompting, is fully compatible with the OpenTelemetry GenAI semantic conventions for tracing, and supports browser WASM (wasm32-unknown-unknown) for the portable core and the classic runtime. It is used in production by projects including St. Jude's proteinpaint genomics tool, Coral Protocol's Rust SDK, Nethermind, Neon's app.build V2, and the ilert incident-management platform. The README carries an explicit warning that the project ships breaking changes as it evolves, so pin your version.
What it does
- One unified interface over 20+ model providers and 10+ vector store integrations
- Agentic workflows with multi-turn streaming and prompting, on a classic agent runtime enabled by default
- Full support for completion and embedding workflows, plus transcription, audio generation, and image generation
- OpenTelemetry GenAI semantic convention compatibility for tracing
- Feature-gated companion crates (bedrock, lancedb, milvus, mongodb, fastembed, vertexai, candle, memory, and more) so you compile only what you use
- Browser WASM (wasm32-unknown-unknown) support for the portable core and classic runtime
Getting started
Add the crate, set your provider's API key in the environment, then build an agent and prompt it. Use the root rig facade when you want feature-gated access to companion crates, or rig-core directly when you only need the core provider abstractions.
Add Rig to your project
The async example below uses Tokio's macros, so enable those features too.
cargo add rig
# or: cargo add rig-core
cargo add tokio --features macros,rt-multi-threadBuild an agent and prompt it
Create a provider client from the environment, give the agent a preamble, and await a prompt.
use rig::prelude::*;
use rig::providers::openai;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// Create OpenAI client
let client = openai::Client::from_env()?;
// Create agent with a single context prompt
let comedian_agent = client
.agent(openai::GPT_5_2)
.preamble("You are a comedian here to entertain the user using humour and jokes.")
.build();
// Prompt the agent and print the response
let response = comedian_agent.prompt("Entertain me!").await?;
println!("{response}");
Ok(())
}Enable the integrations you need
Each companion crate sits behind its own Cargo feature on the rig facade, and is then reachable at rig::<module>.
rig = { version = "0.36.0", features = ["lancedb", "fastembed"] }Explore further
Each crate has its own examples directory, and provider-specific integration coverage lives under tests/providers with cassette-backed tests that replay offline by default. Full guides are published at rig.rs/docs and the API reference at docs.rs/rig.
Commands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Build an LLM application in Rust when you need native performance or want to stay in an existing Rust service
- Swap between model providers, or run several side by side, behind one interface instead of per-vendor SDK code
- Add retrieval to a Rust app using a vector store integration such as LanceDB, Milvus, or MongoDB
- Instrument agent runs with OpenTelemetry GenAI traces for production observability
How Rig compares
Rig alongside other open-source app frameworks tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| LangChain | ★ 146k | A widely used Python and JavaScript framework for building LLM applications by composing models, prompts, tools, retrievers, and memory into chains. |
| LlamaIndex | ★ 52k | A data framework for connecting language models to your own documents and data sources, with built-in agent and retrieval (RAG) tooling. |
| Haystack | ★ 26.4k | An orchestration framework from deepset for building modular LLM pipelines and agents for search, RAG, and question answering. |
| Jina | ★ 21.9k | Jina-serve is a Python framework for building, scaling, and deploying AI services and multi-step pipelines that communicate over gRPC, HTTP, and WebSockets. |
| LLM | ★ 12.5k | Simon Willison's plugin-extensible CLI and Python library for prompting remote and local models, logging every prompt and response to SQLite, and generating embeddings. |
| Prompt Flow | ★ 11.2k | Microsoft's toolkit for building LLM apps as executable flows that link prompts, Python code, and tools, with tracing, batch evaluation, and deployment. |
| Rig | ★ 8.5k | Build modular, scalable LLM applications in Rust |