← プロジェクト一覧に戻る

Rig

ツールの引数もモデルの出力も実行時ではなくコンパイル時に検査される、Rust製のエージェント構築ライブラリ

MIT
スター
8.4k
フォーク
938
オープンIssue
113
最終コミット
2026年8月27日

Rigとは

Rigは、本体がすでにRustで書かれていて、モデルを呼ぶためだけにPythonのプロセスを別に立てたくない場合の選択肢です。ツールはRustの関数そのもので、引数の定義は型から生成されるため、食い違いは本番で見つかる不正な呼び出しではなくコンパイルエラーになります。出力も同じで、エクストラクタにモデルへ値を求めさせると、普通のRustの構造体として返ってきます。モデルの提供元もベクトルストアもトレイトの背後にあるため、差し替えは設定の変更で済みます。引き換えになるのは周辺の充実度です。評価や記録、エージェント向けの道具はPythonなら何種類もありますが、Rustでは相当するものがないことが多く、周辺の仕組みは自分で書くことになります。

Rigで何ができますか?

  • ツールの引数をコンパイル時に検査する — ツールはRustの関数そのもので、モデルに見せる定義はその型から生成されます。引数が食い違えば実行時ではなくビルドで失敗します。
  • 文字列を解析せず構造体で受け取る — エクストラクタを使うと、宣言した型の形でモデルに値を求め、その型のまま受け取れます。解析と検証は済んだ状態です。
  • エージェントを書き換えずに提供元を差し替える — どの提供元も同じトレイトの背後にあるため、クラウドのモデルと自前のモデルの行き来はクライアントの入れ替えだけで済みます。
  • 検索用のベクトル索引をつなぐ — ベクトルストアを文脈の供給元として組み込み、プロンプト作成時に参照させられます。対応済みの保存先は10種類以上あります。
  • 複数のエージェントを1つの経路にまとめる — パイプラインでエージェント間の振り分けや並列実行を行い、戻り値を合成できます。別途の制御サービスは要りません。

Rigを選ぶ前に

  • 周辺の生態系はPython側にあります。評価の仕組みや記録の連携、既製のツール群など、他の言語なら選ぶだけで済むものがRustには存在しないことが多くあります。
  • 利点である型の厳密さは試行錯誤の速度を下げます。ツールの戻り値を変えると呼び出し経路全体の型を直すことになり、動的な言語のようにまず動かしてみる進め方は取りにくくなります。

よくある質問

Rigは商用利用できますか?

RigはMITライセンスで公開されています。OSI承認のオープンソースライセンスで、商用利用が認められています。

Rigはどの形で使えますか?

Rigはセルフホスト・ローカル実行の形で利用できます。

ドキュメント

0xPlaygrounds/rig のREADMEより転載(MIT)。 原文を読む ↗

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

✨ If you would like to help spread the word about Rig, please consider starring the repo!

[!WARNING] Here be dragons! As we plan to ship a torrent of features in the following months, future updates will contain breaking changes. With Rig evolving, we’ll annotate changes and highlight migration paths as we encounter them.

Table of contents

What is Rig?

Rig is a Rust library for building scalable, modular, and ergonomic LLM-powered applications.

More information about this crate can be found in the official and crate API reference documentation.

Features

  • Agentic workflows that can handle multi-turn streaming and prompting
  • A classic agent runtime enabled by default
  • Full GenAI Semantic Convention compatibility
  • 20+ model providers, all under one singular unified interface
  • 10+ vector store integrations, all under one singular unified interface
  • Full support for LLM completion and embedding workflows
  • Support for transcription, audio generation and image generation model capabilities
  • Integrate LLMs in your app with minimal boilerplate
  • Browser-WASM (wasm32-unknown-unknown) support for the portable core and classic runtime — see target support for the full matrix (WASI is not supported; rig-rmcp/MCP is native-only)

Runtime choices

Rig separates portable provider/backend contracts from agent orchestration:

  • rig-core contains provider-neutral messages, completion models, portable tools, memory and vector-store contracts, and built-in provider mappings.
  • rig-agent contains the classic builder, prompt/streaming traits, typed hooks, contextual tools, extraction, and the serializable AgentRun state machine. It remains enabled by default.

The root rig facade re-exports both at their familiar paths, so most code depends only on rig.

Who is using Rig?

