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(ChatProviderCompletionProvider)來標準化向各種 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)以快速與模型互動,並具備指數退避與抖動等韌性特性。