Skip to content
EN DE

Level 1: AI SDK Basics — Briefing

The AI SDK is your toolkit for AI applications. In this level you’ll learn the fundamentals: generating text, streaming, structured output and system prompts. One API for all providers — Anthropic, OpenAI, Google and 20+ more.

Skill Tree — Level 1 AI SDK Basics is the current level
  • What the AI SDK is and how it’s structured — three libraries, one unified interface
  • How to choose and configure an LLM model — provider system, model instances, switching providers
  • Generating text with generateText — the result object, usage tracking, finish reason
  • Streaming text with streamText — real-time output, stream events, textStream
  • Structured output with Output.object, Output.array and Output.choice — typed JSON responses instead of free text
  • System prompts for role behavior — giving the LLM an identity and rules

Every AI application builds on these fundamentals. Without them, you’re stuck copy-pasting from ChatGPT and can’t programmatically integrate AI into your projects.

The concrete problem: You want to integrate AI into your code, but every provider has a different API, different types, different error handling. The AI SDK solves this — one unified API for all providers. You’ll learn it here from the ground up.

  • Node.js 18+ and npm installed — check with node -v and npm -v
  • TypeScript basics — types, interfaces, async/await
  • Experience with ChatGPT or similar — you know what an LLM is and what it can do
  • An API key for at least one provider:

All providers offer free starter credits or a free tier. For Level 1, a single API key is enough.

Create a project directory for this level. Each challenge is saved as its own TypeScript file, and the Boss Fight combines everything into a final file.

Terminal window
mkdir level-1-ai-sdk && cd level-1-ai-sdk
npm init -y
npm install ai @ai-sdk/anthropic zod
npm install -D tsx typescript

Create a .env file for your API key (automatically loaded by tsx):

Terminal window
echo 'ANTHROPIC_API_KEY=sk-ant-your-key-here' > .env

This is how you run your TypeScript files:

Terminal window
npx tsx challenge-1-1.ts

tsx is a TypeScript runner that executes .ts files directly — no tsconfig.json, no build step, with automatic .env support.

  • “API key not found” — Check that your .env file exists and the key is correct: cat .env
  • “Cannot use import statement” — Use npx tsx instead of node to run files
  • “Module not found” — Check that all packages are installed: npm ls ai @ai-sdk/anthropic zod

Skip hint: You already use the AI SDK daily and know generateText, streamText and Output.object? Jump straight to the Boss Fight and test your knowledge.

Build a CLI chat: A terminal program that outputs text in real time with streamText and delivers structured JSON output with Output.object on request. You’ll combine all six building blocks of this level into one project.

Part of AI Learning — free courses from prompt to production. Jan on LinkedIn