Get Started

Artificial Intelligence · Open source · Rust

Build AI agents in Rust

A modular, high-performance library for LLM apps and agents. One unified API across 20+ providers, type-safe tools and structured output — production-ready.

$cargo add rig
7K+GitHub stars
1.4M+Downloads
226+Contributors
76K+ stars across 181+ repos
agent.rs
use rig::{completion::Prompt, providers::openai};

let openai = openai::Client::from_env()?;

let agent = openai.agent("gpt-5.5")
    .preamble("You are a helpful assistant.")
    .build();

let response = agent
    .prompt("What is Rust?")
    .await?;
output

routing: openai/gpt-5.5 · tokens: 128 · 42ms · response streamed OK

Trusted by teams shipping AI in production
Quick install

Add Rig in one line

Drop it into any Cargo project. Ship it as a single binary or compile to WASM for server, edge, and browser environments.

Then read the quickstart
install
bash$cargo add rig

Developer Experience · Agent Stack

Simple, powerful APIs

One crate takes you from a single completion to tools, streaming, RAG, and multi-agent workflows — all with the same clean Rust builder pattern.

basic_agent.rs
use rig::{completion::Prompt, client::{CompletionClient, ProviderClient},providers::openai}; let agent = openai::Client::from_env() .agent("gpt-5") .preamble("You are a helpful assistant.") .build(); let response = agent .prompt("Explain quantum computing") .await?; println!(response);
promptuser inputagentgpt-5 · preambleCompletionModelimpl by openaiclientfrom_env().prompt()callsbuilds.agent("gpt-5").preamble(…).build()
01 · Agent

Start with one fluent builder

Create a provider client, attach a preamble, build the agent, and prompt it. The same shape scales from a tiny prototype to a production service.

  • Provider client from environment
  • Typed Rust errors with async/await
  • No framework lock-in
02 · Tools

Expose typed Rust functions

Register tools directly on the agent so the model can call real application capabilities without leaving Rust’s type system. Tool arguments and structured output are ordinary Rust types checked at compile time.

  • Macro-generated tool schema
  • Compile-time checked inputs
  • Composable with extractors
03 · Streaming

Stream tokens as they arrive

Switch to streaming when latency matters. Rig keeps the agent API familiar while giving you chunk-level control over the response.

  • Backpressure-friendly streams
  • Works with agent prompts
  • Ideal for chat UIs and CLIs
04 · RAG

Ground agents in your data

Attach a vector index as dynamic context and let the agent retrieve relevant documents at prompt time.

  • Provider-agnostic embeddings
  • Pluggable vector stores
  • Context injected per request
05 · Workflows

Compose the whole agent stack

The same builder pattern stretches into multi-agent workflows: route work, fan out specialized agents, and merge results without leaving Rig’s primitives. Typed errors, tracing hooks, mock models, and VCR cassette tests help keep production systems observable and deterministic.

  • Parallel agent work
  • Provider routing by task
  • VCR cassettes for repeatable tests
Integrations

One interface. Every provider.

Your app talks to rig-core; Rig routes to model providers, tools, MCP servers, and vector stores behind one composable trait system.

Model Providers20+ supported
OpenAIOpenAI
AnthropicAnthropic
Azure OpenAIAzure OpenAI
CohereCohere
DeepSeekDeepSeek
EternalAIEternalAI
Google GeminiGoogle Gemini
GaladrielGaladriel
GroqGroq
Hugging FaceHugging Face
HyperbolicHyperbolic
MiraMira
MoonshotMoonshot
OllamaOllama
OpenRouterOpenRouter
PerplexityPerplexity
TogetherAITogetherAI
xAIxAI
AWS BedrockAWS Bedrock
Vector Stores10+ supported
In-MemoryIn-Memory
MongoDBMongoDB
LanceDBLanceDB
SQLiteSQLite
Neo4jNeo4j
QdrantQdrant
SurrealDBSurrealDB
MilvusMilvus
AWS S3VectorsAWS S3Vectors
ScyllaDBScyllaDB
PostgreSQLPostgreSQL
View all integrations
Community

Open source, built together

Join 226+ contributors building the future of AI in Rust.

MIT licensed & free

Ready to build AI applications in Rust?

Join a growing community of Rust + AI developers building the future of AI infrastructure.