aither
Providing unified trait abstractions for AI models
Write AI applications that work with any provider π
Unified trait abstractions for AI models in Rust. Switch between OpenAI, Anthropic, local models, and more without changing your application logic.
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Your App βββββΆβ aither ββββββ Providers β
β β β (this crate) β β β
β - Chat bots β β β β - openai β
β - Search β β - LanguageModel β β - anthropic β
β - Content gen β β - EmbeddingModel β β - llama.cpp β
β - Voice apps β β - ImageGenerator β β - whisper β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
Features
- π― Provider Agnostic - One interface, multiple providers
- β‘ Async Native - Built with
async/awaitand streaming - π No-std Compatible - Works in embedded and WASM environments
- π οΈ Function Calling - Structured tool integration with JSON schemas
- πΈ Multimodal - Text, images, embeddings, and audio support
- π Type Safe - Leverage Rust's type system for AI applications
Supported Capabilities
| Capability | Trait | Description |
|---|---|---|
| Language Models | LanguageModel |
Text generation, conversations, streaming |
| Text Streaming | TextStream |
Unified interface for streaming text responses |
| Embeddings | EmbeddingModel |
Convert text to vectors for semantic search |
| Image Generation | ImageGenerator |
Create images with progressive quality |
| Text-to-Speech | AudioGenerator |
Generate speech audio from text |
| Speech-to-Text | AudioTranscriber |
Transcribe audio to text |
| Content Moderation | Moderation |
Detect policy violations |
Quick Start
[]
= "0.0.1"
Basic Chat Bot
use ;
use StreamExt;
async
Working with Text Streams
The TextStream trait provides a unified interface for streaming text responses from language models. It implements both Stream for chunk-by-chunk processing and IntoFuture for collecting the complete response.
use ;
use StreamExt;
// Process text as it streams in
async
// Collect complete response using IntoFuture
async
// Generic function that works with any TextStream
async
Function Calling
use ;
use ;
use JsonSchema;
;
async
Semantic Search
use EmbeddingModel;
async
Progressive Image Generation
use ;
use StreamExt;
async
License
MIT License - see LICENSE for details.