Expand description
Provider subsystem for model inference backends.
This module implements the factory pattern for AI model providers. Each provider
implements the Provider trait defined in traits, and is registered in the
factory function create_provider by its canonical string key (e.g., "openai",
"anthropic", "ollama", "gemini"). Provider aliases are resolved internally
so that user-facing keys remain stable.
The subsystem supports resilient multi-provider configurations through the
ReliableProvider wrapper, which handles fallback
chains and automatic retry. Model routing across providers is available via
create_routed_provider.
§Extension
To add a new provider, implement Provider in a new submodule and register it
in create_provider_with_url. See AGENTS.md §7.1 for the full change playbook.
Re-exports§
pub use traits::ChatMessage;pub use traits::ChatRequest;pub use traits::ChatResponse;pub use traits::ConversationMessage;pub use traits::Provider;pub use traits::ProviderCapabilityError;pub use traits::ToolCall;pub use traits::ToolResultMessage;
Modules§
- anthropic
- azure_
openai - bedrock
- AWS Bedrock provider using the Converse API.
- claude_
code - Claude Code headless CLI provider.
- compatible
- Generic OpenAI-compatible provider.
Most LLM APIs follow the same
/v1/chat/completionsformat. This module provides a single implementation that works for all of them. - copilot
- GitHub Copilot provider with OAuth device-flow authentication.
- gemini
- Google Gemini provider with support for:
- gemini_
cli - Gemini CLI subprocess provider.
- kilocli
- KiloCLI subprocess provider.
- ollama
- openai
- openai_
codex - openrouter
- reliable
- router
- telnyx
- Telnyx AI inference provider.
- traits
Structs§
- Provider
Info - Information about a supported provider for display purposes.
- Provider
Runtime Options
Functions§
- api_
error - Build a sanitized provider error from a failed HTTP response.
- create_
provider - Factory: create the right provider from config (without custom URL)
- create_
provider_ with_ options - Factory: create provider with runtime options (auth profile override, state dir).
- create_
provider_ with_ url - Factory: create the right provider from config with optional custom base URL
- create_
resilient_ provider - Create provider chain with retry and fallback behavior.
- create_
resilient_ provider_ with_ options - Create provider chain with retry/fallback behavior and auth runtime options.
- create_
routed_ provider - Create a RouterProvider if model routes are configured, otherwise return a standard resilient provider. The router wraps individual providers per route, each with its own retry/fallback chain.
- create_
routed_ provider_ with_ options - Create a routed provider using explicit runtime options.
- list_
providers - Return the list of all known providers for display in
construct providers list. - provider_
runtime_ options_ from_ config - sanitize_
api_ error - Sanitize API error text by scrubbing secrets and truncating length.
- scrub_
secret_ patterns - Scrub known secret-like token prefixes from provider error strings.