graniet/llm
A powerful Rust library and CLI tool to unify and orchestrate multiple LLM, Agent and voice backends (OpenAI, Claude, Gemini, Ollama, ElevenLabs...) with a single, extensible API. Build, chain, evaluate, and serve complex multi-step AI workflows — including speech-to-text, text-to-speech, completions, vision, and reasoning.
What it solves
它提供一个统一的 Rust 库,让开发者能够与多个 LLM 提供商(如 OpenAI、Anthropic、Google、Ollama)交互,而无需为每个提供商编写专属代码。它简化了在模型之间切换或将不同后端组合成单一工作流的过程。
How it works
该库使用构建者模式和统一的 trait(ChatProvider 与 CompletionProvider)来标准化向各种 AI 后端发送请求的方式。开发者可以通过单一 API 配置模型、temperature 和 token 数量。它还支持创建多步骤链,在每一步使用不同的后端,并能将这些链以 OpenAI 标准格式提供为 REST API。
Who it’s for
想在应用中集成多个 AI 模型,同时保持代码库干净、与提供商无关的 Rust 开发者。
Highlights
- Multi-backend support:支持 OpenAI、Anthropic、Ollama、DeepSeek、xAI、Phind、Groq、Google、Cohere、Mistral、Hugging Face 与 ElevenLabs。
- Advanced Orchestration:支持多步骤链、具共享记忆的响应式代理,以及并行评估多个提供商以选出最佳响应。
- Rich Feature Set:内置视觉、推理、结构化 JSON 输出,以及语音转文字/文字转语音功能。
- Developer Tooling:提供命令行界面(CLI)以快速与模型交互,并具备指数回退与抖动等弹性特性。