Auth Profile • Rust AI Agent SDK
AuthProfile: Authentication profile for an LLM provider.
AuthProfile
Defined in the failover module.
Rust AI Agent SDK
Authentication profile for an LLM provider.
Fields
| Name | Type | Description |
|---|---|---|
name | String | Profile name for identification |
provider | String | Provider name (openai, anthropic, google, etc.) |
api_key | String | API key for authentication |
base_url | Option<String> | Optional base URL override |
model | Option<String> | Default model for this profile |
priority | i32 | Priority for failover (lower = higher priority) |
rate_limit_rpm | Option<u32> | Requests per minute limit |
rate_limit_tpm | Option<u32> | Tokens per minute limit |
status | ProviderStatus | Current status |
last_error | Option<String> | Last error message |
last_error_time | Option<Instant> | Last error timestamp |
cooldown_until | Option<Instant> | Cooldown until timestamp |
metadata | HashMap<String | Additional provider-specific configuration |
Methods
new
fn new(name: impl Into<String>, provider: impl Into<String>, api_key: impl Into<String>) -> SelfCreate a new auth profile.
Parameters:
| Name | Type |
|---|---|
name | impl Into<String> |
provider | impl Into<String> |
api_key | impl Into<String> |
base_url
fn base_url(mut self, url: impl Into<String>) -> SelfSet base URL
Parameters:
| Name | Type |
|---|---|
url | impl Into<String> |
model
fn model(mut self, model: impl Into<String>) -> SelfSet default model
Parameters:
| Name | Type |
|---|---|
model | impl Into<String> |
priority
fn priority(mut self, priority: i32) -> SelfSet priority (lower = higher priority)
Parameters:
| Name | Type |
|---|---|
priority | i32 |
rate_limit_rpm
fn rate_limit_rpm(mut self, rpm: u32) -> SelfSet rate limit (requests per minute)
Parameters:
| Name | Type |
|---|---|
rpm | u32 |
rate_limit_tpm
fn rate_limit_tpm(mut self, tpm: u32) -> SelfSet rate limit (tokens per minute)
Parameters:
| Name | Type |
|---|---|
tpm | u32 |
metadata
fn metadata(mut self, key: impl Into<String>, value: impl Into<String>) -> SelfAdd metadata
Parameters:
| Name | Type |
|---|---|
key | impl Into<String> |
value | impl Into<String> |
is_available
fn is_available(&self) -> boolCheck if this profile is currently available.
mark_rate_limited
fn mark_rate_limited(&mut self, cooldown: Duration) -> ()Mark this profile as rate limited.
Parameters:
| Name | Type |
|---|---|
cooldown | Duration |
mark_error
fn mark_error(&mut self, error: impl Into<String>, cooldown: Duration) -> ()Mark this profile as having an error.
Parameters:
| Name | Type |
|---|---|
error | impl Into<String> |
cooldown | Duration |
reset
fn reset(&mut self) -> ()Reset this profile to available status.
Source
View on GitHubpraisonai/src/failover/mod.rs at line 59