Skip to main content

Crate rig

Crate rig 

Source
Expand description

Public facade for Rig.

Re-exports rig_core at rig::... paths and, under the default agent feature, the runtime from rig_agent at rig::agent. rig::tool then carries the contextual tool API alongside the portable contracts, which are always available. use rig::prelude::*; brings in Model, DynModel and the common agent types.

Companion provider and vector-store crates are feature-gated modules, named after their features wherever module naming allows:

[dependencies]
rig = { version = "*", features = ["lancedb", "fastembed"] }

Depend on rig-core directly to skip this facade’s companion integrations.

Re-exports§

pub use rig_reqwest;reqwest
pub use rig_tungstenite;websocket
pub use rig_cassette as cassette;cassette

Modules§

agentagent
Classic agent orchestration and lifecycle APIs.
audio_generationaudio
Text-to-speech requests and normalized audio responses.
bedrockbedrock
busagent
The classic runtime’s effect bus (rig_agent::bus): the dispatcher, the registrar, the driver, the typed views. What a handler implements is rig::core::serve; the vocabulary is rig::core::effect. Effects without the classic agent are rig-ecs’s.
candlecandle
Local CPU inference with validated Llama/SmolLM2 and native tool-capable Qwen3 models, and YOLOv8 pose estimation.
client
Environment handling for provider configurations.
completion
Low-level completion contracts plus the classic runtime’s errors.
core
Direct access to the portable provider and data contracts.
driver
Calls a model. A Model pairs a Wire (what to send and how to read the reply) with a Transport (how the payload travels). Its stream yields any operation’s events as a Streamed, and its call is that stream, finished: one decoder, one fold and one response constructor for both. The _observed twins take the observation context a bus records under.
effect
Serializable effect requests, handler descriptions, outcomes, and recording data. HandlerKey identifies a destination; EffectKind and Outcome describe the exchange. Host-defined operations use CustomEffect.
embeddings
Provider-agnostic embedding abstractions.
error
The provider error type, serializable error reports, and shared retry classifications for the effect protocol. Reports preserve classifications, available provider metadata, and textual source chains.
extractoragent
Classic typed extraction.
fastembedfastembed-hf-hub or fastembed-ort-download-binaries or fastembed
gemini_grpcgemini-grpc
helixdbhelixdb
http_client
Transport-agnostic HTTP contracts, plus the bundled reqwest transport type.
id
Non-cryptographic random identifiers, process-local run counters, and caller-supplied conversation keys. Do not use generated IDs as secrets.
image_generationimage
Image-generation requests, normalized responses, and model interfaces.
integrationsagent
Classic runtime integrations.
lancedblancedb
loaders
Local document loaders for model and embedding input, with optional error skipping. FileLoader reads paths or bytes. The pdf and epub features enable extraction by page or chapter with source numbering.
markers
Missing and provided states for type-safe builders.
memory
Conversation memory traits and the in-process backend, plus the rig-memory policy types when the memory feature is enabled.
message
milvusmilvus
model
Model metadata returned by providers with model listing support.
mongodbmongodb
neo4jneo4j
observe
Typed runtime and policy observations, separate from effect replay records. Witness receives facts and ObservationLog retains a bounded trace. Optional timestamps come from a host-supplied Clock, not replay identity.
operation
The operations a Wire can perform.
postgrespostgres
prelude
Common portable imports plus additive classic-runtime conveniences.
providers
Provider clients, their configurations, and the models they build.
qdrantqdrant
rerank
Provider-agnostic reranking abstractions.
runagent
The sans-IO run layer of rig-agent (rig_agent::run): AgentRun and its step/turn types, the run’s spec, request preparation, output policy and per-turn patch, its response and error types, the invalid-call decision data, the streamed-turn assembler and the loop-side transcript helpers. rig-core keeps only the message-model invariants (rig::core::transcript).
s3vectorss3vectors
schemars
Schemars
scylladbscylladb
serde
Serde
serve
Handlers return a Reply: an outcome or an owned stream. Dispatch carries identity, requested delivery mode and scopes. ErasedHandler is the shared registry boundary; drivers own polling and cancellation. Provider and tool authors retain their domain traits through adapters. Reply::written offers a writer that mints stream block identities.
sqlitesqlite
streaming
Low-level streaming values.
telemetry
GenAI tracing spans, completion-parent adoption, and opt-in content recording.
test_utilstest-utils
tool
Tools: contextual authoring, the erased tool set, and the live registry.
transcript
Conversation validation and constructors for real or synthetic tool results.
transcription
Audio transcription requests, normalized responses, and model interfaces.
typesafeaitypesafeai
Typed TypeSafe Jev judgments for routing and rubric evaluation.
vector_store
Vector-store insertion and similarity-search interfaces. VectorStoreIndex implementations also implement PortableTool when their filter is deserializable and uses JSON values.
vectorizevectorize
vertexaivertexai
wasm_compat
Target-dependent thread bounds, boxed futures, and executor-independent timers.
wire
Operations, provider wires and their decoders. An Operation names what goes in, what comes out event by event and what ends a reply, and its Fold turns one reply’s events and end into the response. A Wire describes a provider endpoint as plain data, encodes requests without transport access, and names a fresh Decoder for each reply. A decoder is told nothing about how the reply arrives, so buffered and streamed replies go through the same decoder and fold.
ws_clientwebsocket
Transport-independent websocket handshakes, connections, and frames. Backends preserve rejected upgrades as HTTP errors with status, headers, and body.

