
Rig is a harness: a Rust library for writing AI agents, and a coding agent built on top of it.
Guides · API reference · Examples · Agent guide · Plugin guide
A terminal coding agent you can take apart. Its tools, commands, sessions,
sign-in and terminal view are each a Bevy plugin, so any of them can be
turned off, replaced or added to. Change one, and /reload rebuilds the
agent around you while the session carries on.
cargo install rig
rigIt runs on Linux and macOS with Rust 1.97.1 or newer.
/pluginslists the plugins and turns each one on or off./helplists every command.rig -p "fix the failing test"answers one prompt and exits. Add--jsonto get the run as JSON lines.rig --jsonstays running for a script or another agent to drive: one request per line on stdin, one event per line on stdout, until stdin closes.rig help-agentsprints the whole protocol.
The agent guide covers the rest, and the plugin guide shows how to write a plugin.
Already paying for another coding agent? The optional
rig-bridge plugin uses Claude Code, Codex, Grok
Build, Antigravity, Muse or Copilot CLI as a model provider, with that
program's own sign-in and no API key. Rig keeps the conversation and tools.
rig plugin enable rig_bridge::BridgePlugin
rig --model claude-code/claude-opus-5-5One interface over more than 20 model providers. Give an agent a plain Rust function as a tool, and switch providers by changing the model line.
cargo add rig
cargo add tokio --features macros,rt-multi-threaduse rig::prelude::*;
use rig::providers::openai::{self, OpenAI};
use rig::tool::ToolExecutionError;
/// Add two numbers.
#[rig::rig_tool]
fn add(x: i64, y: i64) -> Result<i64, ToolExecutionError> {
Ok(x + y)
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Reads OPENAI_API_KEY.
let model = OpenAI::from_env()?.completion(openai::GPT_6_2_SOL);
let agent = AgentBuilder::new(model)
.preamble("Use your tools to answer.")
.tool(Add)
.build();
let response = agent.prompt("What is 1234 + 4321?").await?;
println!("{}", response.output());
Ok(())
}For Claude, import rig::providers::anthropic::{self, Anthropic} and the
model line becomes
Anthropic::from_env()?.completion(anthropic::CLAUDE_SONNET_5_5). The agent
and the tool stay as they are.
- A dozen vector stores behind one interface.
- Agents with tools, streaming and typed hooks.
- Completion, embedding, transcription, audio and image models.
- OpenTelemetry GenAI conventions.
rig-coreandrig-agentbuild for browser WASM.
Integrations such as vector stores, local models and saved conversations are
Cargo features, for example cargo add rig --features memory,fastembed.
docs.rs lists every feature.
Ask questions on Discord. CONTRIBUTING.md says how to contribute, and awesome-rig lists projects built on Rig.
Rig is pre-1.0, so releases break APIs. The changelog and migration notes say what changed. Rig is MIT licensed.