Skip to main content

Crate typesafe

Crate typesafe 

Source
Expand description

Rust client for the TypeSafe AI System One API.

Send a state and a map of typed questions — Noul (yes/no probability), Choice (one of N labels) and Score (ordered levels) — and get typed answers back.

Behaviour follows the official Python SDK (typesafe-sdk): the same environment variables, defaults, retry semantics, error classification and forward-compatible decoding.

Enable the blocking feature for a synchronous client in blocking, and reqwest-client to supply your own reqwest::Client.

Re-exports§

pub use error::ApiError;
pub use error::ApiErrorKind;
pub use error::Error;
pub use error::ResponseValidationError;
pub use error::Result;
pub use question::Choice;
pub use question::Noul;
pub use question::NoulCriteria;
pub use question::Question;
pub use question::Questions;
pub use question::Score;
pub use response::Answer;
pub use response::ChoiceAnswer;
pub use response::ListModelsResponse;
pub use response::ModelMetadata;
pub use response::NoulAnswer;
pub use response::ResponseMeta;
pub use response::ScoreAnswer;
pub use response::SystemOneResponse;
pub use response::Usage;
pub use retry::RetryPolicy;
pub use http;
pub use serde_json;

Modules§

blocking
Synchronous client (feature blocking). Each client owns a private current-thread Tokio runtime; do not call it from inside an async context.
constants
Environment-variable names, defaults and protocol constants.
error
Error types.
question
Typed questions: Noul, Choice and Score.
response
Answers and response metadata.
retry
Retry configuration. Semantics match the Python SDK’s RetryPolicy (Tenacity-based): exponential backoff with subtractive jitter, Retry-After/retry-after-ms support, a max retry count, and a total time budget that stops before a sleep that would exceed it.

Macros§

json
Re-exported so callers can build structured instructions/state without adding a dependency. Construct a serde_json::Value from a JSON literal.

Structs§

Client
TypeSafe API client. Cheap to clone; clones share the connection pool.
ClientBuilder
Builder for Client. Explicit settings win over environment variables; empty or whitespace-only environment values are ignored.
ListModelsRequest
A pending GET /v1/models.
Models
The Models resource.
SystemOneRequest
A pending POST /v1/systemone. Configure it, then .await it (or call send).