Skip to main content

Crate jev_sdk

Crate jev_sdk 

Source
Expand description

§jev-sdk

A 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 — fast enough to sit inside ordinary code paths.

§Quick start

use jev_sdk::{Choice, Noul, Question, Score, TypeSafeClient};

// Reads TYPESAFE_API_KEY from the environment.
let client = TypeSafeClient::from_env()?;

let ticket = "Hi, I've been trying to connect my Stripe account for 3 days \
              and it keeps failing. I'm losing sales. Please help ASAP.";

let response = client
    .system_one(
        ticket,
        [
            (
                "department",
                Question::from(Choice::new(
                    "Which team should handle this",
                    [
                        ("billing", Some("Payment or subscription issues")),
                        ("technical", Some("Bugs or integration problems")),
                        ("sales", Some("Pricing or account questions")),
                    ],
                )),
            ),
            (
                "frustration",
                Question::from(Score::new(
                    "How frustrated the customer appears",
                    ["Calm, just stating facts", "Frustrated but civil", "Very angry"],
                )),
            ),
            (
                "is_urgent",
                Question::from(Noul::new("The message conveys urgency or time-sensitivity")),
            ),
        ],
    )
    .await?;

let department = response.choice("department").unwrap();
println!("route to {} (confidence {:.2})", department.choice, department.confidence);
println!("frustration: {:.2}", response.score("frustration").unwrap().score);
println!("urgent: {:.3}", response.noul("is_urgent").unwrap().noul);

§Configuration

SettingEnvironment variableDefault
API keyTYPESAFE_API_KEY— (required)
ModelTYPESAFE_DEFAULT_MODELjev-latest
Base URLTYPESAFE_BASE_URLhttps://api.typesafe.ai

Use TypeSafeClient::builder for timeouts, retry policy, extra headers, or a custom reqwest client. See RetryPolicy for retry behavior (transient 429/529 responses are retried with exponential backoff by default).

Structs§

ApiError
An unsuccessful HTTP response from the TypeSafe API.
Choice
Pick one option from a defined set.
ChoiceAnswer
Answer to a choice question.
ClientBuilder
Builds TypeSafeClients.
ListModelsResponse
The response to list_models.
ModelCard
A model available to the account.
Noul
A yes/no question. The answer is the probability that the answer is “yes”.
NoulAnswer
Answer to a noul question: the probability that the answer is “yes”.
NoulCriteria
Optional descriptions of the two outcomes of a Noul question.
RetryPolicy
Controls how failed requests are retried.
Score
Rate the state along an ordered rubric.
ScoreAnswer
Answer to a score question.
SystemOneResponse
The response to a system_one evaluation.
TypeSafeClient
An asynchronous client for the TypeSafe AI System One API.
Usage
Token usage for a request.

Enums§

Answer
One typed answer. The variant matches the type of the question asked.
Error
Errors returned by this SDK.
Question
A typed question to evaluate against the state.

Constants§

DEFAULT_BASE_URL
Default API root.
DEFAULT_MODEL
Default model used when none is configured.
DEFAULT_TIMEOUT
Default request timeout.
ENV_API_KEY
Environment variable for the API key.
ENV_BASE_URL
Environment variable for the API root.
ENV_DEFAULT_MODEL
Environment variable for the default model.

Traits§

IntoContent
Any content that can be sent as part of a question: a plain string or arbitrary JSON structure.
IntoDescription
An optional description for a Choice option.