Channel
Interviewed Person
Nico Albanese
Full workshop presented by Nico Albanese from Vercel, at the 2025 AI Engineer Summit in New York, Feb 2025: https://x.com/nicoalbanese10 and https://github.com/nicoalbanese workshop content/guidebook: https://aie-feb-25.vercel.app/docs Organizers note: We somehow screwed up and experienced a total loss of the original workshop video. Nico was incredibly gracious about it and rerecorded the whole thing for you! thank you Nico! Please give him a shoutout: https://x.com/nicoalbanese10
Hey folks, my name is Nico. I work on the AI SDK at Verscell. And in this session today, we're going to be looking at building agents with the AI SDK. Now, this session is roughly divided into two sections. We're going to start with a fundamental section. This is going to introduce you to the building blocks that you need to understand about using the AI SDK before we jump into building agents. And then we're going to be building a deep research clone uh in Node.js. JS. So without further ado, let's get right into it. To follow
along, the first thing that you're going to have to do is clone the repository here, install the dependencies, copy over uh any environment variables, um and then you'll be ready to go. In this project, we have just one file, index.ts. And you can run this file by just running pmpp rundev. I have this alias to just pd. So if you see me typing that, that's just running the script. Great. So let's start with the first primitive that
we're going to be looking at, the generate text function. Now, this is, as it sounds, a way for you to call a larger language model and generate some text. So let's take a look. In this session, rather than typing everything out line by line, I'm going to be copying over snippets so we can get through things a little bit faster and focus on the core concepts rather than necessarily remembering to type everything out properly. So, let's start with the first snippet. What we've got here is a single
function called main. It's asynchronous. And inside this function, we call generate text, which we import from the AI SDK. We specify the model we want to use. in this case, OpenAI's GPT40 mini. Um, and then we pass in a prompt, hello world. Finally, we log out the resulting text that is generated and call the function. So, we can head into the terminal, run pmppm rundev, and we
should see a message back from GPT4 mini. Hello, how can I assist you today? Now each of these generate text functions and uh stream text and generate object and stream object as we'll see later uh can take in either a prompt as input or messages and in this case messages is just an array of messages where a message has a role and then some content. So this would be the same as we had before if we change this
to user. For the rest of this session, we'll be using mostly the prompt key. So, one of the core features of the AI SDK is its unified interface. And what that means is that we're able to switch between language models by just changing one single line of code. Now, there are many reasons why you might want to do this. It might be because a model is cheaper, faster, um, better at your specific use case. Um, and speaking of better, one thing that we can try asking this model
in particular is uh something that we know it might struggle with, like when was the AI engineer summit in 2025. Now, I know for a fact that GPT40 Mini is not going to be able to do this because it doesn't have access to the web and its training data cutoff is somewhere in 2024. So, we can see I'm
sorry, but I don't have information about events scheduled for 2025, including the AI engineer summit. So, how could we solve this? Well, we could, and we'll look into later, add a tool, and that tool could call the web and return those results and pipe those into the context of the conversation, and then the language model can deduce from there. But we could also just pick a model that has web search built in, something like perplexity. So, how do we change to a different model? Well, all