RusticAI
A Rust-native agent framework inspired by PydanticAI. RusticAI focuses on clear abstractions, memory safety, and performance while keeping agent orchestration and tool calling ergonomic.
Features
- Agent orchestration with tool calling, usage limits, and message history
- Multi-provider support for OpenAI, Gemini, Anthropic, and Grok (XAI)
- Streaming with structured events (text deltas, tool calls)
- Structured output validation via JSON schema
- Deferred tools for approval flows and human-in-the-loop workflows
- Tool execution controls including timeouts and sequential execution
- MCP toolsets for remote tool integration (HTTP + SSE)
- Instrumentation hooks with tracing/OpenTelemetry support
- Configurable failover with pluggable model resolvers
- Realtime support for Grok voice agents (audio + tool calls)
Installation
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
use ;
async
Adding Tools
Tools are defined with typed arguments using serde and schemars:
use FunctionTool;
use JsonSchema;
use ;
let tool = new?;
let mut agent = new.system_prompt;
agent.tool;
Providers
RusticAI supports multiple LLM providers:
| Provider | Environment Variable | Example Model |
|---|---|---|
| OpenAI | OPENAI_API_KEY |
openai:gpt-4o-mini |
| Anthropic | ANTHROPIC_API_KEY |
anthropic:claude-sonnet-4-5 |
| Gemini | GEMINI_API_KEY |
gemini:gemini-2.0-flash |
| Grok | XAI_API_KEY |
grok:grok-3-mini-fast |
// Use any supported provider
let openai = infer_model?;
let anthropic = infer_model?;
let gemini = infer_model?;
let grok = infer_model?;
Streaming
Stream responses with text deltas and tool call events:
use StreamExt;
use AgentStreamEvent;
let mut stream = agent.run_stream.await?;
while let Some = stream.next.await
Telemetry (Optional)
Enable OpenTelemetry or Datadog exporters with feature flags:
[]
= { = "0.1", = ["telemetry-otel"] }
# or: features = ["telemetry-datadog"]
use Protocol;
use init_otlp_tracing;
let _guard = init_otlp_tracing?;
Documentation
- API Documentation - Full API reference
- Development Guide - Architecture, internals, and contributor guide
License
MIT License - see LICENSE for details.