Loading video player…

Jev AI in Python: An Honest First Look

Jev is the new System One model from TypeSafe AI, and this is not another hype video. Grab the sample code below, then follow along as we install the model, call it from Python through OpenRouter, and judge the results honestly, including the answer that came back fuzzy.

We start with a plain Python script that only accepts an uppercase Y or N, and watch it fall apart the moment someone types “yeah, I’ve lost something.” Then we replace all that branching with a single Noul question that scores how affirmative an answer is, on a scale from 0 to 1.

Along the way: installing the typesafe-sdk package, keeping your API key in a .env file, the two lines that point the client at OpenRouter, why the first question scored a disappointing 0.34, and the thresholds that turn a float back into a yes or a no.

The verdict at the end is an honest one. No, Jev did not invent anything new, and you could rebuild this with an LLM and Pydantic AI. But it is fast, cheap, and tidy enough to earn a place in the AI model toolbox.

Resources mentioned in this lesson:

A visitor talks into a station assistant machine with a Noul dial, a Score gauge, and a Choice switch, while two staff members read a clipboard and pull a lever.

Tutorial

How to Get Started With Jev in Python

Connect a Python script to the Jev model with the TypeSafe SDK and OpenRouter, then replace brittle input checks with Noul, Score, and Choice answers.

intermediate ai api

00:00 There is a new AI model in town. It’s called Jev, and there was quite a bit of hype over the last couple of days. So if you expect another hype video, you’re in the wrong place.

00:08 In this video, I will show you how you can get started with Jev in Python, so you can find out yourself if Jev lives up to the hype, if it’s something for you, or if you would rather skip it.

00:20 What I’m doing right here is a new format on our YouTube channel. So let me know in the comments if this is something that you like. And if you want to have the code that I’m writing for your own, make sure to click the link below this video where you can download everything you’re seeing on the screen.

00:35 Let’s hop into it. To get a good understanding when Jev could come in handy, let’s start with a plain Python script. The script on the left doesn’t have any AI at all.

00:44 It’s probably Python code that you might have written if you created a little game. The situation here is that we are on a train station, and we want to ask the customer that comes to the counter if they lost something.

00:57 So let’s run the script with uv run plain_python. That’s the name of the script. And you can see on the line 10 on the left, we are asking the customer, did you lose something?

01:10 We want to have a clear answer with an uppercase Y or an uppercase N. If our program doesn’t get an uppercase Y or an uppercase N, we stay in the Y loop until we get an uppercase Y or an N.

01:25 So even if a customer enters a lowercase Y, that doesn’t work because it needs to be uppercase, right? So we could go into the Python code and, for example, add the upper string method, so we also allow lowercase input.

01:41 But now imagine a person says, yeah, I’ve lost something. Now we run into this issue, where does this stop? What are all these cases that our Python script needs to take care of in order to give a useful answer?

01:56 And that is where Jev can come into the picture. If you want to conveniently work with Jev in Python, you need to have the TypeSafe SDK package. That’s the official package by TypeSafe AI.

02:09 That’s the company providing Jev. You can install it either with pip or with uv. Since my project is uv-based, I will use uv. And then you also need an API key.

02:22 You can either get an API key straight from TypeSafe AI, but I recommend using OpenRouter for this. The reason why I recommend OpenRouter is I think when you want to try out a model, OpenRouter is a great platform to just try models out without creating an account and entering your credit card for different providers.

02:44 If you’re curious about OpenRouter in general, then check out our video course on OpenRouter on realpython.com, which goes in depth of how you work with OpenRouter.

02:54 For now, all you need to have is an OpenRouter account and then create an OpenRouter API key. Once you have your OpenRouter API key, jump back into your project and create a .env file.

03:07 And inside this .env file, create an environment variable named OpenRouter underscore API underscore key, everything in uppercase, and then you paste the key there.

03:19 You don’t see me pasting that because you want to keep your API key secret,

03:24 especially when you’re recording YouTube videos. And if you’re working with Git, you also want to gitignore the .env file. Next, let’s have a look at my pyproject.toml file.

03:35 So this is a file that doesn’t exist for you yet. So what you can do is you can pause the video and then enter what I’m having here on my screen, or you can click the link below this video where you can download all the code that you’re seeing in this video.

