No history yet

Setting Up Claude Agent SDK

Setting Up Your Workshop

Before you can build powerful AI agents, you need to set up your digital workspace. The Claude Agent SDK is a toolkit that provides the foundational building blocks for creating agents. Think of it as preparing your workbench with all the necessary tools before starting a project. This initial setup is straightforward and gets you ready for development.

The Claude Agent SDK gives you the same framework that powers Claude Code itself—built-in tools, agent loop structure, and production-ready patterns.

Let's get everything installed and configured.

Installation

The SDK is a Python package, which makes installation simple. If you have Python and its package installer, pip, on your system, you can install it with a single command in your terminal.

pip install claude-agent-sdk

This command downloads and installs the latest version of the SDK, along with any other packages it depends on. With the tools now on your machine, the next step is to connect them to your Anthropic account.

Configuration

To use the SDK, your application needs to authenticate with Anthropic's services. This is done using an API key, which is a unique secret code that identifies you as a developer. You can get your API key from the Anthropic developer console.

Once you have your key, you need to set it as an environment variable. This allows the SDK to access the key securely without you having to write it directly into your code. In your terminal, you can set the variable like this:

export ANTHROPIC_API_KEY="YOUR_API_KEY_HERE"

Remember to replace YOUR_API_KEY_HERE with your actual key. This command sets the variable for your current terminal session. To make it permanent, you can add this line to your shell's startup file, like .bashrc or .zshrc.

SDK Components

Now that you're set up, let's look at the main parts of the SDK. You don't need to know how to use them yet, just what they are. Understanding the purpose of each component will help you see how they fit together to create a working agent.

ComponentWhat It Does
AgentThe core of your application. The Agent class manages the conversation, processes user requests, and decides which tools to use.
ToolA specific capability you give to your agent. A tool is essentially a function the agent can call to perform an action, like searching a file or accessing a database.
SessionRepresents a single, continuous interaction with the agent. It keeps track of the conversation history and state.

With your environment ready and a basic understanding of the key components, you now have a solid foundation for building your first skill.