Skip to main content

Module providers

Module providers 

Source
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/completions format. 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§

ProviderInfo
Information about a supported provider for display purposes.
ProviderRuntimeOptions

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.