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;reqwestpub use rig_tungstenite;websocketpub use rig_cassette as cassette;cassette
Modules§
- agent
agent - Classic agent orchestration and lifecycle APIs.
- audio_
generation audio - Text-to-speech requests and normalized audio responses.
- bedrock
bedrock - bus
agent - The classic runtime’s effect bus (
rig_agent::bus): the dispatcher, the registrar, the driver, the typed views. What a handler implements isrig::core::serve; the vocabulary isrig::core::effect. Effects without the classic agent arerig-ecs’s. - candle
candle - 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
Modelpairs aWire(what to send and how to read the reply) with aTransport(how the payload travels). Itsstreamyields any operation’s events as aStreamed, and itscallis that stream, finished: one decoder, one fold and one response constructor for both. The_observedtwins take the observation context a bus records under. - effect
- Serializable effect requests, handler descriptions, outcomes, and recording data.
HandlerKeyidentifies a destination;EffectKindandOutcomedescribe the exchange. Host-defined operations useCustomEffect. - 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.
- extractor
agent - Classic typed extraction.
- fastembed
fastembed-hf-huborfastembed-ort-download-binariesorfastembed - gemini_
grpc gemini-grpc - helixdb
helixdb - 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_
generation image - Image-generation requests, normalized responses, and model interfaces.
- integrations
agent - Classic runtime integrations.
- lancedb
lancedb - loaders
- Local document loaders for model and embedding input, with optional error skipping.
FileLoaderreads paths or bytes. Thepdfandepubfeatures 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-memorypolicy types when thememoryfeature is enabled. - message
- milvus
milvus - model
- Model metadata returned by providers with model listing support.
- mongodb
mongodb - neo4j
neo4j - observe
- Typed runtime and policy observations, separate from effect replay records.
Witnessreceives facts andObservationLogretains a bounded trace. Optional timestamps come from a host-suppliedClock, not replay identity. - operation
- The operations a
Wirecan perform. - postgres
postgres - prelude
- Common portable imports plus additive classic-runtime conveniences.
- providers
- Provider clients, their configurations, and the models they build.
- qdrant
qdrant - rerank
- Provider-agnostic reranking abstractions.
- run
agent - The sans-IO run layer of rig-agent (
rig_agent::run):AgentRunand 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). - s3vectors
s3vectors - schemars
- Schemars
- scylladb
scylladb - serde
- Serde
- serve
- Handlers return a
Reply: an outcome or an owned stream.Dispatchcarries identity, requested delivery mode and scopes.ErasedHandleris the shared registry boundary; drivers own polling and cancellation. Provider and tool authors retain their domain traits throughadapters.Reply::writtenoffers a writer that mints stream block identities. - sqlite
sqlite - streaming
- Low-level streaming values.
- telemetry
- GenAI tracing spans, completion-parent adoption, and opt-in content recording.
- test_
utils test-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.
- typesafeai
typesafeai - Typed TypeSafe Jev judgments for routing and rubric evaluation.
- vector_
store - Vector-store insertion and similarity-search interfaces.
VectorStoreIndeximplementations also implementPortableToolwhen their filter is deserializable and uses JSON values. - vectorize
vectorize - vertexai
vertexai - wasm_
compat - Target-dependent thread bounds, boxed futures, and executor-independent timers.
- wire
- Operations, provider wires and their decoders. An
Operationnames what goes in, what comes out event by event and what ends a reply, and itsFoldturns one reply’s events and end into the response. AWiredescribes a provider endpoint as plain data, encodes requests without transport access, and names a freshDecoderfor 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_
client websocket - 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>betweentargetandnameaccepts any parent supported bytracing::info_span!, includingNone. - streaming_
conformance_ suite
Structs§
- Agent
agent - Configured model, request settings, hooks, memory, and tool registry for runs. Per-run overrides and dynamic retrieval determine each turn’s effective request.
- Agent
Builder agent - Builds an
Agent. - Agent
Run agent - The sans-IO agent loop state machine. See the module docs for the
driving protocol.
The persisted envelope is versioned:
RUN_FORMATis 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. - Agent
Runner agent - 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::eraseorFrom<Model<W, T>>, so a consumer takesimpl Into<DynModel<Op>>and accepts either. - Error
Report - A serde-able error crossing a wire boundary.
- Model
- An endpoint of one provider: a wire bound to a transport.
- Provider
Response Error - 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. - Typed
Prompt Response agent - A typed run’s response: the deserialized value plus the run’s usage and completion calls.
Enums§
- Error
Kind - Normalized classification of an
ErrorReport. - Provider
Error - 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_
tool derive - Generates a tool type, parameter struct, and uppercase static from a function
returning
Result<T, E>. Functions with a mutable context implementrig_core::tool::Tool; others implementrig_core::tool::PortableTool. Imported context names need#[rig(context)]; qualified Rig paths are recognized directly. The context is excluded from model arguments.
Derive Macros§
- Context
Value derive - Derives
rig_core::tool::ContextValuewith the type name as its default key.#[context(key = "...")]overrides the key. The type must support serde serialization and deserialization. - Embed
derive - Derives
rig_core::embeddings::Embedusing fields marked with#[embed].