Macros§

completion_parent_span
Declares a completion-parent span with the marker and all required fields. Defaults to the current span as parent. An optional parent: <expr> between target and name accepts any parent supported by tracing::info_span!, including None.
streaming_conformance_suite

Structs§

Agentagent
Configured model, request settings, hooks, memory, and tool registry for runs. Per-run overrides and dynamic retrieval determine each turn’s effective request.
AgentBuilderagent
Builds an Agent.
AgentRunagent
The sans-IO agent loop state machine. See the module docs for the driving protocol. The persisted envelope is versioned: RUN_FORMAT is written on every serialization and checked on every deserialization, and an unknown key is refused. State written by another format is refused by name rather than loaded with defaults filled in.
AgentRunneragent
A hook-aware driver over AgentRun.
DynModel
A model of one operation with its wire and transport erased. Clones share the model. Built with Model::erase or From<Model<W, T>>, so a consumer takes impl Into<DynModel<Op>> and accepts either.
ErrorReport
A serde-able error crossing a wire boundary.
Model
An endpoint of one provider: a wire bound to a transport.
ProviderResponseError
A raw provider error body with captured transport metadata. Callers must supply the provider’s actual payload, not a generated diagnostic. Serialization omits headers and route; deserialization restores them as None.
TypedPromptResponseagent
A typed run’s response: the deserialized value plus the run’s usage and completion calls.

Enums§

ErrorKind
Normalized classification of an ErrorReport.
ProviderError
A failed provider operation: completion, embedding, reranking, transcription, image or audio generation, verification, model listing, or context caching.

Traits§

Embed
Extracts text fragments for vector embedding in append order. Implementations report extraction failures through EmbedError.

Attribute Macros§

rig_toolderive
Generates a tool type, parameter struct, and uppercase static from a function returning Result<T, E>. Functions with a mutable context implement rig_core::tool::Tool; others implement rig_core::tool::PortableTool. Imported context names need #[rig(context)]; qualified Rig paths are recognized directly. The context is excluded from model arguments.

Derive Macros§

ContextValuederive
Derives rig_core::tool::ContextValue with the type name as its default key. #[context(key = "...")] overrides the key. The type must support serde serialization and deserialization.
Embedderive
Derives rig_core::embeddings::Embed using fields marked with #[embed].