Your first Jev program: a ticket triage bot in Python, step by step

You've read what Jev is. Now let's run it. This hands-on guide takes you from an empty folder to a working support-ticket triage script: getting an API key (and why you need credits first), installing the SDK, asking your first question, and letting your code act on Jev's confidence.

The path to your first Jev program in four stops. One: add credits in the TypeSafe console and create an API key. Two: pip install typesafe-sdk and set TYPESAFE_API_KEY. Three: hello Jev, ask one yes-or-no question and print one number. Four: a ticket triage script that asks three questions per ticket and routes the confident ones. A terminal shows the result: a checkout API ticket routed to technical with confidence 1.00, urgent 0.99, about 100 milliseconds.
Fig. 1 — Four stops from an empty folder to a script that triages support tickets with Jev.

If you’ve read What is Jev AI?, you know the idea: Jev doesn’t write text, it fills in a form your code can use straight away. Reading about it only goes so far, though. The fastest way to understand Jev is to run it.

In this guide you’ll build a small support-ticket triage script. For each ticket, it asks Jev three questions (which team, how frustrated, how urgent) in a single request, then decides on its own whether to route the ticket or hand it to a person.

You don’t need any machine learning background. If you can run a Python script, you can follow along.

Everything here comes from TypeSafe’s own documentation, console and launch post. Links are at the end.

What you’ll need

  • Python 3.10 or newer. Check with python --version (or python3 --version on a Mac).
  • A TypeSafe account with early access to Jev, and an API key (next section).
  • About 15 minutes.

Do you need an API key to use Jev?

Yes. Jev runs on TypeSafe’s servers. You can’t download it and run it on your laptop the way you can with Ollama models. Every request your code sends must carry an API key, so TypeSafe knows which account is asking. A request without a valid key comes back as 401 Unauthorized.

There are three things to know before you get one:

  1. Jev is in early access. TypeSafe launched Jev on 15 September 2026 and is letting developers in from a waitlist. Sign up at typesafe.ai. Once you’re in, you get the console at console.typesafe.ai.
  2. You need credits before you can create a key. This catches people out. A new account starts with a balance of $0.00, and the console’s API Keys page says your organisation needs available credits to create an API key. So the order is: Billing → add credits → API Keys → create a key.
  3. A little goes a very long way. Jev costs $0.042 per million input tokens, and output tokens are free. TypeSafe’s quick-start request used 428 input tokens, which works out to under two thousandths of a cent. A single dollar covers roughly 55,000 requests of that size.

Once there’s a balance on the account (we added $5), the Create key button appears. Give the key a name, and it shows up in the list:

The API keys page of the TypeSafe console. A Create key button sits at the top right. One key is listed: name test-key, the key value hidden, created 30 Nov 2026, expires never, status active.
The API Keys page in the TypeSafe console after creating a first key. The key value is hidden here; keep yours private too.

Two details from that page are worth knowing. Keys belong to the organisation, not to you personally: the console notes they stay active even if the person who created them is removed. So when someone leaves your team, revoke (delete) their keys yourself from the ⋯ menu.

Try a question in the Playground first

The console also has a Playground, where you can ask Jev questions in the browser before writing any code. You paste a state on the left, write questions below it as JSON, press Run request, and the answers appear on the right.

Here’s a quick test with a small JSON state about an employee, and one yes-or-no question (a Noul):

The TypeSafe Playground. On the left, the state is a JSON object for an employee named John, a senior software engineer, whose responsibilities include delivered 9 out of 10 planned sprint stories and missed one production delivery deadline. Below it, one question: delivery_target_met, type noul, instructions: did the employee deliver all planned sprint stories? On the right, the response from jev-preview: 2% true, 98% false.
One Noul in the Playground. 9 out of 10 stories isn't all of them, and Jev answers 98% false.

The state says John delivered 9 out of 10 planned stories, so the honest answer to “Did the employee deliver all planned sprint stories?” is no. Jev answers 2% true, 98% false, and the run took a fraction of a second. Notice the shape is exactly what you’ll write in code next: a state, a dictionary of questions keyed by your own names, and typed answers back.

The Playground is also the fastest place to learn what a badly asked question looks like. In another run, we put a task description in the state (“Analyse the uploaded photographs of a person. Determine whether the person is wearing or carrying a bag…”), attached some photos without referring to them, and asked “Is the person wearing or carrying a bag?”. Jev came back 38% true, 62% false: split, not sure either way. That’s Jev telling you the question wasn’t set up well. Two fixes, both from TypeSafe’s docs:

  • The state is the thing to judge, not instructions. Put the ticket, record or image in the state, and the question in instructions.
  • Name the image you mean. When a request has images, refer to the one to look at by its path in backticks. Image input is also still an early, opt-in feature (“Dreamer-ready”), so start with text.

