chat-rs

Providers

The providers chat-rs ships with and how they are wired.

Every provider implements the same traits, so switching providers is a one-line change at construction time. Set the listed API-key environment variable (or call .with_api_key(...)) and select the feature flag.

ProviderFeatureAPI Key Env VarBuilder
Google GeminigeminiGEMINI_API_KEYGeminiBuilder
Anthropic ClaudeclaudeCLAUDE_API_KEYClaudeBuilder
OpenAIopenaiOPENAI_API_KEYOpenAIBuilder
DeepSeekdeepseekDEEPSEEK_API_KEYDeepSeekBuilder
CerebrascerebrasCEREBRAS_API_KEYCerebrasBuilder
OpenRouteropenrouterOPENROUTER_API_KEYOpenRouterBuilder
Hugging Face RouterhuggingfaceHF_TOKENHuggingFaceBuilder
Ollama (local)ollamaOllamaBuilder
mistral.rs (local)mistralrsMistralRsBuilder
Generic Chat Completionscompletionsdepends on serverChatCompletionsBuilder
Generic Responses APIresponsesdepends on serverResponsesBuilder

Wire crates

Providers don't reimplement the wire protocol — they wrap one of two shared wire crates:

  • chat-completions — the OpenAI Chat Completions wire. Used by Ollama, Hugging Face, Cerebras, DeepSeek, and any OpenAI-compatible server via ChatCompletionsBuilder::with_base_url(...).
  • chat-responses — the OpenAI Responses API wire. Used by chat-openai and chat-openrouter.

This means a new OpenAI-compatible provider is usually just a thin wrapper that presets a base URL and an API-key env var.

Routing

The router feature lets you dispatch across multiple providers by keyword, capability, or embedding similarity — see RouterBuilder and the examples/router directory in the repository.

On this page