Jev knowledge base·verified Sep 22, 2026

jev python sdk

Use the official typesafe-sdk Python client with typed Jev questions, sync lifecycle, model pinning, error handling and test seams.

the short answer

Install the official typesafe-sdk package, store the direct-service key in TYPESAFE_API_KEY, and use TypeSafeClient.system_one with typed Choice, Score or Noul question objects. Manage the synchronous client with a context manager, pin the model for evaluated workflows, preserve the complete response, and wrap the call with application-specific timeout, retry, fallback and outcome logging.

Package
typesafe-sdk
Client
TypeSafeClient
Synchronous method
system_one
Credential environment variable
TYPESAFE_API_KEY
Question classes
Choice, Score, Noul

Install and Pin the Package Deliberately

The official repository uses the distribution name typesafe-sdk and import namespace typesafe_sdk. Commit a lockfile and record the package version in deployment metadata. The SDK version and Jev model version are different: upgrading the client can change transport behavior while changing jev-1.13.0 changes model behavior.

Set TYPESAFE_API_KEY through a secret manager or process environment. Do not place it in source, fixtures, notebook output or client-side applications. Provider gateways have separate SDKs and credentials; this page covers TypeSafe’s direct client only.

uv add typesafe-sdk
# or record an approved exact version in your lockfile

One State, Several Independent Typed Questions

The three questions share state but are independent. queue does not see the result of refund_requested. If a later question depends on the selected queue, issue another call and represent the dependency explicitly. The multiple-question guide covers batching and observability.

from typesafe_sdk import Choice, Noul, Score, TypeSafeClient

questions = {
    "queue": Choice(
        instructions="Which approved team should handle this ticket?",
        criteria={
            "billing": "Charges, invoices, refunds or payment methods",
            "technical": "Product errors or integrations",
            "other": "Neither billing nor technical",
        },
    ),
    "refund_requested": Noul(
        instructions="Does the customer explicitly ask to reverse a charge?"
    ),
    "urgency": Score(
        instructions="How urgent is this ticket?",
        criteria=[
            "Routine: no deadline or blocked work",
            "Time-sensitive: a deadline or degraded workflow",
            "Critical: a current essential workflow is blocked",
        ],
    ),
}

with TypeSafeClient() as client:
    response = client.system_one(
        state={"message": "Charged twice; this blocks payroll."},
        questions=questions,
        model="jev-1.13.0",
    )

Read by Answer Type and Retain Provenance

The official quickstart accesses Choice results through response.choices; verify the exact fields against the installed SDK release. Store resolved model and usage with question/state versions. Never reconstruct a distribution later from only the selected queue or weighted score.

Noul has no separate confidence field. Its noul value is the modeled yes probability. Choice and Score confidence summarize distribution concentration, not correctness or permission. See confidence versus probability.

queue = response.choices["queue"]
refund = response.nouls["refund_requested"]
urgency = response.scores["urgency"]

record = {
    "resolved_model": response.model,
    "usage": response.usage,
    "queue": {
        "choice": queue.choice,
        "probabilities": queue.probabilities,
        "confidence": queue.confidence,
    },
    "refund_probability": refund.noul,
    "urgency": {
        "score": urgency.score,
        "probabilities": urgency.probabilities,
        "confidence": urgency.confidence,
    },
}

Own Client Lifecycle and Concurrency

The official README demonstrates the synchronous client as a context manager, which closes transport resources deterministically. In a long-running service, create the supported long-lived client at process or dependency-injection scope rather than constructing one per item, and close it during shutdown. In a short script, use with.

TypeSafe also documents synchronous and asynchronous Python clients; choose one end to end instead of calling a blocking client inside an async event loop. Bound application concurrency below account limits and downstream capacity. A large task fan-out needs backpressure even if individual calls are fast.

Classify Failures Before Deciding to Retry

Inspect the installed SDK’s documented exception hierarchy and defaults before catching broad Exception. Preserve request IDs and sanitized error metadata. A runtime policy may need fail-closed behavior while an offline evaluator can queue delayed retry; the correct response follows consequence, not the SDK.

FailureDefault application response
Invalid question or stateFix code/data; do not retry unchanged
Authentication/authorizationStop and alert; never rotate through guessed credentials
Rate limitRespect server guidance, jitter backoff and apply backpressure
Timeout/connectionRetry only inside a bounded total budget when safe
Server errorBound retries, then invoke the explicit workflow fallback
Valid low-confidence resultUse calibrated review/fallback bands; this is not a transport error

Use Separate Contract, Fixture and Live Tests

Mocking proves application branches, not Jev quality. Live smoke tests prove API compatibility, not calibration. The full release gate needs both plus held-out outcome evaluation from Jev calibration.

  1. Unit-test state projection and question construction without a network call.
  2. Use sanitized captured responses to test parsing, storage and threshold behavior.
  3. Run a small credentialed contract test against a pinned model outside pull requests when secrets are unavailable.
  4. Replay a labeled evaluation suite for semantic changes; do not assert an exact float from a probabilistic service in ordinary unit tests.
  5. Inject timeouts, 429s, malformed payloads and fallback failures.

Production Checklist

  • Pin SDK and Jev model versions; log the resolved model.
  • Keep the key server-side and redact request state from unsafe logs.
  • Set timeout, bounded retries, concurrency and a consequence-specific fallback.
  • Persist full typed answers, usage, question/state versions and outcomes.
  • Re-evaluate after changing model, SDK, question, state projection or provider.

FAQ

What is the official Jev Python package?

TypeSafe publishes typesafe-sdk, imported as typesafe_sdk. Verify its current release and README before installation.

Does Python use system_one or systemOne?

The official Python quickstart uses client.system_one; the JavaScript SDK uses client.systemOne.

Should I create a client for every request?

Use the supported long-lived lifecycle in services and a context manager in short scripts. Avoid unnecessary transport setup and close resources cleanly.

How should I test probabilities?

Do not require an exact floating-point answer in ordinary unit tests. Test parsing with fixtures and assess distributions statistically on versioned labeled datasets.

Sources

Checked against the sources below on September 22, 2026. Model versions, prices and limits change.

  1. TypeSafe AI: official Python SDK
  2. TypeSafe AI docs: HTTP API reference
  3. TypeSafe AI docs: Primitives
  4. TypeSafe AI docs: How to build with System One
  5. TypeSafe AI docs: State
  6. TypeSafe AI docs: Models
  7. TypeSafe AI docs: Jev 1.13 jaggedness