When you’re happy with a question in the Playground, move it into code.

Save the key in an environment variable

Once you’ve created your key, don’t paste it into your code. The SDK reads it from an environment variable called TYPESAFE_API_KEY.

# macOS / Linux (bash or zsh). Lasts for this terminal window.
export TYPESAFE_API_KEY="paste-your-key-here"
# Windows PowerShell. Lasts for this window.
$env:TYPESAFE_API_KEY = "paste-your-key-here"

To keep it permanently, add the export line to your ~/.zshrc or ~/.bashrc, or on Windows set it under System Properties → Environment Variables. Treat the key like a password: never commit it to Git.

Step 1: set up the project

Make a folder, create a virtual environment so this project’s packages stay separate, and install TypeSafe’s Python SDK:

mkdir jev-triage && cd jev-triage
python -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate
pip install typesafe-sdk

If you use uv, uv add typesafe-sdk does the same job.

Step 2: hello, Jev

Start with the smallest program that does something real: one ticket, one yes-or-no question, one number back. Create hello_jev.py:

from typesafe_sdk import Noul, TypeSafeClient

ticket = "Our checkout API has been failing since morning. We can't take any orders."

with TypeSafeClient(model="jev-latest") as client:      # reads TYPESAFE_API_KEY
    result = client.system_one(
        state=ticket,                                    # the thing to judge
        questions={
            "urgent": Noul(instructions="The text signals time pressure"),
        },
    )

print(result.nouls["urgent"].noul)

Run it:

python hello_jev.py

You’ll get a single number between 0 and 1, the probability that the answer is yes. For a ticket like this, expect something close to 1. In TypeSafe’s own quick start, a similar ticket scored 0.99.

Now read the program line by line, because every Jev program has the same shape:

  • TypeSafeClient(model="jev-latest") opens a connection. jev-latest is an alias for the newest stable Jev (today that’s jev-1.14.0). The client picks up your key from TYPESAFE_API_KEY by itself.
  • state is the input Jev judges. Here it’s a plain string, but it can also be a JSON object.
  • questions is a dictionary. The key, "urgent", is your own name for the question. Jev never sees it; it’s only there so you can find the answer afterwards.
  • Noul(...) is a yes-or-no question. (“Noul” is TypeSafe’s name for this question type.)
  • result.nouls["urgent"].noul reads the answer back by the name you chose.

That’s the whole pattern: state in, typed questions in, typed answers out. No prompt asking for JSON, and no parsing.

Step 3: ask which team, with a Choice

A yes-or-no answer is useful, but routing needs a Choice: pick one option from a fixed list. You write the options as a dictionary of name → description. Jev sees both, so make the descriptions clearly different from each other.

from typesafe_sdk import Choice, TypeSafeClient

ticket = "Our checkout API has been failing since morning. We can't take any orders."

with TypeSafeClient(model="jev-latest") as client:
    result = client.system_one(
        state=ticket,
        questions={
            "team": Choice(
                instructions="Which group should own this request",
                criteria={
                    "billing": "Invoices, payments, refunds or plan changes",
                    "technical": "Software faults, outages or integration errors",
                    "sales": "Buying, pricing or discount questions",
                    "other": "Anything that fits none of the groups above",
                },
            ),
        },
    )

team = result.choices["team"]
print(team.choice)          # the winning option
print(team.confidence)      # 0 to 1: how sure Jev is
print(team.probabilities)   # a probability for every option, adding up to 1

Two things are new here:

  • probabilities shows how Jev spread its belief across every option. It’s the most honest view of what the model “thinks”.
  • confidence squeezes that spread into one number. It’s 1 when all the probability sits on one option and 0 when it’s spread evenly. In the quick start, the department question came back technical with confidence 1.0.

Notice the other option. TypeSafe’s Choice guide recommends adding one, so that a ticket that fits nothing has somewhere honest to go instead of being forced into the closest team.

Step 4: ask how frustrated, with a Score

Frustration isn’t a category, it’s a scale. For that you use a Score: a list of levels, ordered from low to high. The first level is 0, the next is 1, and so on.

from typesafe_sdk import Score

frustration = Score(
    instructions="Level of frustration in the writer's tone",
    criteria=[
        "Neutral, factual tone",        # level 0
        "Annoyed but polite",           # level 1
        "Furious, harsh wording",       # level 2
    ],
)

The answer’s score can land between levels, because it’s an average of the levels weighted by their probabilities. In the quick start, a frustration question came back with probabilities 0.33 on level 0 and 0.67 on level 1, so the score was 0.67. To turn it into a 0-to-1 number, divide by the top level number: 0.67 ÷ 2 ≈ 0.33.

Step 5: the triage bot

