Expand description
§AI SDK
A provider-agnostic Rust SDK for AI completions with streaming support.
Built by Stakpak 🚀
§Features
- Provider-agnostic: Unified interface for multiple AI providers (OpenAI, Anthropic, etc.)
- Streaming support: Real-time streaming responses with unified event types
- Type-safe: Strong typing with compile-time guarantees
- Zero-cost abstractions: Static dispatch for optimal performance
- Ergonomic API: Builder patterns and intuitive interfaces
§Quick Start
use stakai::{Inference, GenerateRequest, Message, Role};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Inference::new();
let request = GenerateRequest::new(
"gpt-4",
vec![Message::new(Role::User, "What is Rust?")]
);
let response = client.generate(&request).await?;
println!("Response: {}", response.text());
Ok(())
}Re-exports§
pub use client::Inference;pub use client::InferenceConfig;pub use error::Error;pub use error::Result;pub use types::AnthropicContentPartOptions;pub use types::AnthropicMessageOptions;pub use types::AnthropicOptions;pub use types::AnthropicToolOptions;pub use types::CacheContext;pub use types::CacheControl;pub use types::CacheControlValidator;pub use types::CacheWarning;pub use types::CacheWarningType;pub use types::ContentPart;pub use types::ContentPartProviderOptions;pub use types::FinishReason;pub use types::FinishReasonKind;pub use types::GenerateOptions;pub use types::GenerateRequest;pub use types::GenerateResponse;pub use types::GenerateStream;pub use types::GoogleOptions;pub use types::Headers;pub use types::ImageDetail;pub use types::InputTokenDetails;pub use types::Message;pub use types::MessageContent;pub use types::MessageProviderOptions;pub use types::OpenAIOptions;pub use types::OutputTokenDetails;pub use types::PromptCacheRetention;pub use types::ProviderOptions;pub use types::ReasoningEffort;pub use types::ReasoningSummary;pub use types::ResponseContent;pub use types::ResponseWarning;pub use types::Role;pub use types::StreamEvent;pub use types::SystemMessageMode;pub use types::ThinkingOptions;pub use types::Tool;pub use types::ToolCall;pub use types::ToolChoice;pub use types::ToolFunction;pub use types::ToolProviderOptions;pub use types::Usage;