stakai/
lib.rs

1//! # AI SDK
2//!
3//! A provider-agnostic Rust SDK for AI completions with streaming support.
4//!
5//! Built by [Stakpak](https://stakpak.dev) 🚀
6//!
7//! ## Features
8//!
9//! - **Provider-agnostic**: Unified interface for multiple AI providers (OpenAI, Anthropic, etc.)
10//! - **Streaming support**: Real-time streaming responses with unified event types
11//! - **Type-safe**: Strong typing with compile-time guarantees
12//! - **Zero-cost abstractions**: Static dispatch for optimal performance
13//! - **Ergonomic API**: Builder patterns and intuitive interfaces
14//!
15//! ## Quick Start
16//!
17//! ```rust,no_run
18//! use stakai::{Inference, GenerateRequest, Message, Role};
19//!
20//! #[tokio::main]
21//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
22//!     let client = Inference::new();
23//!
24//!     let request = GenerateRequest::new(
25//!         "gpt-4",
26//!         vec![Message::new(Role::User, "What is Rust?")]
27//!     );
28//!
29//!     let response = client.generate(&request).await?;
30//!     println!("Response: {}", response.text());
31//!
32//!     Ok(())
33//! }
34//! ```
35
36pub mod client;
37pub mod error;
38pub mod provider;
39pub mod providers;
40pub mod registry;
41pub mod types;
42
43#[cfg(feature = "tracing")]
44pub mod tracing;
45
46// Re-export commonly used types
47pub use client::{Inference, InferenceConfig};
48pub use error::{Error, Result};
49pub use types::{
50    // Message types
51    AnthropicContentPartOptions,
52    AnthropicMessageOptions,
53    // Request types
54    AnthropicOptions,
55    // Options types
56    AnthropicToolOptions,
57    // Cache control types
58    CacheContext,
59    CacheControl,
60    CacheControlValidator,
61    CacheWarning,
62    CacheWarningType,
63    ContentPart,
64    ContentPartProviderOptions,
65    // Response types
66    FinishReason,
67    FinishReasonKind,
68    GenerateOptions,
69    GenerateRequest,
70    GenerateResponse,
71    GenerateStream,
72    GoogleOptions,
73    Headers,
74    ImageDetail,
75    InputTokenDetails,
76    Message,
77    MessageContent,
78    MessageProviderOptions,
79    OpenAIOptions,
80    OutputTokenDetails,
81    PromptCacheRetention,
82    ProviderOptions,
83    ReasoningEffort,
84    ReasoningSummary,
85    ResponseContent,
86    ResponseWarning,
87    Role,
88    StreamEvent,
89    SystemMessageMode,
90    ThinkingOptions,
91    Tool,
92    ToolCall,
93    ToolChoice,
94    ToolFunction,
95    ToolProviderOptions,
96    Usage,
97};
98
99/// Prelude module for convenient imports
100pub mod prelude {
101    pub use crate::client::Inference;
102    pub use crate::error::{Error, Result};
103    pub use crate::provider::Provider;
104    pub use crate::types::*;
105}