Now put all three question types together. They go in one request: Jev evaluates each question separately against the same ticket, in parallel, so asking three questions barely changes the wait compared with asking one.

Create triage.py:

import time
from typesafe_sdk import Choice, Noul, Score, TypeSafeClient

TICKETS = [
    "Our checkout API has been failing since morning. We can't take any orders.",
    "I was charged twice for my November invoice. Please refund one of them.",
    "Do you offer a discount if we buy 50 seats for our team?",
    "Third time writing. Nobody answers. Fix my login NOW, I have a demo in an hour.",
    "Hi, quick question about something with my account.",
]

QUESTIONS = {
    "team": Choice(
        instructions="Which group should own this request",
        criteria={
            "billing": "Invoices, payments, refunds or plan changes",
            "technical": "Software faults, outages or integration errors",
            "sales": "Buying, pricing or discount questions",
            "other": "Anything that fits none of the groups above",
        },
    ),
    "frustration": Score(
        instructions="Level of frustration in the writer's tone",
        criteria=["Neutral, factual tone", "Annoyed but polite", "Furious, harsh wording"],
    ),
    "urgent": Noul(instructions="The text signals time pressure"),
}

CONFIDENT = 0.8                       # below this, a person decides the team
PRICE_PER_TOKEN = 0.042 / 1_000_000   # dollars per input token; output is free


def triage(client, ticket):
    start = time.perf_counter()
    result = client.system_one(state=ticket, questions=QUESTIONS)
    ms = (time.perf_counter() - start) * 1000

    team = result.choices["team"]
    frustration = result.scores["frustration"].score / 2   # 3 levels -> 0..1
    urgent = result.nouls["urgent"].noul

    # Your code makes the decision, using Jev's answers.
    if team.confidence >= CONFIDENT and team.choice != "other":
        action = f"route to {team.choice}"
    else:
        action = "send to a person"
    if urgent > 0.7:
        action += " + page on-call"

    cost = (result.usage.input_tokens or 0) * PRICE_PER_TOKEN
    print(f"ticket       {ticket[:60]}")
    print(f"team         {team.choice:<10} confidence {team.confidence:.2f}")
    print(f"frustration  {frustration:.2f}")
    print(f"urgent       {urgent:.2f}")
    print(f"action       {action}")
    print(f"took         {ms:.0f} ms, about ${cost:.7f}\n")


with TypeSafeClient(model="jev-latest") as client:
    for ticket in TICKETS:
        triage(client, ticket)

Run it with python triage.py. For each ticket you’ll see a block like this (your numbers will be Jev’s own, and can shift a little between Jev versions):

ticket       Our checkout API has been failing since morning. We can't ta
team         technical  confidence 1.00
frustration  0.33
urgent       0.99
action       route to technical + page on-call
took         ... ms, about $0.0000...

Look at the last ticket, “Hi, quick question about something with my account.” It’s deliberately vague. Watch its team confidence: if it falls below 0.8, or the answer is other, your script sends it to a person. That’s the important moment in this tutorial: Jev doesn’t just answer, it tells your code how much to trust the answer.

Step 6: understand the two thresholds

The script uses two numbers you chose yourself. Neither is magic; they come from TypeSafe’s advice:

  • Team confidence ≥ 0.8 → act; below → a person. TypeSafe’s confidence guide suggests three bands: high, act on your own; medium, ask the user or flag for review; low, don’t act. It also says to match the bar to the risk: a read-only action can go ahead at moderate confidence, while something destructive needs a much higher bar or a human’s yes.
  • Urgent > 0.7 → page on-call. For yes-or-no questions, TypeSafe suggests starting with 0.7 for yes and 0.3 for no, and sending the values in between to a person. Paging someone at 3 am is costly if it’s wrong, so you might raise this one.

Start conservative, then adjust once you’ve seen how Jev does on your real tickets.

Step 7: what did it cost?

Every response reports its token usage in result.usage. Input tokens are priced at $0.042 per million, and output tokens are free, so the cost is just input_tokens × 0.042 / 1,000,000, which is what the script prints.

Running all five tickets costs a tiny fraction of a cent. That’s the point of Jev’s pricing: it’s cheap enough to ask on every ticket, message or row, not just the important ones. You can check your real spend on the console’s Usage page.

Common errors and fixes

What you see What it means Fix
The console won’t let you create a key Your balance is $0.00 Add credits under Billing first
TypeSafeError when the client is created The API key is missing or invalid Check TYPESAFE_API_KEY is set in this terminal
401 Unauthorized (with curl or HTTP) Missing or wrong Authorization header Send Authorization: Bearer <your key>
422 Unprocessable Entity A question is malformed or a required field is missing Read the error: it names the bad field
429 Too Many Requests You hit your rate limit The SDK retries with backoff by default; just wait
ModuleNotFoundError: typesafe_sdk The package is in a different environment Activate .venv, then pip install typesafe-sdk

