Learning Vercel AI SDK—Part 1

The AI SDK is a robust TypeScript library that enables developers to easily create AI-powered applications. In this tutorial, you’ll build a simple AI chatbot with a real-time streaming interface.

After completing this article, you will have a solid grasp of key concepts used in the Vercel AI SDK, including:

  • Models
  • Text prompts
  • System prompts
  • Text generation
  • Text streaming

Setting Up the Project

To get started, create a new Node.js application and set it up to use TypeScript.
For that, in your terminal, run the following commands:

  • npm install -D typescript @types/node ts-node
  • npx tsc –init

Once the commands have been executed, replace the contents of your tsconfig.json file with the configuration shown below.

{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "node",
"rootDir": "./src",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true
},
"include": ["src/**/*"],
"exclude": ["node_modules"]
}

After that, install the dependencies below:

  • npm install dotenv
  • npm install -D @types/dotenv
  • npm install ai@beta @ai-sdk/openai@beta zod
  • npm install -D @types/node tsx typescript
  • npm i –save-dev @types/json-schema

Next, add the .env file to the project root and paste the OpenAI key information below inside the file:

Now that you’ve added your API key and installed all the dependencies, you’ll notice that your package.json file has been updated with these changes.

{
"name": "demo1",
"version": "1.0.0",
"main": "index.js",
"type": "module",
"scripts": {
"build": "tsc",
"start": "tsc && node dist/index.js"
},
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@types/dotenv": "^6.1.1",
"@types/json-schema": "^7.0.15",
"@types/node": "^24.7.2",
"tsx": "^4.20.6",
"typescript": "^5.9.3"
},
"dependencies": {
"@ai-sdk/openai": "^3.0.0-beta.29",
"ai": "^6.0.0-beta.47",
"dotenv": "^17.2.3",
"zod": "^4.1.12"
}
}

In your setup, the package name and version may differ. Next, create a src folder in your project and add an index.ts file inside it. In that file, log the value of your OpenAI key to verify that the project has been configured correctly.

import dotenv from 'dotenv';
dotenv.config();
const openaiApiKey: string | undefined = process.env.OPENAI_API_KEY;
console.log(`OpenAI API Key: ${openaiApiKey}`);

When you execute npm run start in your terminal, you should see your OpenAI key printed in the console.

Read full article here – https://www.telerik.com/blogs/learning-vercel-ai-sdk-part-1

I hope you find this article useful. Thanks for reading.

Also, we are hosting India’s First AI Conference focused on Developers, AI-India, on 12 April in Gurgaon. At AI-India 2026, you will learn these topics to level up your development skills.

 🏆14 Deep Dive Talks 

🎤 14 Esteemed Speakers 

📅 12 April 2026

📍Gurgaon, India 

Details – https://www.ai-india.ai/home

Hope to see you there.


Discover more from Dhananjay Kumar

Subscribe to get the latest posts sent to your email.

Published by Dhananjay Kumar

Dhananjay Kumar is founder of NomadCoder and ng-India

Leave a comment

Discover more from Dhananjay Kumar

Subscribe now to keep reading and get access to the full archive.

Continue reading