Before we start working with the AI SDK, let's create a simple project for you to follow along in. If you'd prefer to save four or five minutes and simply download this boilerplate, then you could do so with the link in the description below. But I also wanted to show you how easy it was to get started from absolute zero. gitignore file.
env file. Next I want to run npm init in order to start a Node project. Most of the default answers will work here just fine. 0, description can be blank.
The entry point doesn't matter for us. The test command, git repository, keywords, author, license, all of that can be the default empty value. For type though, I don't want to use CommonJS. I want to use ESM.
So I'll type the word module. This lets us do our imports and exports in the ESM syntax. Okay, all this looks good. The next thing I want to do is install TSX for running TypeScript files.
So I'll run npm install TSX. js. So we'll install those now as well. json file with some values just for the sake of my IDE.
I've left these exact values in the description below. js website. I've left a link to that as well. But I did include these two lines to look for TypeScript files anywhere throughout our entire project and exclude the Node modules.
env files. So my current version that I'm working with is Node version 25, which definitely has that support available. In fact, it's been supported since version 20. So do just make sure that you have at least that version or above installed.
If you don't, feel free to use nvm to install it. Next, I'm going to open up my AI chat and just ask it to pin my current Node version. This is going to write a couple little files for us. I'll hit accept here and accept here.
But it looks like somehow it got my Node version wrong. So let me do a copy paste from the terminal, add that into nvmrc, keep that. So this will just ensure that when somebody uses nvmuse on this project, the version that it checks out is the same version as I'm using. nodeversion.
1. env files. But I just want to make sure I'm using the latest version. ts file to make sure things are working as expected.
ts, create a variable, yeah, test string, and then we'll just console log it. In the terminal, let me run npx tsx and target that hello world file. Perfect. Hello world is printed to the console.
So we're running TypeScript. Let's also test that env variables are working as expected. env and create a new my test environment variable. env.
This time when I run tsx, before I give it the file name, let me pass in the env-file flag and point it to our env file. Perfect. json. And then inside of our scripts, I'm going to create a new script called tsx, call tsx from that, and then pass in that env-file flag right there so that we don't have to type it every time.
Clear out my terminal. Let's try the shortcut. And there we go. In the next lesson, let's install the AI SDK and get it working with the Google provider, aka the Gemini model.