
The Claude Agent SDK, explained for people who build websites
The Agent SDK is Claude Code as a library: the same tools, agent loop and context handling, in Python or TypeScript. What it does, how it differs from Claude Code and the API, what it costs, and the agents worth building first.
We build client websites with Claude Code every day, and the question we now hear from clients and other developers is the next one: can the same thing run without anyone sitting at the terminal? That is what the Claude Agent SDK is for. Most of what ranks for it is either reference documentation or an explainer written for AI engineers. This one is for people who run or build websites, and every detail below was checked against Anthropic's own documentation on 9 November 2026.
What is the Claude Agent SDK?
The Claude Agent SDK is Claude Code as a library. Anthropic describes it as the same tools, agent loop and context management that power Claude Code, programmable in Python and TypeScript. You call one function, query, with a prompt and a set of options, and the SDK streams messages back while Claude plans, reads files, runs commands and edits code, until the task is finished or it hits an error.
The difference from calling the Claude API directly is who writes the loop. With the API you send a message and get a reply, and if the reply asks for a tool, you run the tool yourself and send the result back. The Agent SDK ships that loop already written, along with the built-in tools Claude Code uses: reading, writing and editing files, running shell commands, searching files and searching the web.
How is it different from Claude Code and the Claude API?
| Option | Who runs it | Use it when |
|---|---|---|
| Claude Code | You, interactively, in a terminal, IDE, desktop app or browser | A person is at the keyboard doing the work |
| Agent SDK | Your own process, in Python or TypeScript | Your code starts the task: a schedule, a webhook, a pipeline |
| Claude API | Your own process; you write the tool loop | You need full control or no agent at all |
| Managed Agents | Anthropic's infrastructure, configured through the API | You want the loop hosted for you |
For a website business the line that matters is the second one. Claude Code is for when a person is driving. The Agent SDK is for when something else starts the work: a nightly schedule, a form submission, a new item in a CMS, a pull request.
How do you install the Claude Agent SDK?
The packages are @anthropic-ai/claude-agent-sdk on npm and claude-agent-sdk on PyPI, and they need Node.js 18.14 or later, or Python 3.10 or later. Both bundle a native Claude Code binary, so most installs need nothing else. Set ANTHROPIC_API_KEY in the environment of the process that runs the agent. The SDK does not read .env files on its own, which is the first thing that catches people out: a key that works in your terminal and fails in a scheduled job usually lives in a file the job never loaded. The quickstart walks through a first agent that finds and fixes bugs in a file.
In code, the core is small. You import query, pass a prompt, and set the two options that matter more than any others: allowedTools, the tools the agent may use without asking, and permissionMode, how much it may do unattended. Everything else, from a custom system prompt to MCP servers, hangs off the same options object.
What does the Claude Agent SDK cost?
The library is free; the model use is not. The SDK authenticates with a Claude Console API key, or through Amazon Bedrock, Google Cloud, Microsoft Foundry or Claude Platform on AWS, and each bills per token. At Anthropic's current API prices, Claude Sonnet 5.5 is $2 per million input tokens and $10 per million output tokens, Claude Opus 5.5 is $4 and $20, and Claude Haiku 5.5 is $0.10 and $0.50 for prompts up to 100,000 tokens. A read-only audit of a small site is cheap at those rates; an agent that rereads a large codebase every hour is not.
What you cannot do is ship an agent that logs in with a Claude subscription. Anthropic's documentation says that, unless previously approved, third-party developers may not offer claude.ai login or rate limits in their products, including agents built on the SDK. Your Pro or Max plan covers your own Claude Code use; an agent that runs for a client, or inside a product, runs on an API key. Use of the SDK is governed by Anthropic's Commercial Terms of Service.
What changed when the Claude Code SDK was renamed?
If you built on the older Claude Code SDK, three things change. The packages were renamed from @anthropic-ai/claude-code and claude-code-sdk. The Python options class ClaudeCodeOptions became ClaudeAgentOptions. And since version 0.1.0 the SDK no longer uses Claude Code's system prompt by default: it starts with a minimal one, and you ask for Claude Code's behaviour explicitly with the claude_code preset. The migration guide has the before and after for both languages.
One more default deserves attention because it surprises people in the other direction. Unless you pass settingSources: [], the SDK loads the same filesystem settings the CLI does: your user settings, the project's .claude folder and its CLAUDE.md files. On your laptop that is convenient. On a server running agents for several clients, it means one project's instructions can leak into another's run, so isolate each one.
What should a website business build with it first?
Something read-only, on a schedule. The agents that pay back fastest on a website are the ones that check rather than change:
- A weekly site audit that reads your own pages, flags missing titles, broken internal links, oversized images and pages that dropped out of the sitemap, and writes a report.
- A form and integration check that submits a test enquiry to every form and confirms it reached the CRM, because a form can fail silently for weeks.
- A content brief agent that reads Search Console exports and drafts briefs for the questions you are close to ranking for.
- A pull request reviewer that checks a site change against the project's CLAUDE.md before a person looks at it.
Each of these needs only Read, Glob, Grep and web fetching, and none of them needs permission to edit. That is deliberate. An unattended agent with write access to a live site is a different risk from one at your desk, and the permissions system is where you decide which tools run without approval.
Do hooks, skills and subagents work in the SDK?
Yes, and that is the main reason to use it rather than writing your own loop. The SDK supports the same hooks, subagents, MCP servers, sessions, skills and plugins as Claude Code. A team already using Claude Code can carry its setup across: the hooks that block risky commands, the subagents that split a build, the MCP servers that connect a CMS and the CLAUDE.md that sets the project's rules all load the same way.
Where does an Agent SDK agent run?
Wherever your code runs: a scheduled job, a container, a CI pipeline or a small server. Anthropic's hosting guide covers Docker, cloud and CI setups. If you would rather not run the process at all, Managed Agents is Anthropic's hosted alternative, configured through the API. For most small website teams, a scheduled job in the CI they already use is enough, and it runs next to the code it checks.
What can you call an agent built on it?
Not Claude Code. Anthropic's branding guidance for the SDK allows Claude Agent, or your own agent's name followed by Powered by Claude, and rules out Claude Code, Claude Code Agent and anything that imitates Claude Code's look. Using Claude branding at all is optional, and the product should read as yours rather than as an Anthropic product.
When is the Agent SDK the wrong tool?
When a person is going to review every step anyway. If the work is building or changing a site with someone watching, Claude Code itself is the better interface, with the diffs, approvals and history in front of you. The SDK earns its place when the work has to happen without anyone opening a terminal, and when the same task runs often enough that writing it down once pays off. If you are not sure which of your recurring tasks qualify, that is the conversation our AI automation work starts with.

