Vercel AI SDKAI SDK 7 · TypeScript · Node.js 20+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
17 small wins to finish your pathNext lesson

Installation and setup

The AI SDK comes from npm as a core package plus one package per model provider. Groq and Google each have a provider package and a free key.

ai, zod, @ai-sdk/openai and tsx

This course needs Node.js 20 or later. zod describes schemas for tools and typed output, @ai-sdk/openai is the OpenAI provider, and tsx runs a TypeScript file directly: every lesson is a file run with npx tsx file.ts.

bash
node --version
npm install ai zod @ai-sdk/openai
npm install --save-dev tsx

A provider package for a free modelOptional

The course uses a stand-in model from lesson 4, so no key is needed to follow along. A real model means installing its provider package and setting the variable it reads; lesson 3 shows the error when that variable is missing.

bash
npm install @ai-sdk/groq
ProviderKeyVariablePackage and model
GroqFree, console.groq.com/keysGROQ_API_KEY@ai-sdk/groq, groq("openai/gpt-oss-120b")
GeminiFree, aistudio.google.com/apikeyGOOGLE_GENERATIVE_AI_API_KEY@ai-sdk/google, google("gemini-2.5-flash")
OpenRouterFree models end in :free, openrouter.ai/keysOPENROUTER_API_KEY@openrouter/ai-sdk-provider, openrouter("google/gemma-4-31b-it:free")
OpenAIPaid, platform.openai.com/api-keysOPENAI_API_KEY@ai-sdk/openai, openai("gpt-4.1-mini")
export GROQ_API_KEY=gsk_...
typescript
import { generateText } from "ai";
import { groq } from "@ai-sdk/groq";

const { text } = await generateText({
  model: groq("openai/gpt-oss-120b"),
  prompt: "Say hello",
});
console.log(text);

Next.js loads .env.local for you and keeps it out of git; a plain script needs the variable exported first.

Try it yourself
  • Run npm ls ai and check the installed version.

Little by little, you're building something great.