Skip to main content

AuthProfile

Defined in the failover module.
Rust AI Agent SDK Authentication profile for an LLM provider.

Fields

NameTypeDescription
nameStringProfile name for identification
providerStringProvider name (openai, anthropic, google, etc.)
api_keyStringAPI key for authentication
base_urlOption<String>Optional base URL override
modelOption<String>Default model for this profile
priorityi32Priority for failover (lower = higher priority)
rate_limit_rpmOption<u32>Requests per minute limit
rate_limit_tpmOption<u32>Tokens per minute limit
statusProviderStatusCurrent status
last_errorOption<String>Last error message
last_error_timeOption<Instant>Last error timestamp
cooldown_untilOption<Instant>Cooldown until timestamp
metadataHashMap<StringAdditional provider-specific configuration

Methods

new

fn new(name: impl Into<String>, provider: impl Into<String>, api_key: impl Into<String>) -> Self
Create a new auth profile. Parameters:
NameType
nameimpl Into&lt;String&gt;
providerimpl Into&lt;String&gt;
api_keyimpl Into&lt;String&gt;

base_url

fn base_url(mut self, url: impl Into<String>) -> Self
Set base URL Parameters:
NameType
urlimpl Into&lt;String&gt;

model

fn model(mut self, model: impl Into<String>) -> Self
Set default model Parameters:
NameType
modelimpl Into&lt;String&gt;

priority

fn priority(mut self, priority: i32) -> Self
Set priority (lower = higher priority) Parameters:
NameType
priorityi32

rate_limit_rpm

fn rate_limit_rpm(mut self, rpm: u32) -> Self
Set rate limit (requests per minute) Parameters:
NameType
rpmu32

rate_limit_tpm

fn rate_limit_tpm(mut self, tpm: u32) -> Self
Set rate limit (tokens per minute) Parameters:
NameType
tpmu32

metadata

fn metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> Self
Add metadata Parameters:
NameType
keyimpl Into&lt;String&gt;
valueimpl Into&lt;String&gt;

is_available

fn is_available(&self) -> bool
Check if this profile is currently available.

mark_rate_limited

fn mark_rate_limited(&mut self, cooldown: Duration) -> ()
Mark this profile as rate limited. Parameters:
NameType
cooldownDuration

mark_error

fn mark_error(&mut self, error: impl Into<String>, cooldown: Duration) -> ()
Mark this profile as having an error. Parameters:
NameType
errorimpl Into&lt;String&gt;
cooldownDuration

reset

fn reset(&mut self) -> ()
Reset this profile to available status.

Source

View on GitHub

praisonai/src/failover/mod.rs at line 59