pub struct ClientBuilder { /* private fields */ }Expand description
Builder for Client. Explicit settings win over environment variables; empty or
whitespace-only environment values are ignored.
Its Debug output hides the API key and any credential-bearing header.
Implementations§
Source§impl ClientBuilder
impl ClientBuilder
Sourcepub fn api_key(self, key: impl Into<String>) -> Self
pub fn api_key(self, key: impl Into<String>) -> Self
API key (else TYPESAFE_API_KEY). Surrounding whitespace is trimmed; an empty key, or one
with whitespace, control or non-ASCII characters inside it, is rejected by build.
Sourcepub fn base_url(self, url: impl Into<String>) -> Self
pub fn base_url(self, url: impl Into<String>) -> Self
API root (else TYPESAFE_BASE_URL, else https://api.typesafe.ai).
Sourcepub fn model(self, model: impl Into<String>) -> Self
pub fn model(self, model: impl Into<String>) -> Self
Default model (else TYPESAFE_DEFAULT_MODEL, else jev-latest).
Sourcepub fn retry(self, policy: RetryPolicy) -> Self
pub fn retry(self, policy: RetryPolicy) -> Self
Default retry policy.
Sourcepub fn header(self, name: HeaderName, value: HeaderValue) -> Self
pub fn header(self, name: HeaderName, value: HeaderValue) -> Self
Extra header sent with every request. Authentication and SDK identification headers cannot be overridden.
Sourcepub fn record(self, dir: impl Into<PathBuf>) -> Self
pub fn record(self, dir: impl Into<PathBuf>) -> Self
Write each successful System One response to <dir>/<key>.json (else TYPESAFE_RECORD).
The directory is created if needed. See cassette.
Sourcepub fn replay(self, dir: impl Into<PathBuf>) -> Self
pub fn replay(self, dir: impl Into<PathBuf>) -> Self
Answer System One calls from <dir>/<key>.json instead of the network (else
TYPESAFE_REPLAY); no API key is needed. A request that was never recorded fails with
Error::ReplayMiss. See cassette.
Sourcepub fn http_client(self, client: Client) -> Self
Available on crate feature reqwest-client only.
pub fn http_client(self, client: Client) -> Self
reqwest-client only.Use your own reqwest::Client (proxies, TLS, connection pools…). Requires the
reqwest-client feature.
Sourcepub fn build_blocking(self) -> Result<Client>
Available on crate feature blocking only.
pub fn build_blocking(self) -> Result<Client>
blocking only.Build a blocking::Client (feature blocking).
§Errors
As for build, plus Error::Config if the runtime cannot be started.
Sourcepub fn build(self) -> Result<Client>
pub fn build(self) -> Result<Client>
Build the client.
§Errors
Error::Config if no API key is set (unless replaying) or it is malformed, the base URL
is not an http(s) URL, the timeout is zero, the retry policy is invalid, both record and
replay are set, or the record directory cannot be created. The cause, such as the
std::io::Error or the URL parse error, is the error’s source().