0xPlaygrounds/rig

⚙️🦀 Build modular and scalable LLM Applications in Rust

What is Rig?

Rig is a Rust‑based ecosystem for building and running applications that use large language models (LLMs). It consists of two parts:

  1. rig library – a set of crates that provide a provider‑agnostic API for completions, embeddings, audio/image generation, vector stores, tool contracts, memory handling, and OpenTelemetry semantics.
  2. rig terminal agent – a command‑line “coding agent” built on the Bevy game engine. The agent can be extended with plugins (tools, commands, UI panels) that live in a plugins.toml file.

Both are open‑source, published on crates.io, and target Linux/macOS with Rust 1.97+.


Key Features (as described in the README)

Area Details
Plugin architecture Everything – sign‑in, model selection, tools, terminal UI – is a Bevy plugin. You can add, replace, or remove plugins without touching the core.
Self‑rebuilding agent The /reload command recompiles the agent with any plugin changes and restarts it in the same session, falling back to the previous build if compilation fails.
Scriptable / pipe‑friendly rig -p --json and rig --json emit JSON on stdout, allowing other programs to drive the agent via pipes. The help‑agents command documents the protocol.
Rich toolset Built‑in tools for reading/writing files, editing code, searching, running shell commands, and remote SSH execution. Additional tools can be added as plugins.
Model & vector‑store integrations 20+ model providers (OpenAI, AWS Bedrock, Gemini, etc.) and 10+ vector‑store back‑ends (LanceDB, Qdrant, Milvus, SQLite, MongoDB, Neo4j, …) are exposed through a single interface.
Agent capabilities Multi‑turn streaming, typed hooks, tool usage, memory windows with compaction, checkpointing, and replay via the rig‑cassette crate.
Cross‑platform runtime Core and agent runtime compile to wasm32-unknown-unknown, enabling browser‑based usage.
Observability Emits OpenTelemetry GenAI semantic conventions for tracing and metrics.

Getting Started

Install the terminal agent

cargo install rig
rig               # start the interactive coding agent

Sign‑in: /login chatgpt or set an API key env var (e.g., OPENAI_API_KEY). Select model: /model. One‑shot prompt: rig -p "fix the failing test".

Use the library in your own Rust code

# Cargo.toml
[dependencies]
rig = "0.44"
use rig::prelude::*;
use rig::providers::openai::{self, OpenAI};

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    let model = OpenAI::from_env()?.completion(openai::GPT_6_1_SOL);
    let agent = AgentBuilder::new(model)
        .preamble("You are a comedian …")
        .build();
    let resp = agent.prompt("Entertain me!").await?;
    println!("{}", resp.output());
    Ok(())
}

Note: add tokio with macros,rt-multi-thread features.


Crate Landscape

Crate Purpose
rig-core Provider‑neutral data structures, model/embedding contracts, tool interfaces.
rig-agent Builder, prompting, streaming, hooks, serialisable run logs.
rig-memory Conversation windows, compaction, persistence.
rig-cassette Record/replay of agent effects, checkpoints.
rig-tools Common coding tools (read, write, edit, search, shell).
rig-ecs / rig-harness Bevy ECS kernel and plugin harness for the coding agent.
rig-tui / rig-basics Default terminal UI and baseline plugins.
Integration crates (e.g., rig-bedrock, rig-lancedb, rig-fastembed, …) Optional features that bring in specific model providers or vector‑store back‑ends.

Community & Ecosystem


Who Might Use This?

  • Rust developers who want a type‑safe, modular framework for LLM‑driven tools.
  • Teams building coding assistants, chat‑based agents, or RAG pipelines that need custom tooling and persistent memory.
  • Anyone looking to experiment with many model providers or vector stores without switching languages.

Bottom Line

Rig is a genuine, production‑oriented Rust library and accompanying terminal agent for constructing LLM applications. Its plugin‑first design, broad provider/vector‑store support, and built‑in observability make it a solid foundation for developers who prefer Rust and want deep control over their AI agents.

Related

  • Project
  • Project
  • Project
  • Project
  • Project