03:49 So that’s way more convenient. The most important part in the pyproject.toml file is the declaration of dependencies, which here is typesafe-sdk, which should be equal or larger than 0.7.

04:02 As you will see in a moment, the code that we are using with Jev is not that much different than our plain Python script. So instead of writing everything from scratch, we want to enhance the script.

04:15 So I will duplicate this script and then rename the file to jev_noul, because that is the primitive we want to work with in Jev first. And then let’s make a tiny change.

04:30 So we see that the script is different. Let’s remove the yes and no question in the part. And maybe the answer, if we didn’t get what the user was saying, let’s say, sorry, I didn’t get that.

04:45 The rest can stay like it is for now, because the only part that I want to check right now is to see if the script works. So back in the terminal, let’s run uv run jev_noul, and then the question should be only, did you lose something?

05:04 Instead of asking for the Y and N. All right, now it’s time to add Jev. To work with Jev in Python, you need to import the TypeSafeClient. So on the very top of your document, add the import statement from typesafe_sdk import TypeSafeClient.

05:26 Don’t forget to save the file and with control C, you stop the loop on the right side in the terminal and then run uv run jev_noul again. One thing I forgot to mention a moment ago, since we have our pyproject.toml file and we have the dependency of the TypeSafe SDK in there, and we didn’t run uv add in order to get the package, you might have gotten a message of installing TypeSafe SDK.

05:52 I already did that, so you didn’t see the message on my end, but you can definitely make sure that everything is there once you run uv run Jev Noul, that there is no error.

06:02 If you don’t have the TypeSafe SDK, you would get an import error at this point. All right, so that means our TypeSafeClient is present, and now we want to use this TypeSafeClient in order to connect to the open router API.

06:15 To do so, you create a client variable. Of course, you can name the variable however you want to name it, but client is a convention, and then you set it to the imported TypeSafeClient object.

06:29 So that means client is an instance of the TypeSafeClient class, and to instantiate the class, you need to provide an API key, which you need to get from your environment variable.

06:41 So that’s usually done with os.environ, and then you need to get the open router underscore API key. Don’t forget to import OS because it’s os.environ, so import OS at the very top.

06:59 So once OS is present, then you can get the environment variable, and of course it is open router API key, and the next argument you need to provide is a base URL, and the base URL for the open router API is HTTPS colon double slash open router dot AI slash API.

07:25 These two lines, the API key setting it to the open router API key and the base URL setting it to the open router API, are the most important two lines if you want to work with open router and Jev.

07:38 If you want to use the TypeSafe AI directly, then you don’t have to set the API key and the base URL because then it will kind of fall back to some default values, but since we don’t have these default values, but we want to use open router, you need to add these two arguments when you instantiate the TypeSafeClient.

07:59 The next important bit is that you want to get the answer from the user back and pass it in to a request to the open router API for the Jev model. So go into the ask function and there in the line after you ask for a user input and there create a new variable called R, which is short for response.

08:22 And then you want to call the system_one() method from the client that you instantiated in line four. The system_one() method takes two arguments. One is the state, which can be a simple string.

08:38 It can also be an array or an object. But let’s start with a simple string. And that is basically the answer that the user gives. So we are using an F string and adding the answer to it.

08:51 The second argument then is questions and questions is a dictionary. And this dictionary can now have multiple questions. So we just want to have one question for now.

09:06 This question should have a key that you can choose yourself. So for example, for us, let’s use the key lost something. And then you need to define which type this question is.

09:18 So we are working with Noul here. In order to work with it, we also need to import it. So in line two, where you’re importing the type safe client, also import Noul uppercase N-O-U-L, and then you instantiate it as the value of your lost something item.

09:39 And Noul takes at least one argument, and that’s the instructions. So Jev knows what to do with the input that was given. So you can think of it as a lens that Jev should look at what you handed over.

09:54 And there we can start very basic. But you will see in a moment that this is probably something where you will spend some time in thinking, how can you improve that in order to get good answers back from Jev?

10:06 Because with any AI, it’s very much about the prompt that goes in that defines on how good is the quality of what comes out. So for now, let’s just add something like, did the user lose something?

