QAI SDK
A modular, type-safe Rust SDK for AI providers. One unified API across OpenAI, Anthropic Claude, Google Gemini, DeepSeek, xAI Grok, and any OpenAI-compatible endpoint.
Features
| Capability | OpenAI | Anthropic | DeepSeek | xAI | Compatible | |
|---|---|---|---|---|---|---|
| Chat / Language Model | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Streaming | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Tool Calling | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Vision / Multimodal | ✅ | ✅ | ✅ | — | — | — |
| Embeddings | ✅ | — | ✅ | — | — | — |
| Image Generation | ✅ | — | ✅ | — | — | — |
| Speech (TTS) | ✅ | — | — | — | — | — |
| Transcription (STT) | ✅ | — | — | — | — | — |
| Text Completion | ✅ | — | — | — | — | — |
| Responses API | ✅ | — | — | — | — | — |
Quick Start
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Or pick individual providers:
[]
= "0.1"
= "0.1"
= "0.1"
Basic Usage
use *;
async
Streaming
use *;
use StreamExt;
let model = provider.chat;
let mut stream = model.generate_stream.await?;
while let Some = stream.next.await
Switch Providers in One Line
// OpenAI
let provider = create_openai;
// Anthropic
let provider = create_anthropic;
// Google Gemini
let provider = create_google;
// DeepSeek
let provider = create_deepseek;
// xAI Grok
let provider = create_xai;
// Any OpenAI-compatible API
let provider = create_openai_compatible;
Architecture
qai-sdk (umbrella re-export crate)
├── qai-core — Core traits: LanguageModel, EmbeddingModel, ImageModel, etc.
├── qai-openai — OpenAI (GPT, DALL-E, Whisper, TTS, Responses API)
├── qai-anthropic — Anthropic (Claude)
├── qai-google — Google (Gemini)
├── qai-deepseek — DeepSeek (via OpenAI-compatible)
├── qai-xai — xAI (Grok, via OpenAI-compatible)
└── qai-openai-compatible — Any OpenAI-compatible endpoint
Examples
See the examples/ directory for 17 comprehensive examples covering:
- Basic chat, streaming, and multimodal conversations
- Tool calling / function calling
- Embeddings, image generation, speech, and transcription
- OpenAI Responses API
- Error handling patterns
- Provider factory pattern
- OpenAI-compatible endpoints (Ollama, LM Studio, etc.)
Run an example:
# Fill in your API keys
Environment Variables
| Variable | Provider |
|---|---|
OPENAI_API_KEY |
OpenAI |
ANTHROPIC_API_KEY |
Anthropic |
GOOGLE_API_KEY |
Google Gemini |
DEEPSEEK_API_KEY |
DeepSeek |
XAI_API_KEY |
xAI |
Contributing
See CONTRIBUTING.md for guidelines.
License
Licensed under either of:
at your option.
Author
Keyvan Arasteh — @keyvanarasteh