Skip to main content

mutil_ai/
lib.rs

1//! A small, provider-neutral AI SDK designed for learning.
2//!
3//! The important idea in this crate is the split between:
4//!
5//! 1. an **internal message model** that can represent messy agent histories;
6//! 2. a **normalization layer** that turns that model into a clean, strict
7//!    provider-facing conversation;
8//! 3. provider adapters that only serialize the normalized form.
9//!
10//! This keeps role conversion and tool-call repair in one place.
11//!
12//! The crate intentionally stops at the model request/response boundary.
13//! Conversation loops, tool execution, permissions, and agent scheduling belong
14//! to the downstream application. See `examples/minimal_agent.rs` for a small
15//! runtime built only from the public API.
16
17mod adapter;
18mod audit;
19#[cfg(feature = "blocking")]
20mod blocking;
21mod cancel;
22mod error;
23mod headers;
24mod native_tool_stream;
25mod normalize;
26mod profile;
27mod report;
28mod retry;
29mod security;
30mod sse;
31mod stream;
32mod transform;
33mod types;
34
35pub use adapter::{
36    Anthropic, AnthropicMessages, EndpointAdapter, Gemini, GeminiGenerateContent, ModelAdapter,
37    OpenAI, OpenAIChat, OpenAICompatible, OpenAIResponses,
38};
39pub use audit::{
40    AuditConfig, AuditEvent, AuditOutcome, AuditSink, AuditStats, AuditStatsSnapshot, ByteCounts,
41    FirstTokenKind, ProfileAuditSnapshot, RequestTiming, bounded_audit_channel,
42};
43#[cfg(feature = "blocking")]
44pub use blocking::{BlockingAdapter, BlockingStream};
45pub use cancel::CancellationToken;
46pub use error::{Error, ErrorKind, ProviderErrorInfo, Result};
47pub use headers::{
48    ClientInfo, HeaderInjector, HeaderPolicy, RequestContext, RequestOptions, SDK_USER_AGENT,
49    TransportConfig, apply_headers,
50};
51pub use native_tool_stream::{CustomToolAccumulator, NativeToolIdentity};
52pub use normalize::{
53    ExternalRole, MissingToolResultPolicy, NormalizeAction, NormalizeOptions, NormalizeReport,
54    NormalizeStats, NormalizedChat, NormalizedMessage, OrphanToolResultPolicy, Protocol,
55    SystemPlacement, normalize, normalize_with_options,
56};
57pub use profile::{
58    AuthStyle, Capabilities, EffortMapping, EndpointSpec, MaxTokensSemantics, ModelMatcher,
59    ModelProfile, NormalizeProfile, ProfileId, ProfileRegistry, ProfileSelector, ProtocolSurface,
60    ProviderProfile, ProviderRequestOptions, ReasoningAliases, ReasoningCapabilities,
61    ReasoningProfile, ReasoningReplayPolicy, RequestProfile, StreamCapabilities, StreamProfile,
62    StreamTerminal, ThinkingRequestProfile, ToolCallContentMode, ToolCallIdPolicy,
63    ToolCapabilities, ToolProfile, UsagePlacement, UsageProfile,
64};
65pub use report::{CompletionReport, WireAction, WireFeature, WireReport};
66pub use retry::{
67    RetryDirective, RetryPolicy, RetryProvider, RetrySource, parse_retry_after,
68    parse_retry_after_at, parse_retry_headers, parse_retry_headers_at, retry_async,
69};
70pub use security::ResponseLimits;
71pub use sse::{SseError, SseEvent, SseMessage, SseParser, SseUtf8Policy, TailPolicy};
72pub use stream::{
73    ModelStream, StreamError, StreamEvent, StreamReconnectPolicy, collect_stream, next_event,
74};
75pub use transform::RequestTransform;
76pub use types::{
77    ChatRequest, ChatResponse, CustomToolFormat, ImageDetail, ImagePart, ImageSource, ImageUrl,
78    Message, NativeToolCall, NativeToolCompletion, NativeToolKind, NativeToolPayload, Part,
79    ProviderState, ProviderStateFormat, Reasoning, ReasoningConfig, ReasoningEffort, ReasoningKind,
80    ReasoningMode, ReasoningSummary, ResponseFormat, ResponseMetadata, Role, ScopedToolDeclaration,
81    ServerTool, ServerToolItem, ServerToolState, ToolCall, ToolChoice, ToolDeclaration, ToolResult,
82    ToolResultPart, ToolSpec, Usage, validate_tool_declarations,
83};