Skip to content
Get Started

Core Concepts

Rig is built from a small set of composable abstractions. Once you understand how they layer, everything else in the framework is a variation on the same pattern. This section explains each piece and links to a dedicated page.

The building blocks stack from the bottom up:

  • Provider clients wrap an LLM vendor (OpenAI, Anthropic, Gemini, Ollama, and more). A client knows how to authenticate and which capabilities the provider supports.
  • Models are created from a client: a CompletionModel for text generation, an EmbeddingModel for vector representations, plus transcription, image, and audio models where a provider supports them.
  • Agents wrap a completion model with a preamble, tools, and context. An agent is the highest-level, most convenient way to prompt a model, and it runs the tool-calling loop for you.
  • Tools, RAG, and memory extend an agent: tools let it call your code, RAG injects relevant documents from a vector store, and memory loads and saves conversation history per conversation — automatically via a memory backend, or by hand when you want full control.
  • Workflows compose all of the above into multi-step programs — sequential, parallel, or conditional — using plain Rust.
flowchart TD
Client["Provider / Client"] --> Model["Model"]
Model --> Agent["Agent"]
Tools["Tools"] -.-> Agent
RAG["RAG<br/>(Embeddings + Vector Store)"] -.-> Agent
Memory["Memory"] -.-> Agent
Agent --> Output["Structured Output"]

The Client authenticates a vendor and creates a Model. An Agent wraps that model and draws on Tools (your code), RAG (documents retrieved from a vector store), and Memory (conversation history) to answer a prompt — as free text or as Structured Output.

Start from the task, not the type. Each row links to the page that covers it.

I want to…Reach for…Page
prompt a model onceCompletionsCompletions
let the model plan multi-step workAgents (the agent loop)Agents
hold a conversationConversation memoryMemory
let the model call my codeToolsTools
get typed data out of textStructured OutputStructured Output
answer from my documentsRAG + Vector StoresVector Stores & RAG
stream tokens as they arriveStreamingStreaming
orchestrate known steps in codeWorkflowsWorkflows
coordinate several agentsMulti-agent systemsMulti-agent systems
test without a live modelMock modelsTesting

A minimal end-to-end example touches the first three layers:

use rig::client::{CompletionClient, ProviderClient};
use rig::completion::Prompt;
use rig::providers::openai;
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// provider client -> agent (wraps a completion model)
let agent = openai::Client::from_env()?
.agent("gpt-5.5")
.preamble("You are a helpful assistant.")
.build();
let answer = agent.prompt("What is Rig?").await?;
println!("{answer}");
Ok(())
}
  • New to Rig? Start with the Quickstart to build your first agent.
  • Want the big picture? See the Architecture overview.
  • Ready to build something? Head to the Guides.