pub struct ClientBuilder { /* private fields */ }Expand description
Build an async client for the SystemOne API.
Settings resolve in priority order: explicit builder value →
OPENKIND_* environment variable → TYPESAFE_* environment variable
(for drop-in parity with the Python SDK) → SDK default. The API key is
required unless allow_unauthenticated is
selected; everything else has a default. Cloudflare mode selects its own
account URL and typesafe/jev model unless overridden explicitly.
§Examples
use openkind_client::Client;
// Hosted TypeSafe API (default base URL).
let client = Client::builder().api_key("sk-...").build()?;
// Local daemon.
let local = Client::builder()
.api_key("dev-key")
.base_url("http://127.0.0.1:18080")
.build()?;Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn api_key(self, api_key: impl Into<String>) -> Self
pub fn api_key(self, api_key: impl Into<String>) -> Self
Bearer API key. Falls back to OPENKIND_API_KEY, then
TYPESAFE_API_KEY, when unset.
Sourcepub fn allow_unauthenticated(self) -> Self
pub fn allow_unauthenticated(self) -> Self
Allow a missing API key when connecting to an unauthenticated daemon. Supplied and environment keys still resolve and validate normally.
Sourcepub fn base_url(self, base_url: impl Into<String>) -> Self
pub fn base_url(self, base_url: impl Into<String>) -> Self
API base URL, e.g. http://127.0.0.1:18080. Falls back to
OPENKIND_BASE_URL, then TYPESAFE_BASE_URL, then
DEFAULT_BASE_URL.
Sourcepub fn cloudflare_account(self, account_id: impl Into<String>) -> Self
pub fn cloudflare_account(self, account_id: impl Into<String>) -> Self
Sourcepub fn default_model(self, model: impl Into<String>) -> Self
pub fn default_model(self, model: impl Into<String>) -> Self
Model alias used by Client::system_one when the request does not
name one. Falls back to OPENKIND_DEFAULT_MODEL, then
TYPESAFE_DEFAULT_MODEL, then DEFAULT_MODEL.
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
TCP connect timeout. Unset by default.
Sourcepub fn retry(self, retry: RetryPolicy) -> Self
pub fn retry(self, retry: RetryPolicy) -> Self
Retry behavior. Defaults to RetryPolicy::default.
Sourcepub fn header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn header(self, name: HeaderName, value: HeaderValue) -> Self
A header sent with every request.
Sourcepub fn http_client(self, client: Client) -> Self
pub fn http_client(self, client: Client) -> Self
Supply a preconfigured reqwest::Client (connection pooling, proxy,
TLS settings). Default headers and timeouts are still applied
per-request by this SDK.