Overview
Build provider-backed LLM agents in Rust.
Aquaregia is a Rust SDK for applications that need an LLM to do work, not just return one completion.
The common shape is:
- choose a provider client
- bind it to a model with
client.agent(model) - add instructions and tools
- run the agent, stream it, or inspect the full transcript
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")
.instructions("You are concise.")
.build()?;
let response = agent
.prompt("Explain Rust ownership in 3 bullet points.")
.await?;
println!("{response}");
Ok(())
}When to use Aquaregia
Use Aquaregia when your application needs one of these workflows:
- a model-bound assistant with stable instructions
- a tool-using loop where the model can call your Rust code
- streaming output for a CLI, chat UI, or debug panel
- structured data returned as Rust types
- direct model requests for application-managed conversations
- multimodal prompts and embeddings for retrieval
- the same high-level code running across multiple providers
For one-off lower-level calls, provider clients also expose generate(...), stream(...), generate_object::<T>(...), stream_object::<T>(...), and embed(...).
The mental model
An agent is a loop:
- send the current messages and tool schemas to the model
- receive text and optional tool calls
- execute requested tools
- send tool results back to the model
- stop when the model returns a final answer or your stopping rule fires
Aquaregia owns that loop. Your code owns the tools, model choice, stopping policy, and how to display the result.
Choose a path
Start with the guide that matches what you are building:
| Goal | Read |
|---|---|
| Run the smallest working example | Quickstart |
| Configure OpenAI, Anthropic, Google, or a gateway | Providers |
| Send one explicit model request | Direct requests |
| Build an assistant that can call tools | Agents |
| Turn Rust functions into model-callable tools | Tools |
| Stream model or agent output to a UI | Streaming |
| Ask the model for typed data | Structured output |
| Send images, PDFs, or bytes | Multimodal input |
| Generate vectors for search or RAG | Embeddings |
| Pass provider-native fields | Provider options |
| Handle retries, cancellation, and errors | Errors and production |