Skip to content
Agent Builder
Module 5Full course10 min read

Project Setup: SDKs, Keys, and Your First API Call

Set up a TypeScript project, store your API key safely, and make your first model call — with a Python equivalent for every step.

Every agent you've used so far — Claude Code, ChatGPT, Cursor — is, underneath, a program making API calls to a language model in a loop. In this module you'll write that program yourself, one piece at a time, until you have a real agent that reads and writes files, browses the web, calls APIs, streams its progress, and recovers from errors.

This first lesson gets the foundation right: a clean TypeScript project, an API key stored where it can't leak, and your first successful call to Claude. It's ten minutes of setup that saves you hours of confusing errors later. Every step has a Python equivalent, so you can follow along in either language.

What you're building in this module

Over six lessons you'll grow one project, my-agent, from a single API call into a capable agent. Each lesson extends the code from the previous one, so keep the same folder throughout.

LessonWhat you addMain file
1. Project setupA working project and your first model callsrc/hello.ts
2. A minimal agent loopThe loop: call model, run tools, repeatsrc/agent.ts
3. Adding real toolsFiles, web pages, and a weather APIsrc/tools.ts
4. Streaming and UXLive output in a terminal and a web pagesrc/cli.ts, src/server.ts
5. Errors and stop conditionsRetries, tool errors, limits, and budgetssrc/agent.ts
6. Using an agent SDKThe same agent, rebuilt on the Claude Agent SDKsrc/sdk-agent.ts

You'll use the Anthropic API directly through its official TypeScript SDK, @anthropic-ai/sdk. If you've read Tools and Function Calling, you already know the concepts. This module turns them into code you own.

You need Node.js 22 or newer (check with node --version); Node 20 reached end of life in April 2026, and the --env-file flag you'll use below needs a modern Node anyway and a terminal. If you set up your toolkit in Setting Up Your Agent Toolkit, you're ready.