To catch API errors in code, wrap the call:

from typesafe_sdk import TypeSafeAPIError

try:
    result = client.system_one(state=ticket, questions=QUESTIONS)
except TypeSafeAPIError as error:
    print("Jev request failed:", error.status, error.request_id)

The request_id is what TypeSafe support will ask for if you need help.

Bonus: no SDK, just HTTP

Jev is a plain HTTP API, so any language can call it. Here’s the hello-world request with curl (version 7.76 or newer):

curl https://api.typesafe.ai/v1/systemone \
  -H "Authorization: Bearer $TYPESAFE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "jev-latest",
    "state": "Our checkout API has been failing since morning. We cannot take any orders.",
    "questions": {
      "urgent": { "type": "noul", "instructions": "The text signals time pressure" }
    }
  }'

The JSON that comes back has an answers object keyed by your question names, plus model and usage.

And the same thing in Java with the built-in HttpClient (Java 15+ for the text block), no extra libraries:

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class HelloJev {
    public static void main(String[] args) throws Exception {
        String body = """
            {
              "model": "jev-latest",
              "state": "Our checkout API has been failing since morning. We cannot take any orders.",
              "questions": {
                "urgent": { "type": "noul", "instructions": "The text signals time pressure" }
              }
            }
            """;

        HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.typesafe.ai/v1/systemone"))
                .header("Authorization", "Bearer " + System.getenv("TYPESAFE_API_KEY"))
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(body))
                .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
                .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());   // {"model": ..., "answers": {"urgent": {...}}, "usage": {...}}
    }
}

Run it with java HelloJev.java. In a real app you’d map the JSON to a record with Jackson; TypeSafe also publishes a JavaScript/TypeScript SDK (npm install @typesafe-ai/sdk).

Try it yourself

Three short exercises, each teaching one more thing about Jev:

  1. Add a “security” team. Add one line to the Choice criteria, for example "security": "Leaked passwords, breaches or account abuse", and add a ticket about a leaked API key. No training needed: that one line is the whole change.
  2. Add a spam check. Add a Noul "spam": Noul(instructions="The message is unsolicited advertising") and skip routing when it’s above 0.7. Notice the response time barely changes.
  3. Swap the option order. Move other to the top of the Choice and rerun the vague ticket. TypeSafe’s list of known weaknesses says Jev tends to favour the first option listed, so it’s worth seeing for yourself, and worth keeping your most likely option out of first place by accident.

Tips from TypeSafe’s docs for writing good questions

  • One snap judgment per question. “Does this message convey urgency?” is a good question. “Analyse this ticket and decide what to do” is not; split it into small questions and combine the answers in code.
  • Phrase yes-or-no questions so that high means yes. “Contains personal data” is better than “Is free of personal data”.
  • Don’t combine two things in one Noul. “Angry and asking for a refund” should be two questions.
  • Keep the state focused. Irrelevant text in the state distracts Jev and lowers accuracy.
  • Keep maths and dates in code. Jev treats dates as text and isn’t a calculator.

The next article, Jev’s four primitives explained, goes deeper into each question type.

Key takeaways

  • Yes, you need an API key, and in the console you need credits before you can create one. Store it in TYPESAFE_API_KEY.
  • Every Jev program has the same shape: state in, typed questions in, typed answers out.
  • Use a Noul for yes or no, a Choice for one of several options, and a Score for a level on a scale.
  • Put all your questions in one request; they’re evaluated in parallel.
  • Let your code decide, using confidence and thresholds, and send unsure cases to a person.
  • It’s cheap: $0.042 per million input tokens, output free.

Frequently asked questions

Is Jev free to use?

No, but it’s very cheap. You pay $0.042 per million input tokens, and output is free. You need to add credits to your organisation in the TypeSafe console before you can create an API key.

Can I run Jev locally, without an API key?

No. Jev runs on TypeSafe’s servers and every request needs an API key. For running models on your own computer, see what is Ollama, but note those are text-generating LLMs, not System One models.

Which languages can I use?

TypeSafe has official SDKs for Python (typesafe-sdk, Python 3.10+) and JavaScript/TypeScript (@typesafe-ai/sdk). Any other language, including Java, can call the HTTP endpoint directly.

What does jev-latest mean?

It’s an alias that points to the newest stable Jev release, currently jev-1.14.0. If you need answers to stay exactly the same over time, pin a specific version such as jev-1.14.0 instead.

Why did my request work in the Playground but fail in code?

Usually the key isn’t set in the terminal where you ran the script. Run echo $TYPESAFE_API_KEY (or echo $env:TYPESAFE_API_KEY in PowerShell) to check.

Sources

Comments

LEAVE A COMMENT
No sign-up. Comments appear after a quick review.