Jev Python SDK tutorial
Install the TypeSafe Python SDK, send a typed Jev request, and safely consume Choice, Score, Noul, and confidence results.
1. Install and authenticate
Keep the API key on the server. The SDK reads TYPESAFE_API_KEY from the environment, so it does not need to appear in application code.
python -m pip install typesafe-sdk
export TYPESAFE_API_KEY="your-api-key" 2. Make a typed decision
State carries the facts to inspect. Questions define the closed decisions you want back. This example routes a support message and separately checks urgency.
from typesafe_sdk import Choice, Noul, TypeSafeClient
with TypeSafeClient() as client:
response = client.system_one(
state={"message": "Stripe has failed for 3 days."},
questions={
"department": Choice(
instructions="Which team should handle this?",
criteria={
"billing": "Payments or subscriptions",
"technical": "Bugs or integrations",
"sales": "Pricing or account questions",
},
),
"is_urgent": Noul(
instructions="Does the message convey urgency?"
),
},
) 3. Read the answer safely
Choice answers expose a winning label, a probability distribution, and confidence. Noul returns the estimated probability that its statement is true. Treat the result as decision data, not generated prose.
department = response.answers["department"]
print(department.choice)
print(department.probabilities)
print(department.confidence)
urgent = response.answers["is_urgent"]
print(urgent.noul) # P(true) 4. Production checklist
Pin and log the model version, keep question identifiers stable, validate every answer before applying side effects, and send low-confidence or high-risk cases to a person.