#[non_exhaustive]pub struct ClientConfig {
pub api_key: String,
pub base_url: String,
pub default_model: String,
pub timeout: Duration,
pub retry: RetryPolicy,
pub http_client: Option<Client>,
}Expand description
Configuration for constructing a TypeSafeClient.
All fields are public for inspection and mutation, but the struct is
#[non_exhaustive], so external crates must use ClientConfig::new
or ClientConfig::default plus the builder methods to construct
configurations.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.api_key: StringAPI key for authentication.
Set this directly or use TypeSafeClient::from_env to read it
from the TYPESAFE_API_KEY environment variable.
base_url: StringAPI root. Defaults to https://api.typesafe.ai.
A base path is supported and preserved: e.g. https://example.com/api
produces endpoints like https://example.com/api/v1/systemone.
Credentials, query parameters, and fragments are rejected.
default_model: StringDefault model. Defaults to jev-latest.
timeout: DurationPer-attempt timeout. Defaults to 10 seconds.
retry: RetryPolicyRetry policy. Defaults to 2 retries with exponential backoff + jitter.
http_client: Option<Client>Custom reqwest::Client to use for HTTP requests. If None, a new
client is built from the other config fields. This allows sharing a
connection pool or using a custom TLS configuration.
Implementations§
Source§impl ClientConfig
impl ClientConfig
Sourcepub fn new(api_key: impl Into<String>) -> Self
pub fn new(api_key: impl Into<String>) -> Self
Create a new ClientConfig with the given API key and all other
fields set to their defaults.
Use the .with_*() methods to override individual fields.
Sourcepub fn with_api_key(self, api_key: impl Into<String>) -> Self
pub fn with_api_key(self, api_key: impl Into<String>) -> Self
Set the API key.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> Self
pub fn with_base_url(self, base_url: impl Into<String>) -> Self
Set the base URL.
Sourcepub fn with_default_model(self, default_model: impl Into<String>) -> Self
pub fn with_default_model(self, default_model: impl Into<String>) -> Self
Set the default model.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Set the per-attempt timeout.
This is the timeout for a single HTTP request, not the total time
across all retries. The first attempt always uses the full configured
timeout; subsequent attempts are capped at the remaining retry budget
(if set). See RetryPolicy::budget.
Sourcepub fn with_retry(self, retry: RetryPolicy) -> Self
pub fn with_retry(self, retry: RetryPolicy) -> Self
Set the retry policy.
Sourcepub fn with_http_client(self, client: HttpClient) -> Self
pub fn with_http_client(self, client: HttpClient) -> Self
Provide a custom reqwest::Client for HTTP requests. If not set, the
client builds one from the other config fields (timeout, default
headers). Use this to share a connection pool or apply custom TLS
settings.
The client is used as-is, so the caller controls redirect behavior. The SDK’s default client disables redirects to prevent POST replay via 307/308; a custom client that follows redirects does not have this protection.
Trait Implementations§
Source§impl Clone for ClientConfig
impl Clone for ClientConfig
Source§impl Debug for ClientConfig
impl Debug for ClientConfig
Source§impl Default for ClientConfig
impl Default for ClientConfig
Source§fn default() -> Self
fn default() -> Self
Create a ClientConfig with all fields at their defaults.
Note: api_key defaults to an empty string, which will cause
TypeSafeClient::from_config to return an
Authentication error on the first
request. Use ClientConfig::new or set api_key explicitly
before constructing a client.