jev-sdk
An unofficial Rust client for the TypeSafe AI System One API.
Jev is a System One model: instead of generating text, it evaluates typed questions against a state and returns structured decisions with calibrated probabilities and confidence scores — in ~70–500ms. Think of it as a frontier-intelligence function call: unstructured state in, typed probabilistic decisions out. It can't hallucinate schema violations, because the possible outputs are defined in advance.
Features
- All three question primitives: Choice, Score, Noul — mixable in a single parallel call
- Typed answers with full probability distributions and confidence
- Async client built on
reqwest(rustls, no OpenSSL) - Config via environment variables or a builder
- Automatic retries with exponential backoff +
Retry-Afterfor429/529/connection failures - Structured error types for auth, validation, and rate-limit failures
Install
[]
= "0.1"
= { = "1", = ["macros", "rt-multi-thread"] }
Quick start
Get an API key from the dashboard and export it:
use ;
async
Run the included version against the live API:
TYPESAFE_API_KEY=apikey_...
Question types
| Type | Purpose | Answer |
|---|---|---|
Noul |
Is this statement true? | noul: probability of "yes", 0–1 |
Choice |
Pick one option from a set | choice, probabilities, confidence |
Score |
Rate against ordered levels | score (probability-weighted), legend, probabilities, confidence |
- State can be a string or any serializable structure (objects, arrays — chat logs, records, application state).
- Instructions accept strings or structured JSON.
- Choice criteria map option → optional description (
Choice::optionsfor bare names). - Noul criteria optionally describe what "yes" and "no" mean.
- Ask many questions in one call: they're evaluated in parallel, and adding more barely changes latency.
use ;
options; // no descriptions
new.criteria;
Using the answers
SystemOneResponse.answers is keyed by your question ids. Typed accessors
return Options so you can't mix up question types:
# let response: SystemOneResponse = todo!;
if let Some = response.choice
for in response.nouls
The model never makes type errors; every Choice/Score answer also carries a
calibrated confidence you can gate automation on.
Configuration
| Setting | Environment variable | Default |
|---|---|---|
| API key | TYPESAFE_API_KEY |
— (required) |
| Model | TYPESAFE_DEFAULT_MODEL |
jev-latest |
| Base URL | TYPESAFE_BASE_URL |
https://api.typesafe.ai |
Explicit builder options take precedence over environment variables:
use Duration;
use ;
let client = builder
.api_key
.model
.timeout
.retry // or RetryPolicy::none()
.build?;
// Per-call model override:
// client.system_one_with_model("jev-preview", state, questions).await?;
List available models with client.list_models().await?.
Errors
use Error;
match client.system_one.await
Security
The client is hardened by default:
- Credential protection — the API key is stored in a sensitive
HeaderValueand redacted from allDebugoutput; keys containing header control characters are rejected (no CRLF injection). - TLS-only transport — base URLs must use HTTPS; plain HTTP is accepted only for loopback hosts (local testing). TLS uses rustls with certificate verification; the crate never exposes a way to disable it.
- No redirects — the built-in HTTP client never follows redirects, so the
Authorizationheader cannot be forwarded to an unexpected host. - Bounded memory — response bodies are size-capped (16 MiB success / 64 KiB error) and read incrementally, so a hostile or buggy endpoint cannot exhaust memory. Automatic decompression is not enabled (no gzip bombs).
- Bounded waits — retries use saturating exponential backoff with jitter;
server
Retry-Afterhints are honored but capped at 60s. - Dependencies — minimal, mainstream crates only (
reqwest,serde,serde_json,indexmap,thiserror,tokio), vetted withcargo audit.
Supplying your own reqwest client via ClientBuilder::http_client
transfers responsibility for transport hardening (TLS verification, redirect
policy, timeouts) to you.
Testing
TYPESAFE_API_KEY=...
Notes
- This crate is async (tokio). There is no blocking façade yet.
- MSRV: 1.75.
Links
License
Dual-licensed under MIT or Apache-2.0, at your option.