Below is a non-exhaustive list of companies and people who are using Rig:

  • St Jude - Using Rig for a chatbot utility as part of proteinpaint, a genomics visualisation tool.
  • Coral Protocol - Using Rig extensively, both internally as well as part of the Coral Rust SDK.
  • VT Code - VT Code is a Rust-based terminal coding agent with semantic code intelligence via Tree-sitter and ast-grep. VT Code uses rig for simplifying LLM calls and implementing the model picker.
  • Con - Con is a GPU-accelerated terminal emulator with a built-in AI agent harness. It uses Rig as the provider abstraction layer for its integrated coding agents.
  • Dria - a decentralised AI network. Currently using Rig as part of their compute node.
  • Nethermind - Using Rig as part of their Neural Interconnected Nodes Engine framework.
  • Neon - Using Rig for their app.build V2 reboot in Rust.
  • Listen - A framework aiming to become the go-to framework for AI portfolio management agents. Powers the Listen app.
  • Cairnify - helps users find documents, links, and information instantly through an intelligent search bar. Rig provides the agentic foundation behind Cairnify’s AI search experience, enabling tool-calling, reasoning, and retrieval workflows.
  • Ryzome - Ryzome is a visual AI workspace that lets you build interconnected canvases of thoughts, research, and AI agents to orchestrate complex knowledge work.
  • deepwiki-rs - Turn code into clarity. Generate accurate technical docs and AI-ready context in minutes—perfectly structured for human teams and intelligent agents.
  • Cortex Memory - The production-ready memory system for intelligent agents. A complete solution for memory management, from extraction and vector search to automated optimization, with a REST API, MCP, CLI, and insights dashboard out-of-the-box.
  • Ironclaw - A secure personal AI assistant
  • ilert - Incident management & alerting platform. Uses Rig as the multi-provider abstraction in its agentic LLM proxy powering ilert AI.
  • Archestra - MCP-native secure AI platform. Uses Rig in its agentic benchmark.

For a curated list of Rig projects, libraries, tools, articles, and production users, check out awesome-rig.

Are you also using Rig? Open an issue to have your name added!

Get Started

Use the root rig facade when you want feature-gated access to companion crates, or use rig-core directly when you only need the core provider abstractions.

cargo add rig
# or: cargo add rig-core

Simple example

use rig::prelude::*;
use rig::providers::openai;

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    // Create OpenAI client
    let client = openai::Client::from_env()?;

    // Create agent with a single context prompt
    let comedian_agent = client
        .agent(openai::GPT_5_2)
        .preamble("You are a comedian here to entertain the user using humour and jokes.")
        .build();

    // Prompt the agent and print the response
    let response = comedian_agent.prompt("Entertain me!").await?;

    println!("{response}");

    Ok(())
}

Note using #[tokio::main] requires you enable tokio’s macros and rt-multi-thread features or just full to enable all features (cargo add tokio --features macros,rt-multi-thread).

You can find more examples in each crate’s examples directory (for example, examples). Provider-specific integration coverage lives under tests/providers, with cassette-backed tests that replay offline by default and live-only tests kept separate when real provider APIs are still required. See tests/README.md for test target, replay, record, and cassette safety commands. More detailed use case walkthroughs are regularly published on our Dev.to Blog and added to Rig’s official documentation at rig.rs/docs.

Supported Integrations

The root rig facade exposes companion crates behind one feature per integration:

rig = { version = "0.36.0", features = ["lancedb", "fastembed"] }
IntegrationCrateFeatureModule path
AWS Bedrockrig-bedrockbedrockrig::bedrock
AWS S3Vectorsrig-s3vectorss3vectorsrig::s3vectors
Candle (local Llama/SmolLM2/Qwen3 tools)rig-candlecandlerig::candle
Cloudflare Vectorizerig-vectorizevectorizerig::vectorize
FastEmbedrig-fastembedfastembedrig::fastembed
Google Gemini gRPCrig-gemini-grpcgemini-grpcrig::gemini_grpc
Google Vertex AIrig-vertexaivertexairig::vertexai
HelixDBrig-helixdbhelixdbrig::helixdb
LanceDBrig-lancedblancedbrig::lancedb
Memory policiesrig-memorymemoryrig::memory
Milvusrig-milvusmilvusrig::milvus
MongoDBrig-mongodbmongodbrig::mongodb
Neo4jrig-neo4jneo4jrig::neo4j
PostgreSQLrig-postgrespostgresrig::postgres
Qdrantrig-qdrantqdrantrig::qdrant
ScyllaDBrig-scylladbscylladbrig::scylladb
SQLiterig-sqlitesqliterig::sqlite
SurrealDBrig-surrealdbsurrealdbrig::surrealdb

rig::memory is available without the memory feature; it contains the core conversation memory traits and in-memory backend re-exported from rig-core. Enabling features = ["memory"] adds reusable history-shaping policy types from the rig-memory companion crate to the same module.

We also have some other associated crates that have additional functionality you may find helpful when using Rig:

  • rig-onchain-kit - the Rig Onchain Kit. Intended to make interactions between Solana/EVM and Rig much easier to implement.