Rig Rust Framework: How to Build LLM Agents in Rust
Rig is an open-source Rust framework for building LLM applications and agents. It is maintained by Playgrounds and published on crates.io. This guide covers what Rig does as of version 0.45.0, released on October 19, 2026. It covers agents and RAG first, then conversation memory. Rig is pre-1.0 and its API has changed a lot this year, so many tutorials online no longer compile.
What is Rig, in one sentence?
Rig is an MIT-licensed Rust library for building LLM-powered applications and agents, with one interface over 20+ model providers and 10+ vector stores.
The Rig docs use nearly the same words. The README of the GitHub repository warns that releases contain breaking changes until 1.0. The project's homepage reports 9K+ GitHub stars and 3.9M+ downloads. The same repository now also ships rig, a terminal coding agent built on the library. You extend it with Bevy plugins.
How Rig 0.45 differs from older Rig tutorials
Most Rig articles were written for versions before 0.40, and four things have changed since.
| Older Rig (before 0.40) | Rig 0.45 (October 2026) | |
|---|---|---|
| Install | rig-core crate | cargo add rig, a facade over rig-core and rig-agent (rig-core is still published) |
| Models | CompletionModel and EmbeddingModel traits | Model and DynModel types built from provider clients |
| Multi-step workflows | pipeline module | Plain async Rust, no workflow DSL |
| Conversation memory | Pass history yourself | Optional stores via rig-memory, including SQLite and Postgres |
The changelog records the pipeline removal in 0.40.0. The 0.45 API docs no longer list the old model traits. On crates.io, 0.41 shipped on July 28, 2026, and 0.45 on October 19. If an example imports the pipeline module, it was written for an older version.
How do you build an agent with Rig?
The Rig docs define an agent as a model plus a system prompt, which Rig calls a preamble. This is the current example from the README:
use rig::prelude::*;
use rig::providers::openai::{self, OpenAI};
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// The client reads `OPENAI_API_KEY` and builds the models it serves.
let model = OpenAI::from_env()?.completion(openai::GPT_6_1_SOL);
let comedian = AgentBuilder::new(model)
.preamble("You are a comedian here to entertain the user using humour and jokes.")
.build();
let response = comedian.prompt("Entertain me!").await?;
println!("{}", response.output());
Ok(())
}
The README notes that the tokio main macro needs tokio's macros and rt-multi-thread features. Model constants differ between the README and the docs site, so check which ones your installed version exports.
Static context documents go into the agent builder with a context call. Tools attach as typed Rust structs. For dynamic context, which is Rig's RAG, the agent docs show a dynamic_context call that fetches the top matching documents from a vector index on each prompt. Rig agents can also use MCP servers as clients, through the official Rust MCP SDK, per the MCP integration page.
How do RAG and structured extraction work in Rig?
For RAG, a vector store implements two traits, according to the RAG docs. VectorStoreIndex handles search. InsertDocuments handles writes. You embed documents with an embeddings builder and hand the index to the agent. Rig ships an in-memory store and separate crates for MongoDB, LanceDB, Neo4j, Qdrant, SQLite, SurrealDB, Milvus, ScyllaDB, S3 Vectors, HelixDB, Cloudflare Vectorize and Postgres.
The in-memory store keeps nothing between runs. Its docs page says to rebuild it on each run. Use one of the database crates for anything a user expects to survive a restart.
Extraction turns free text into a typed Rust value. The extractor docs describe an extractor as an agent with a fixed preamble and one tool, submit. The model fills that tool's arguments, and Rig deserializes them into your type. You get a struct back, or an error you can handle, which is the main reason to do this in Rust.
Which models can Rig run, and can it run locally?
The rig-core README lists Anthropic, OpenAI, Azure OpenAI, Gemini, Mistral, Cohere, DeepSeek, Groq, xAI, OpenRouter, Together, Perplexity and Ollama among its built-in providers. Separate crates add more, such as AWS Bedrock and Google Vertex.
Yes, it runs locally. The local models page says Rig can run entirely on your own hardware. Its Ollama client defaults to localhost port 11434 with no authentication, and it supports llama.cpp's server. For fully in-process inference, Rig uses the Candle crate for completions and fastembed for embeddings.
Rig also compiles to browser WebAssembly for the core and the agent runtime. The rig-agent README lists the limits: WASI is not supported, and the MCP crate is not available on WebAssembly.
How does Rig handle conversation memory?
You can keep the history yourself, or attach a store. For the first, the memory docs show a chat call that takes a mutable history vector and appends each turn. For the second, since 0.45, you attach a store with the agent builder's memory method and name a conversation. The rig-memory crate provides an in-process store and a directory store. Its README adds SQLite and Postgres session stores behind a memory feature flag.
Pick SQLite or Postgres if conversations must outlive the process. Note that the docs site and the 0.45 crate use different type names for memory, so trust the crate docs for your version.
Read the fine print
The adoption numbers come from Rig's own homepage, including its claim of 30+ teams in production. The logo strip on that page mixes teams with model providers under a label of things that work with Rig, so it does not show who runs Rig in production. The repository points to the community list awesome-rig for projects built on it.
Expect breaking changes. Rig shipped five minor releases between late July and mid-October 2026, and code samples on the official site still pin 0.44. Pin your version in Cargo.toml and read the changelog before you upgrade.
The bottom line
Rig is our default pick for LLM agents in Rust today, because it already covers the common providers and vector stores. MCP tools and local models work as well. Pin the version and start from the current README example. Treat any tutorial older than mid-2026 as out of date.
How do you stop a coding agent from writing outdated Rig code?
Rig's pace creates a memory problem for the agents that write Rig code. A coding agent whose training data predates 0.40 may reach for the pipeline module or the old model traits. You correct it and it fixes the code. The next session, it makes the same mistake. The fix lived only in that session's context. This is separate from your app's conversation memory, which rig-memory handles.
memU keeps that kind of lesson. It is a shared memory for coding agents, including Claude Code and Codex. A background task slices new session logs into jobs, and the agent itself distills them into memory and skill files in readable Markdown. memU makes no LLM calls of its own. It stores and embeds what the agent wrote, then returns it on request. A note like "Rig 0.45 builds agents with AgentBuilder::new(model)" can reach the next session, even in a different agent. See why memU leaves the thinking to the agent for the design.
To try the hosted version, get an API key from memu.so and send your agent one message:
Read https://memu.pro/SKILL.md, follow its instructions to install and configure memU, API Key is
YOUR_MEMU_API_KEY.
The self-hosted setup and the support matrix are in the memU GitHub repository.
FAQ
What is Rig in Rust?
Rig is an open-source Rust library from Playgrounds for building LLM applications and agents. It gives one interface over 20+ model providers and 10+ vector stores, and it is MIT licensed.
How do I install Rig?
Run cargo add rig in your project. The rig crate bundles rig-core and rig-agent. Vector store integrations come as separate crates, such as rig-qdrant.
Can Rig run models locally?
Yes. Rig supports Ollama and llama.cpp servers on your machine, and it can run models in-process with Candle and fastembed, so no API key is needed.
Does Rig support MCP?
Yes. Rig agents can act as MCP clients through rmcp, the official Rust MCP SDK, via the rig-rmcp crate. MCP is not available in WebAssembly builds.
Is Rig production ready?
It is used in production by some teams, according to its homepage, but it is still pre-1.0 and releases contain breaking changes. Pin the version and plan time for upgrades.