Rig is a Rust library for building LLM applications, and rig, a terminal
coding agent built on it that you extend with Bevy plugins.
The coding agent
cargo install rig
rig
In the agent, /login signs in with a ChatGPT plan or saves a provider’s API
key, or export the key (such as OPENAI_API_KEY) before starting. /model picks
the model and /help lists the commands. rig -p "fix the failing test"
answers one prompt without the terminal view.
Everything is a plugin. The agent is a Bevy app; its
tools, commands, sessions, sign-in and terminal view are each a plugin listed
in plugins.toml, so any of them can be removed, replaced or added to.
It rebuilds itself./reload rebuilds the agent with your plugin
changes and restarts it in the same session, and keeps the old build running
if the new one does not compile.
Scriptable.rig -p --json and rig --json drive it over pipes;
rig help-agents is the protocol.
More when you want it. Subagents and checkpoints of what shell
changed are optional plugins, and the tools work on remote hosts over ssh
or any command.
The agent guide covers the keys, sessions, compaction,
plugins and files, and the plugin guide shows
how to write a tool, command or panel. The agent needs Rust 1.97.1 or newer
and runs on Linux and macOS.
The library
cargo add rig
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(())
}
#[tokio::main] needs tokio’s macros and rt-multi-thread features
(cargo add tokio --features macros,rt-multi-thread).
20+ model providers and 10+ vector stores, each under one interface
Agents with tools, multi-turn streaming and typed hooks
Completion, embedding, transcription, audio and image generation
Projects built on Rig are listed in
awesome-rig; open a pull
request there to add yours. Questions and ideas are welcome on
Discord, and CONTRIBUTING.md
says how to contribute. Rig is MIT licensed.
[!WARNING]
Rig is pre-1.0. Releases contain breaking changes; each release’s
changelog and migration notes say what
changed and how to move.
📑 Docs • 🌐 Website • 🤝 Contribute • ✍🏽 Blogs •
Rig is a Rust library for building LLM applications, and
rig, a terminal coding agent built on it that you extend with Bevy plugins.The coding agent
In the agent,
/loginsigns in with a ChatGPT plan or saves a provider’s API key, or export the key (such asOPENAI_API_KEY) before starting./modelpicks the model and/helplists the commands.rig -p "fix the failing test"answers one prompt without the terminal view.plugins.toml, so any of them can be removed, replaced or added to./reloadrebuilds the agent with your plugin changes and restarts it in the same session, and keeps the old build running if the new one does not compile.rig -p --jsonandrig --jsondrive it over pipes;rig help-agentsis the protocol.shellchanged are optional plugins, and the tools work on remote hosts over ssh or any command.The agent guide covers the keys, sessions, compaction, plugins and files, and the plugin guide shows how to write a tool, command or panel. The agent needs Rust 1.97.1 or newer and runs on Linux and macOS.
The library
#[tokio::main]needs tokio’smacrosandrt-multi-threadfeatures (cargo add tokio --features macros,rt-multi-thread).rig-cassette)wasm32-unknown-unknown) for the core and the agent runtime (target support)More in
examples/, the docs and the API reference.Crates
The
rigcrate re-exports the core and the agent runtime, and each companion crate behind a feature.rig-corerig-agentAgentRunrig-memoryrig-cassetterig-toolsrig-ecs,rig-harnessrig-tui,rig-basicsrig-trafficIntegrations
rig-bedrockbedrockrig::bedrockrig-s3vectorss3vectorsrig::s3vectorsrig-candlecandlerig::candlerig-vectorizevectorizerig::vectorizerig-fastembedfastembedrig::fastembedrig-gemini-grpcgemini-grpcrig::gemini_grpcrig-vertexaivertexairig::vertexairig-helixdbhelixdbrig::helixdbrig-lancedblancedbrig::lancedbrig-memorymemoryrig::memoryrig-milvusmilvusrig::milvusrig-mongodbmongodbrig::mongodbrig-neo4jneo4jrig::neo4jmemory, a session store)rig-postgrespostgresrig::postgresrig-qdrantqdrantrig::qdrantrig-scylladbscylladbrig::scylladbmemory, a session store)rig-sqlitesqliterig::sqliterig-surrealdbsurrealdbrig::surrealdbrig-typesafeaitypesafeairig::typesafeaiCommunity
Projects built on Rig are listed in awesome-rig; open a pull request there to add yours. Questions and ideas are welcome on Discord, and CONTRIBUTING.md says how to contribute. Rig is MIT licensed.