Jev AI Hub
Start Learning

Tutorials

Jev Python Tutorial

Install typesafe-sdk and call TypeSafe Jev from Python with Choice, Score, and Noul questions.

Published
Sep 20, 2026
Updated
Sep 20, 2026
Last verified
Sep 20, 2026

Quick answer

Install typesafe-sdk (Python 3.10+), set TYPESAFE_API_KEY, and call TypeSafeClient().system_one(state, questions). Use Choice, Score, and Noul helpers. AsyncTypeSafeClient is available for async code. Official SDKs retry 429/529 with backoff.

This tutorial is the Python path into Jev. It is not a copy of the SDK reference. For request fields see the API guide.

Install

pip install typesafe-sdk
uv add typesafe-sdk

Official quickstart: Python >= 3.10. Set TYPESAFE_API_KEY.

First sync call

from typesafe_sdk import Choice, Noul, Score, TypeSafeClient

ticket = (
    "Hi, I have been trying to connect my Stripe account for 3 days "
    "and the integration keeps failing. I am losing sales. Please help ASAP."
)

with TypeSafeClient() as client:
    response = client.system_one(
        state=ticket,
        questions={
            "department": Choice(
                instructions="Which team should handle this",
                criteria={
                    "billing": "Payment or subscription issues",
                    "technical": "Bugs or integration problems",
                    "sales": "Pricing or account questions",
                },
            ),
            "frustration": Score(
                instructions="How frustrated the customer appears",
                criteria=[
                    "Calm, just stating facts",
                    "Frustrated but civil",
                    "Very angry, strong language",
                ],
            ),
            "is_urgent": Noul(
                instructions="The message conveys urgency or time-sensitivity",
            ),
        },
    )

print(response.answers["department"].choice)
print(response.answers["frustration"].score)
print(response.answers["is_urgent"].noul)
print(response.model)

Some SDK examples also expose response.nouls, response.choices, and response.scores. Prefer the typed accessors your installed version documents.

Async

from typesafe_sdk import AsyncTypeSafeClient, Choice, Noul, Score

async def main() -> None:
    async with AsyncTypeSafeClient() as client:
        response = await client.system_one(
            state={"document": "I was charged twice. Please fix this ASAP."},
            questions={
                "billing": Noul(instructions="Is this ticket about billing?"),
                "tone": Choice(
                    instructions="What is the customer's tone?",
                    criteria={"calm": None, "frustrated": None, "angry": None},
                ),
                "urgency": Score(
                    instructions="How urgent is this ticket?",
                    criteria=["can wait", "this week", "today"],
                ),
            },
        )
    print(response.answers["billing"].noul)

Structured state

state = {
    "ticket_message": "My flight was cancelled. Can I get a refund?",
    "refund_policy": "Cancelled flights are eligible for a full refund.",
}

questions = {
    "refund_requested": Noul(
        instructions="Does `ticket_message` request a refund?",
    )
}

Backticks plus paths are the official way to point at fields. See Choice when you add routing.

Errors and retries

Official HTTP errors: 401, 422, 429, 529. The Python SDK documents RetryPolicy and retries retryable statuses by default. Do not write your own tight retry loop around 422.

When to use the Python SDK

Backend workers, notebooks, and FastAPI services that already live in Python.

When not to

Browser code — keep the key on a server. One-off probes can stay on cURL.

Common mistakes

  • Installing a similarly named package that is not typesafe-sdk.
  • Putting the English question only in the dict key.
  • Comparing floats from two different model versions without logging response.model.
  • Load-testing without reading pricing.

Next: examples or the same workflow in TypeScript.

FAQ

What package do I install for Jev in Python?

typesafe-sdk, via pip or uv. Official docs require Python >= 3.10.

Sync or async?

TypeSafeClient is sync. AsyncTypeSafeClient is the async client. Both call the same HTTP API.

Sources

  1. TypeSafe Python SDKTypeSafe · accessed 2026-09-20 · documentation
  2. Quick startTypeSafe · accessed 2026-09-20 · documentation
  3. PrimitivesTypeSafe · accessed 2026-09-20 · documentation