pub struct Client { /* private fields */ }Expand description
An async client for the TypeSafe System One API.
Construct with Client::builder or Client::from_env. The client is
Clone and cheap to clone (an Arc inside), and Send + Sync.
Every method is async; there is no blocking client. Cancellation is dropping the returned future.
let client = Client::builder()
.api_key("sk-live-...")
.default_header("X-Agent-Client", "my-app")
.build()?;Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Creates a builder.
Sourcepub fn from_env() -> Result<Self, Error>
pub fn from_env() -> Result<Self, Error>
Creates a client from TYPESAFE_API_KEY (and the other
TYPESAFE_* variables), exactly like
Client::builder().build().
Sourcepub fn default_model(&self) -> &str
pub fn default_model(&self) -> &str
The configured default model.
Sourcepub fn retry_policy(&self) -> &RetryPolicy
pub fn retry_policy(&self) -> &RetryPolicy
The configured default retry policy.
Sourcepub async fn system_one(
&self,
request: SystemOneRequest,
) -> Result<SystemOneResponse, Error>
pub async fn system_one( &self, request: SystemOneRequest, ) -> Result<SystemOneResponse, Error>
Answers the questions in request about its state.
Client-side validation runs before any network I/O; failures return
Error::InvalidRequest. Retries,
per the client’s default policy, are automatic.
Sourcepub async fn system_one_with(
&self,
request: SystemOneRequest,
options: RequestOptions,
) -> Result<SystemOneResponse, Error>
pub async fn system_one_with( &self, request: SystemOneRequest, options: RequestOptions, ) -> Result<SystemOneResponse, Error>
Answers the questions in request with per-call options.
A per-call retry policy fully replaces the client’s policy for this call.
Sourcepub async fn list_models(&self) -> Result<Vec<ModelMetadata>, Error>
pub async fn list_models(&self) -> Result<Vec<ModelMetadata>, Error>
Lists the models and aliases available to the authenticated account.
Sourcepub async fn list_models_with(
&self,
options: RequestOptions,
) -> Result<Vec<ModelMetadata>, Error>
pub async fn list_models_with( &self, options: RequestOptions, ) -> Result<Vec<ModelMetadata>, Error>
Lists the models with per-call options.
A per-call retry policy fully replaces the client’s policy for this
call. extra_body has no effect here (the request has no body).