Skip to content
0xPlaygroundsPublic

About

⚙️🦀 Build modular and scalable LLM Applications in Rust

Topics

Resources

Contributing

Stars

9.2k stars

Watchers

57 watching

Forks

Latest commit

 

History

1,894 Commits

Folders and files

Repository files navigation

Rig logo

       
    stars - rig

 

📑 Docs   •   🌐 Website   •   🤝 Contribute   •   ✍🏽 Blogs   •   Ryzome

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

rig-cli is not on crates.io yet. Until the next release, install the last release, 0.46.0, whose rig crate carries the launcher:

cargo install rig

This README describes main. 0.46.0 keeps its plugin list in plugins.toml, and its guide is on its tag. Or install main from a checkout (--force replaces a rig installed by another crate):

git clone https://github.com/0xPlaygrounds/rig && cd rig
cargo install --locked --force --path crates/rig-cli

Then:

  1. rig builds the agent, which takes several minutes the first time, and opens it.
  2. /login signs in with a ChatGPT plan or saves a provider's API key. Or export a key, such as OPENAI_API_KEY, before starting rig.
  3. /model picks a model. A local Ollama or llama.cpp server is listed once OLLAMA_API_BASE_URL or LLAMACPP_API_BASE_URL names it, or its key variable is set.
  4. Type a prompt and press Enter. /help lists the commands.
  5. rig -p "fix the failing test" answers one prompt without the terminal view.

rig update updates rig (how). The agent guide also says what is per home and what is per project.

  • Everything is a plugin. The agent is a Bevy app; its tools, commands, sessions, sign-in and terminal view are each a plugin, turned on or off in settings.toml, so any of them can be removed, replaced or added to.
  • It rebuilds itself. /reload rebuilds the agent with your plugin crates and restarts it in the same session, and keeps the old build running if the new one does not compile. rig update reinstalls rig with cargo; /update does it from the agent and restarts on it. Both arrive with the next release: 0.46.0 updates by installing again.
  • Scriptable. rig -p --json and rig --json drive it over pipes; rig help-agents is the protocol.
  • More when you want it. Subagents are an optional plugin, 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(())
}

The example also needs tokio, with the macros and rt-multi-thread features that #[tokio::main] uses, and anyhow (cargo add tokio --features macros,rt-multi-thread and cargo add anyhow).

  • 20+ model providers and 10+ vector stores, each under one interface
  • Agents with tools, multi-turn streaming and typed hooks
  • Live tool output in streamed runs: a returned JSON array arrives one element at a time, any other output at once
  • Completion, embedding, transcription, audio and image generation
  • GenAI semantic conventions for OpenTelemetry
  • Recording and replay of an agent's effects (rig-cassette)
  • Browser WASM (wasm32-unknown-unknown) for the core and the agent runtime (target support)

More in examples/, the docs and the API reference.

Crates

The rig crate re-exports rig-core, and each companion crate behind a feature.

Crate Feature What it is
rig-core always Provider-neutral messages, completion and embedding models, tool contracts, the conversation type, vector-store contracts, and the providers
rig-agent agent (default) The agent builder, prompting and streaming, hooks, the tool registry and the serializable AgentRun
rig-memory memory Windows, compaction, and saving, resuming and forking conversations
rig-cassette cassette Effect logs: recording, replay and checkpoints

The coding agent's crates are not facade features. Depend on them directly.

Crate What it is
rig-cli The rig launcher
rig-tools Coding tools any rig agent can use: read, write, edit, search, shell
rig-ecs, rig-harness The agent kernel on Bevy's ECS, and the harness the coding agent's plugins build on
rig-tui, rig-basics The terminal view, and the coding agent's default plugins
rig-markdown Markdown drawn as styled lines and word-wrapped to a width, shared by the terminal view and rig -p
rig-fold Off by default: folds finished tool calls in the terminal view, with a key that shows them whole
rig-traffic Opt-in provider HTTP recording in the session store, using the cassette engine
rig-mcp-client The coding agent's MCP client, off by default: MCP servers' tools, with an opt-in plugin that asks before a project's server starts
rig-acp rig acp, off by default: the coding agent for ACP clients (editors such as Zed)

Integrations

rig = { version = "0.46.0", features = ["lancedb", "fastembed"] }
Integration Crate Feature Module path
AWS Bedrock rig-bedrock bedrock rig::bedrock
AWS S3Vectors rig-s3vectors s3vectors rig::s3vectors
Candle (local Llama/SmolLM2/Qwen3 tools, YOLOv8 pose) rig-candle candle rig::candle
Cloudflare Vectorize rig-vectorize vectorize rig::vectorize
FastEmbed rig-fastembed fastembed rig::fastembed
Google Gemini gRPC rig-gemini-grpc gemini-grpc rig::gemini_grpc
Google Vertex AI rig-vertexai vertexai rig::vertexai
HelixDB rig-helixdb helixdb rig::helixdb
LanceDB rig-lancedb lancedb rig::lancedb
Conversations over time rig-memory memory rig::memory
Milvus rig-milvus milvus rig::milvus
MongoDB rig-mongodb mongodb rig::mongodb
Neo4j rig-neo4j neo4j rig::neo4j
PostgreSQL (vector store; with memory, a session store) rig-postgres postgres rig::postgres
Qdrant rig-qdrant qdrant rig::qdrant
ScyllaDB rig-scylladb scylladb rig::scylladb
SQLite (vector store; with memory, a session store) rig-sqlite sqlite rig::sqlite
SurrealDB rig-surrealdb surrealdb rig::surrealdb
TypeSafe Jev (experimental judgments) rig-typesafeai typesafeai rig::typesafeai

Community

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.



Build by Playgrounds

About

⚙️🦀 Build modular and scalable LLM Applications in Rust

Topics

Resources

Contributing

Stars

9.2k stars

Watchers

57 watching

Forks

Releases

Used by

Contributors

Languages