aither
Unified Rust traits for building AI applications across providers
Write AI applications that work with any provider π
aither is a workspace of crates that gives you portable traits (LanguageModel, EmbeddingModel, ImageGenerator, β¦) plus thin provider bindings (aither-openai, aither-gemini, etc.). Build flows once and pick any backend that satisfies the traitsβOpenAI, Gemini, local inference, or custom vendor endpoints.
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Your App βββββΆβ aither ββββββ Providers β
β β β (this crate) β β β
β - Chat bots β β β β - openai β
β - Search β β - LanguageModel β β - anthropic β
β - Content gen β β - EmbeddingModel β β - llama.cpp β
β - Voice apps β β - ImageGenerator β β - whisper β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
Highlights
- π― Provider-agnostic traits β swap between OpenAI, Gemini, local adapters, or your own.
- β‘ Streaming-first β every
LanguageModel::respondreturns a stream ofEvents: visible text deltas, reasoning updates, and tool calls. - π§ Reasoning controls β request chain-of-thought summaries, budgets, or effort tiers without macros.
- π οΈ Tooling & structured output β JSON-schema tools, builders, and derive macros keep function calling type-safe.
- π§± No-std capable β
aither-coreruns in embedded/WASM targets and re-exports onlyalloc. - π¦ Batteries included β provider crates (
openai,gemini) plus runnable examples (cargo run --example tool_macro).
Supported Capabilities
| Capability | Trait | Description |
|---|---|---|
| Language Models | LanguageModel / Event |
Streaming chat, reasoning summaries, tool calling |
| Embeddings | EmbeddingModel |
Vectorize text for search, clustering, and RAG |
| Images | ImageGenerator |
Progressive generation + editing pipelines |
| Audio | AudioGenerator / AudioTranscriber |
TTS + speech recognition |
| Moderation | Moderation |
Policy scoring across multiple providers |
Quick Start
- Choose a provider crate (
aither-openai,aither-gemini, β¦) alongsideaitherfor the shared traits:
[]
= { = "0.1", = ["serde", "derive"] }
= "0.1"
- Instantiate the provider, then drive everything through the trait:
use ;
use OpenAI;
use StreamExt;
async
Streaming Reasoning & Thinking Budgets
Reasoning-focused models (OpenAI O-series, Gemini Flash Thinking, etc.) expose chain-of-thought summaries as Event::Reasoning items in the same stream. You can request a thinking budget or reasoning effort via Parameters.
use ;
use ;
use StreamExt;
async
Function Calling
use ;
use JsonSchema;
use Deserialize;
use Cow;
/// Get current weather for a location.
;
// Advertise the tool on the request. The model answers with an
// `Event::ToolCall`; running it and feeding the result back is the caller's
// job, or `aither-agent`'s.
let request = new
.with_tool;
The tool's description defaults to the rustdoc on its Arguments type. Override
Tool::description() to set it explicitly β a tool with neither is rejected at
registration rather than reaching the model unexplained.
Semantic Search & Multimodal
See examples/chatbot_gemini.rs, examples/chatbot_openrouter.rs, and examples/tool_macro.rs for end-to-end demos that combine embeddings, multimodal prompts, and structured outputs. Each example can be run with:
Progressive Image Generation
use ;
use StreamExt;
async
Workspace Layout
| Crate | Description |
|---|---|
aither |
Entry crate re-exporting everything from aither-core + derive macros |
aither-core |
No-std traits (LanguageModel, Event, LLMRequest, embedders, moderation, β¦) |
aither-openai |
Provider bindings for OpenAI-compatible chat, images, audio, and moderation |
aither-gemini |
Google Gemini bindings with tool looping and thinking budgets |
aither-rag |
Retrieval-Augmented Generation helper with a parallel in-memory vector DB |
aither-llama |
Local llama.cpp wrapper that statically links llama.cpp |
derive/ |
Proc-macro helpers for tool schemas (#[tool]) |
examples/ |
Runnable flows for chat, research, and tool macros |
Development
Use the same commands as CI:
To try reasoning/tooling flows locally:
# Stream reasoning with tools enabled
OPENAI_API_KEY=sk-...
# Gemini thinking-budget demo
GEMINI_API_KEY=...
License
MIT License - see LICENSE for details.