TypeSafe for Rust
typesafe-ai brings TypeSafe's System One evaluation API into
Rust as small, typed judgments that fit inside ordinary application code.
Send the state your application already has, ask focused questions, and combine the answers with your own rules. A request can:
- route a support case to one of your teams;
- classify content against a fixed set of labels;
- score an item along an ordered rubric;
- judge whether a condition is true and return its probability.
Why this crate
- Typed results. Noul, Choice, and Score responses deserialize into Rust enums with probabilities, distributions, confidence, and usage data.
- Sync or async. Use the default asynchronous reqwest client, or disable default features and choose the blocking ureq client without pulling in Tokio.
- One state, several judgments. Batch independent questions over shared text or structured JSON.
- Visible retries when you need them. Use
evaluatefor a simple result, or observe each failure and planned retry through a lazy iterator or stream. - Errors you can inspect. Status, headers, request IDs, original response bytes, and concrete backend errors remain available without exposing credentials in display text.
A small example
use ;
async
The model supplies a bounded judgment; your code keeps control of thresholds, routing, side effects, and the larger workflow.
See Getting started for installation, feature selection, all three primitives, and runnable examples.
Documentation
- Getting started — install the crate, choose a client, and build requests.
- Configuration and errors — timeouts, retries, custom transports, response bytes, and typed errors.
- Progress events — observe retries with a blocking iterator or asynchronous stream.
- Pull request questions — a clap CLI that applies
.ts_rules/*.jsonto PR metadata and diffs, with a GitHub Actions setup guide. - Rust API documentation — build the current reference locally with
cargo doc --open --all-features. - TypeSafe API reference and primitive guide — service behavior and question design.
License
Licensed under the Apache License, Version 2.0. See LICENSE.