Expand description
§Aquaregia
A lightweight agent SDK for Rust: build tool-using LLM agents that run on any provider.
§Features
- Tool-Using Agents: Multi-step agent loops with
prepare_stephooks,stop_when, and configurable tool execution and error handling — you describe the tools, the agent runs the loop. - Provider-Portable: The same agent (and every
generate/streamcall) runs on OpenAI, Anthropic, Google, and OpenAI-compatible endpoints — swap a constructor to change provider. - Streaming & Non-Streaming: Both
generateandstreamAPIs with consistent event handling. - Structured Output:
generate_object::<T>()deserialises responses directly into Rust types usingschemars-derived JSON Schema, with provider-native support (OpenAI) and tool-use fallback (Anthropic, Google). - Reasoning Support: First-class reasoning content extraction and streaming events.
- Multimodal Vision: Send images to vision-capable models via URL, base64, or raw bytes.
- Cancellation: All requests and agent runs support cancellation via
CancellationToken.
§Quick Start
use aquaregia::providers::openai;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let agent = openai::Client::from_env()?
.agent("gpt-5.5")
.build()?;
let out = agent.prompt("Explain Rust ownership in 3 bullet points.").await?;
println!("{out}");
Ok(())
}§Architecture
Re-exports§
pub use agent::Agent;pub use error::Error;pub use error::ErrorCode;pub use tool::Tool;pub use tool::tool;pub use types::AgentOutput;pub use types::AgentStream;pub use types::AgentStreamEvent;pub use types::ChatRequest;pub use types::ChatResponse;pub use types::ContentPart;pub use types::FilePart;pub use types::FinishReason;pub use types::MediaData;pub use types::Message;pub use types::MessageRole;pub use types::ObjectResponse;pub use types::OutputSchema;pub use types::ReasoningPart;pub use types::StreamEvent;pub use types::TextPart;pub use types::TextStream;pub use types::ToolCall;pub use types::ToolErrorPolicy;pub use types::ToolResult;pub use types::Usage;
Modules§
- agent
- Agent runtime and builder APIs. Agent runtime and builder APIs for Aquaregia.
- embed
- Embedding generation types and APIs. Embedding generation types and APIs for Aquaregia.
- error
- Unified error types and HTTP-to-error mapping helpers. Unified error types and HTTP-to-error mapping helpers for Aquaregia.
- providers
- Provider-specific client entry points. Provider clients for Aquaregia.
- tool
- Tool definition, execution, and registry types. Tool definition and execution types for Aquaregia agents.
- types
- Shared request/response and event types. Shared request/response types and streaming events for Aquaregia.