10:20 So Jev will get the state, which is the answer from the user, and then the questions which should be used to look at this answer. And if this is a bit abstract, bear with me because we will look at the response and then hopefully it will make a bit more sense.

10:34 To check if it’s working, let’s just print R and then run the file. Now, since you are using the OpenRouter API key now, you want to point UV to the correct .env file to load it when running the file.

10:50 And that’s where UV’s env file flags come into play. And you pass .env to it to point it to the .env file and then run the jev_noul.py example. So again, the question is, did you lose something?

11:07 And now I can say, yeah, I lost something. And then we make the API requests. The first time it takes a bit longer and then it comes back. You can ignore the, sorry, I didn’t get that part.

11:22 That’s because we haven’t added any other logic into our script yet. The important bit here is this little value. Noul has a value of 0.94. So that’s almost one.

11:35 So you can think of the Noul as a Boolean, true or false, but it’s on a scale from one to zero. So if it’s at 0.94, that’s likely true. So did the user lose something?

11:47 Yeah, that seems to be true. And this input is definitely more complex than only the uppercase Y. So that is kind of nice. However, what if I just say yes to the question, did you lose something?

12:03 So now the response is way faster because the connection is there. But what you see now is that Noul is 0.34. So that is more in the middle or lower third even.

12:17 And for the Noul, you can think of it like if it’s not clearly into one direction, so either one or zero, like very clear, then you can’t really trust that score.

12:28 And 0.34 is something in between. And this usually is something where, especially when you’re writing your code, is something where you should look at the question that you’re asking, meaning what is the state you’re sending over and what are the instructions you’re giving to Jev.

12:45 How it looks now is that the did the user lose something question only really works when the user is answering in a full sentence of like, yes, I lost something.

12:54 But that’s not the case. So what we would rather ask here to Jev is not if the user lost something or not, but if the answer was affirmative to the question before.

13:07 So with this adjustment, we restart our script and then let’s just answer in yes, because that’s when we got the fuzzy result before.

13:17 And now we get 0.98 back for yes. What if we answer with yeah, then it’s 0.94. So that’s also nice. What it’s something like, yes, I did lose something. So now it’s still in the 0.97 area.

13:38 In order to get the actual value back from Jev’s reply, we need to go into the answers object and in there you need to look for the key of your question.

13:51 So here it is the lost something key and this lost something key, since it contains the Noul as an object, you need to get the Noul value. Let’s run the code.

14:04 Let’s say yes, and then you can see that the response is only 0.98. And here, I didn’t mention this before, I think, this is a part where Jev is kind of nice because you only get these values back in this schema and not some prose that you might end up with LLMs in general.

14:25 So there you really know you can traverse into this object and get the value you want, and now you don’t look for the answer yes or no. But what you now want to do is that you want to check if the Noul value is above 0.8 in order to be a yes, then it’s true that the user lost something or if it’s below 0.2.

14:48 So we get the response back. Let’s set it to a variable named lost something, which then has a float value. And then we check if this float value is above 0.8 or below 0.2, and then we return true or false.

15:13 And if it’s somewhat in between that, then we print, sorry, I didn’t get that. All right, let’s restart our script and see what it does. So, yeah, I did lose something is true.

15:32 That means we get the message. You can find the lost and found counter on the right. And if we are answering with no, for example, then we go into the what can I help you with?

15:47 Besides the Noul, you can also ask for a score, so that asks more for severity, like for example, how urgent is the request, or you can ask for a choice.

16:00 So there you provide some choices and then you can let Jev choose from that. So is this something really new that Jev invented? Of course not. That is kind of like some classification.

16:13 And you could even write this with a normal LLM. If you’re curious about LLMs, we have benchmarks at realpython.com about how the current LLM models perform.

16:25 And if you put something like Pydantic AI on top of it, you also can replicate that without having to use something like Jev. Still, I think Jev is quite nice to streamline all of that.

16:37 And currently, it’s quite fast and quite cheap. Let’s see if it stays that way. But at the moment, I honestly see it as a nice little tool in our AI model toolbox.

16:49 All right, and that is how you connect your Python scripts with Jev. I hope this was a good starting point for you. I’m curious what you’re thinking of Jev, what you’re doing with Jev, or if you rather skip it.

17:00 See you next time.

Become a Member to join the conversation.