A unified multi-provider LLM client for Rust — one [Connector], three
provider families, one interface.
aiface is a standalone connector crate: a single client that speaks Claude,
OpenAI, Gemini, GitHub Copilot and every OpenAI-compatible endpoint (DeepSeek,
Groq, xAI, Ollama, LM Studio, vLLM, …), with streaming chat, tool calling,
embeddings, token usage and cost tracking. It is application-agnostic — the
host app supplies anything that is its own identity, including the OS keyring
service its API keys are stored under.
- One
Connector, 30 providers — native adapters for Claude, OpenAI and Gemini, plus OpenAI-compatible endpoints (DeepSeek, Groq, xAI, Kimi, Venice, Ollama, LM Studio, vLLM, …). Swap the name passed toConnector::newto switch backends. - Streaming with mid-stream retry — automatic retry on 429/5xx/network
errors with backoff and
retry-aftersupport; a reset marker lets you discard partial text from a failed attempt. - Context-window intelligence — model catalog with context-window
discovery and
ContextWindowExceededclassification, even from ambiguous SSE error bodies. - OAuth built in — Authorization Code + PKCE, loopback redirect and Device Grant flows (RFC 7636 / 8252 / 8628), plus a GitHub Copilot device-flow adapter, with tokens stored in the OS keyring.
- Multimodal — image blocks travel inline (base64) on the message
channel;
generate_imageproduces images on the providers that offer image generation (OpenAI-shaped/images/generationssurfaces — OpenAI, xAI, Together, Venice, … — and Gemini's image models), with bytes decoded and ready to save. Chat answers that EMBED images (Gemini image models, OpenRouter-style gateways, OpenAI's Responsesimage_generationtool) surface decoded bytes onChatOutput::images/ChatStream::images. - System One decisions — typed decisions with probabilities from
decision models (TypeSafe Jev, Microsoft-Decision-1, OpenRouter's
System One route) or wrapped LLMs, under one
Connector::decidecontract (seedocs/decision.md).
use aiface::connector::Connector;
let reply = Connector::new("openai")?
.with_model("gpt-4o")
.with_temperature(0.7)
.with_api_key("sk-...")
.chat("Explain Rust ownership")
.await?;Guides for every module live in docs/:
connector (overview) · client (builder API) · decision (System One
decisions) · params (request vocabulary) · output (output types) ·
discovery (context windows) · provider (registry & keys) · error
(classification & retry).
A runnable walkthrough lives in examples/client.rs:
cargo run --example client- Rust 2024 edition (≥ 1.85)
Apache-2.0 — see LICENSE.