pub enum ProviderConfig {
OpenAI {
api_key: Option<String>,
api_endpoint: Option<String>,
auth: Option<ProviderAuth>,
},
Anthropic {
api_key: Option<String>,
api_endpoint: Option<String>,
access_token: Option<String>,
auth: Option<ProviderAuth>,
},
Gemini {
api_key: Option<String>,
api_endpoint: Option<String>,
auth: Option<ProviderAuth>,
},
Custom {
api_key: Option<String>,
api_endpoint: String,
auth: Option<ProviderAuth>,
},
Stakpak {
api_key: Option<String>,
api_endpoint: Option<String>,
auth: Option<ProviderAuth>,
},
Bedrock {
region: String,
profile_name: Option<String>,
},
}Expand description
Unified provider configuration enum
All provider configurations are stored in a HashMap<String, ProviderConfig>
where the key is the provider name and becomes the model prefix for routing.
§Provider Key = Model Prefix
The key used in the HashMap becomes the prefix used in model names:
- Config key:
providers.offline - Model usage:
offline/llama3 - Routing: finds
offlineprovider, sendsllama3to API
§Example TOML
[profiles.myprofile.providers.openai]
type = "openai"
[profiles.myprofile.providers.openai.auth]
type = "api"
key = "sk-..."
[profiles.myprofile.providers.anthropic]
type = "anthropic"
[profiles.myprofile.providers.anthropic.auth]
type = "oauth"
access = "eyJ..."
refresh = "eyJ..."
expires = 1735600000000
name = "Claude Max"
[profiles.myprofile.providers.offline]
type = "custom"
api_endpoint = "http://localhost:11434/v1"Variants§
OpenAI
OpenAI provider configuration
Fields
auth: Option<ProviderAuth>Authentication credentials (preferred over api_key)
Anthropic
Anthropic provider configuration
Fields
auth: Option<ProviderAuth>Authentication credentials (preferred over api_key/access_token)
Gemini
Google Gemini provider configuration
Fields
auth: Option<ProviderAuth>Authentication credentials (preferred over api_key)
Custom
Custom OpenAI-compatible provider (Ollama, vLLM, etc.)
The provider key in the config becomes the model prefix.
For example, if configured as providers.offline, use models as:
offline/llama3- passesllama3to the APIoffline/anthropic/claude-opus- passesanthropic/claude-opusto the API
§Example TOML
[profiles.myprofile.providers.offline]
type = "custom"
api_endpoint = "http://localhost:11434/v1"
# Then use models as:
model = "offline/llama3"Fields
api_endpoint: StringAPI endpoint URL (required for custom providers) Use the base URL as required by your provider (e.g., “http://localhost:11434/v1”)
auth: Option<ProviderAuth>Authentication credentials (preferred over api_key)
Stakpak
Stakpak provider configuration
Routes inference through Stakpak’s unified API, which provides:
- Access to multiple LLM providers via a single endpoint
- Usage tracking and billing
- Session management and checkpoints
§Example TOML
[profiles.myprofile.providers.stakpak]
type = "stakpak"
api_endpoint = "https://apiv2.stakpak.dev" # optional, this is the default
[profiles.myprofile.providers.stakpak.auth]
type = "api"
key = "your-stakpak-api-key"
# Then use models as:
model = "stakpak/anthropic/claude-sonnet-4-5-20250929"Fields
api_key: Option<String>Legacy API key field (prefer auth field)
Note: This field is optional when using auth
auth: Option<ProviderAuth>Authentication credentials (preferred over api_key)
Bedrock
AWS Bedrock provider configuration
Uses AWS credential chain for authentication (no API key needed). Supports env vars, shared credentials, SSO, and instance roles.
§Example TOML
[profiles.myprofile.providers.amazon-bedrock]
type = "amazon-bedrock"
region = "us-east-1"
profile_name = "my-aws-profile" # optional
# Then use models as (friendly aliases work):
model = "amazon-bedrock/claude-sonnet-4-5"Implementations§
Source§impl ProviderConfig
impl ProviderConfig
Sourcepub fn provider_type(&self) -> &'static str
pub fn provider_type(&self) -> &'static str
Get the provider type name
Sourcepub fn api_key(&self) -> Option<&str>
pub fn api_key(&self) -> Option<&str>
Get the API key if set (checks auth field first, then legacy api_key)
Sourcepub fn get_auth(&self) -> Option<ProviderAuth>
pub fn get_auth(&self) -> Option<ProviderAuth>
Get resolved authentication credentials.
Resolution order:
authfield (preferred)- Legacy
api_keyfield (converted to ProviderAuth::Api) - Legacy
access_tokenfield for Anthropic (converted to ProviderAuth with access token)
Sourcepub fn set_auth(&mut self, auth: ProviderAuth)
pub fn set_auth(&mut self, auth: ProviderAuth)
Set authentication credentials on this provider config.
Also clears any legacy credential fields (api_key, access_token)
so they don’t shadow the new auth field on future reads.
Sourcepub fn clear_auth(&mut self)
pub fn clear_auth(&mut self)
Clear authentication credentials from this provider config.
Clears both the auth field and any legacy credential fields
(api_key, access_token) to ensure credentials are fully removed.
Sourcepub fn api_endpoint(&self) -> Option<&str>
pub fn api_endpoint(&self) -> Option<&str>
Get the API endpoint if set
Sourcepub fn set_api_endpoint(&mut self, endpoint: Option<String>)
pub fn set_api_endpoint(&mut self, endpoint: Option<String>)
Set the API endpoint for providers that support it.
For Custom, None is ignored because custom providers require an endpoint.
For Bedrock, this is a no-op.
Sourcepub fn access_token(&self) -> Option<&str>
pub fn access_token(&self) -> Option<&str>
Get the access token (Anthropic only)
Checks the auth field first for OAuth access token, then falls back
to the legacy access_token field.
Sourcepub fn openai(api_key: Option<String>) -> Self
pub fn openai(api_key: Option<String>) -> Self
Create an OpenAI provider config (legacy, uses api_key field)
Sourcepub fn openai_with_auth(auth: ProviderAuth) -> Self
pub fn openai_with_auth(auth: ProviderAuth) -> Self
Create an OpenAI provider config with auth
Sourcepub fn anthropic(api_key: Option<String>, access_token: Option<String>) -> Self
pub fn anthropic(api_key: Option<String>, access_token: Option<String>) -> Self
Create an Anthropic provider config (legacy, uses api_key/access_token fields)
Sourcepub fn anthropic_with_auth(auth: ProviderAuth) -> Self
pub fn anthropic_with_auth(auth: ProviderAuth) -> Self
Create an Anthropic provider config with auth
Sourcepub fn gemini(api_key: Option<String>) -> Self
pub fn gemini(api_key: Option<String>) -> Self
Create a Gemini provider config (legacy, uses api_key field)
Sourcepub fn gemini_with_auth(auth: ProviderAuth) -> Self
pub fn gemini_with_auth(auth: ProviderAuth) -> Self
Create a Gemini provider config with auth
Sourcepub fn custom(api_endpoint: String, api_key: Option<String>) -> Self
pub fn custom(api_endpoint: String, api_key: Option<String>) -> Self
Create a custom provider config (legacy, uses api_key field)
Sourcepub fn custom_with_auth(api_endpoint: String, auth: ProviderAuth) -> Self
pub fn custom_with_auth(api_endpoint: String, auth: ProviderAuth) -> Self
Create a custom provider config with auth
Sourcepub fn stakpak(api_key: String, api_endpoint: Option<String>) -> Self
pub fn stakpak(api_key: String, api_endpoint: Option<String>) -> Self
Create a Stakpak provider config (legacy, uses api_key field)
Sourcepub fn stakpak_with_auth(
auth: ProviderAuth,
api_endpoint: Option<String>,
) -> Self
pub fn stakpak_with_auth( auth: ProviderAuth, api_endpoint: Option<String>, ) -> Self
Create a Stakpak provider config with auth
Sourcepub fn bedrock(region: String, profile_name: Option<String>) -> Self
pub fn bedrock(region: String, profile_name: Option<String>) -> Self
Create a Bedrock provider config
Sourcepub fn profile_name(&self) -> Option<&str>
pub fn profile_name(&self) -> Option<&str>
Get the AWS profile name (Bedrock only)
Sourcepub fn empty_for_provider(provider_name: &str) -> Option<Self>
pub fn empty_for_provider(provider_name: &str) -> Option<Self>
Create an empty provider config for a given provider name.
Used during migration when we need to create a provider config to attach auth credentials to.
Trait Implementations§
Source§impl Clone for ProviderConfig
impl Clone for ProviderConfig
Source§fn clone(&self) -> ProviderConfig
fn clone(&self) -> ProviderConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more