Chapter 2

Quickstart

Get started with the Python or TypeScript Agent SDK to build AI agents that work autonomously.

Use the Agent SDK to build an AI agent that reads your code, finds bugs, and fixes them—all without manual intervention.

What you'll do:

  • Set up a project with the Agent SDK
  • Create a file with some buggy code
  • Run an agent that finds and fixes the bugs automatically

Prerequisites

Node.js 18+ or Python 3.10+An Anthropic account (sign up here) →

Setup

1

Install Claude Code

The Agent SDK uses Claude Code as its runtime. Install it for your platform:

curl -fsSL https://claude.ai/install.sh | bash

After installing Claude Code onto your machine, run claude in your terminal and follow the prompts to authenticate. The SDK will use this authentication automatically.

For more information on Claude Code installation, see Claude Code setup.

2

Create a project folder

Create a new directory for this quickstart:

mkdir my-agent && cd my-agent

For your own projects, you can run the SDK from any folder; it will have access to files in that directory and its subdirectories by default.

3

Install the SDK

Install the Agent SDK package for your language:

npm install @anthropic-ai/claude-agent-sdk
4

Set your API key

If you've already authenticated Claude Code (by running claude in your terminal), the SDK uses that authentication automatically.

Otherwise, you need an API key, which you can get from the Claude Console.

Create a .env file in your project directory and store the API key there:

ANTHROPIC_API_KEY=your-api-key

Using Amazon Bedrock, Google Vertex AI, or Microsoft Azure? See the setup guides for Bedrock, Vertex AI, or Azure AI Foundry.

Note: Unless previously approved, Anthropic does not allow third party developers to offer claude.ai login or rate limits for their products, including agents built on the Claude Agent SDK. Please use the API key authentication methods described in this document instead.