Skip to main content

rustic_ai/
lib.rs

1//! # RusticAI
2//!
3//! A Rust-native agent framework with tool calling, streaming, and multi-provider
4//! support for OpenAI, Anthropic, Gemini, and Grok.
5//!
6//! ## Quick Start
7//!
8//! ```rust,no_run
9//! use rustic_ai::{Agent, RunInput, UsageLimits, UserContent, infer_model, infer_provider};
10//!
11//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
12//! let model = infer_model("openai:gpt-4o-mini", infer_provider)?;
13//! let agent = Agent::new(model)
14//!     .system_prompt("You are a helpful assistant.");
15//!
16//! let input = RunInput::new(
17//!     vec![UserContent::Text("Hello!".to_string())],
18//!     vec![],
19//!     (),
20//!     UsageLimits::default(),
21//! );
22//!
23//! let result = agent.run(input).await?;
24//! println!("{}", result.output);
25//! # Ok(())
26//! # }
27//! ```
28//!
29//! ## Features
30//!
31//! - **Agent orchestration** with tool calling, usage limits, and message history
32//! - **Multi-provider support** for OpenAI, Gemini, Anthropic, and Grok
33//! - **Streaming** with structured events
34//! - **Structured output** validation via JSON schema
35//! - **Deferred tools** for approval flows
36//! - **MCP toolsets** for remote tool integration
37//! - **Instrumentation hooks** with tracing/OpenTelemetry support
38//!
39//! ## Optional Features
40//!
41//! - `telemetry-otel` - OpenTelemetry/OTLP exporter support
42//! - `telemetry-datadog` - Datadog exporter support
43
44#![forbid(unsafe_code)]
45
46pub mod agent;
47pub mod error;
48pub mod failover;
49pub mod instrumentation;
50mod json_schema;
51pub mod mcp;
52pub mod messages;
53pub mod model;
54pub mod model_config;
55pub mod providers;
56pub mod realtime;
57#[cfg(any(feature = "telemetry-otel", feature = "telemetry-datadog"))]
58pub mod telemetry;
59pub mod tools;
60pub mod usage;
61
62pub use agent::{Agent, AgentRunResult, AgentRunState, DeferredToolCall, RunInput};
63pub use error::AgentError;
64pub use failover::{
65    FailoverResult, classify_error_kind, run_with_config, run_with_config_and_classifier,
66    run_with_failover, run_with_failover_with_classifier, run_with_utility_failover,
67    run_with_utility_failover_with_classifier,
68};
69pub use instrumentation::{Instrumenter, NoopInstrumenter, TracingInstrumenter};
70pub use messages::{
71    AudioUrl, BinaryContent, DocumentUrl, ImageUrl, ModelMessage, ModelRequest, ModelRequestPart,
72    ModelResponse, ModelResponsePart, ProviderItemPart, RetryPromptPart, SystemPromptPart,
73    TextPart, ToolCallPart, ToolReturnPart, UserContent, UserPromptPart, VideoUrl,
74};
75pub use model::{
76    Model, ModelError, ModelRequestParameters, ModelSettings, ModelStream, OutputMode, StreamChunk,
77};
78pub use model_config::{
79    CircuitBreakerConfig, InMemoryResolver, ModelConfigEntry, ModelConfigResolver,
80    ResolvedModelConfig,
81};
82pub use providers::{Provider, ProviderError, infer_model, infer_provider};
83pub use realtime::grok::{
84    GrokClient as GrokRealtimeClient, GrokSender as GrokRealtimeSender,
85    ServerEvent as GrokRealtimeEvent, SessionConfig as GrokSessionConfig,
86};
87pub use tools::ToolError;
88pub use tools::{FunctionTool, RunContext, Tool, ToolDefinition, ToolKind, Toolset};
89pub use usage::{RequestUsage, RunUsage, UsageError, UsageLimits};