Versus · AI tools

Claude Agent SDK vs messages.create: which one should you build with?

We read every plan page. Paid links are labelled. Money never changes a ranking. How we pick.

Verdict Our pick

The bar guide has a call.

The vectaai bar guide pointing at the verdict
  • Use messages.create (the Messages API, through the anthropic client SDK) when you want one model call at a time and full control: you send the messages, you get Claude's next message back, and if you give it tools, you run them and write the loop.
  • Use the Claude Agent SDK (claude-agent-sdk on PyPI, @anthropic-ai/claude-agent-sdk on npm) when you want an agent that does the work: Anthropic's docs say it gives you the same tools, agent loop and context management that power Claude Code, with file editing, shell commands, web search, hooks, subagents, MCP, permissions and sessions built in.

Compared here

  • 01Claude Agent SDK
  • 02Messages API (messages.create)

Short answer

Use messages.create (the Messages API, through the anthropic client SDK) when you want one model call at a time and full control: you send the messages, you get Claude's next message back, and if you give it tools, you run them and write the loop. Use the Claude Agent SDK (claude-agent-sdk on PyPI, @anthropic-ai/claude-agent-sdk on npm) when you want an agent that does the work: Anthropic's docs say it gives you the same tools, agent loop and context management that power Claude Code, with file editing, shell commands, web search, hooks, subagents, MCP, permissions and sessions built in.

Rule of thumb: chat features, classification, extraction, summaries and anything in a web request handler, use messages.create. Code agents, file-heavy automation and long multi-step tasks on a machine you control, use the Agent SDK. Both bill against your API key. One rule to know before you ship: Anthropic does not allow third-party products to offer claude.ai login or subscription rate limits unless previously approved, so your users cannot sign in with their Claude plan. Below: the differences in a table, code for both, and the in-between options.

At a glance

From Anthropic's Agent SDK overview and quickstart (code.claude.com), the Messages API reference and the SDKs overview (platform.claude.com), read 4 December 2026.
Claude Agent SDKmessages.create (Client SDK)
What it isA library that runs the Claude Code binary as an agentOne HTTP call: POST /v1/messages
Who runs the tool loopThe SDKYou (or the beta tool runner)
Built-in toolsRead, write, edit files, run commands, web searchNone; you define tools as JSON Schema
StateSessions: keep context, resume or forkStateless; send full history each time
LanguagesPython 3.10+, TypeScript (Node 18.14+); other languages via the CLIPython, TypeScript, C#, Go, Java, PHP, Ruby
Installpip install claude-agent-sdk / npm install @anthropic-ai/claude-agent-sdkpip install anthropic / npm install @anthropic-ai/sdk
ExtrasHooks, subagents, MCP, permissions, skills, pluginsStreaming, retries, errors, OpenTelemetry
AuthAPI key, or Bedrock, Claude Platform on AWS, Google Cloud, Microsoft FoundryAPI key (x-api-key)
Best forCoding and file agents, automation on your machineApp features, request-response, tight control

Money first. Nobody pays us for this page. Anthropic has no affiliate program we know of, there are no /go/ links here, and display ads may appear around it. The FTC's disclosure guide asks us to say so; we would anyway.

How we wrote it: everything below comes from Anthropic's own docs, read on 4 December 2026: the Agent SDK overview, the Agent SDK quickstart, the Messages API reference and the SDKs overview. Package versions and model names move monthly; check the docs before you pin anything. We did not benchmark the two for speed or cost.

The one-sentence difference

messages.create asks Claude a question. The Agent SDK hires Claude to do a job.

That is it. Everything else is detail. With messages.create you get one answer and decide what happens next. With the Agent SDK, Claude reads files, runs commands, checks its own work and keeps going until the task is done or it hits a wall.

What "create message" actually is

The search phrase "create message" means the Messages API's create call: client.messages.create(...) in the Python or TypeScript client SDK, or a raw POST /v1/messages. Anthropic's reference says it takes a structured list of input messages (text and/or images) and returns the model's next message.

Three required parameters:

  • model, for example claude-sonnet-4-6 in the reference example,
  • max_tokens, the most it may generate,
  • messages, each with a role (user or assistant) and content.

The key word in the reference is stateless. The API stores no conversation. For a multi-turn chat, you send the whole history every time. The system prompt goes in a top-level system parameter, not as a message.

# pip install anthropic   (set ANTHROPIC_API_KEY)
import anthropic

client = anthropic.Anthropic()
message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello, Claude"}],
)
print(message.content[0].text)

Tools with messages.create. You can give it tools, defined with a name, description and JSON Schema input_schema. Claude may answer with a tool_use block. Then you run the tool, and send the result back in a user message as a tool_result block with the matching tool_use_id. Then you call create again. That back-and-forth is the "tool loop", and with the client SDK it is your code. The SDKs overview mentions a beta tool runner in the client SDK that can drive that loop for you.

Streaming. Set stream: true for server-sent events, or use messages.stream() in the TypeScript, Python and Ruby SDKs, which collects the events into the final message for you.

Client SDKs exist for Python, TypeScript, C#, Go, Java, PHP and Ruby, with streaming, retries, error handling and OpenTelemetry tracing built in.

What the Claude Agent SDK actually is

Anthropic's overview describes it as building "production AI agents with Claude Code as a library". It gives you "the same tools, agent loop, and context management that power Claude Code, programmable in Python and TypeScript."

Practically: the package bundles a native Claude Code binary on most installs, and your code drives it. Capabilities listed in the overview:

  • Built-in tools: read, write and edit files, run commands, search the web.
  • Hooks: run your code at key points in the agent's lifecycle.
  • Subagents: spawn focused helper agents for subtasks.
  • MCP: connect external tools and data through the Model Context Protocol.
  • Permissions: decide which tools run automatically and which need approval.
  • Sessions: keep context across exchanges, resume or fork later.
  • Skills, commands and memory loaded from .claude/ folders, same as Claude Code.
  • Plugins bundling skills, agents, hooks and MCP servers.

Here is the quickstart's agent, trimmed. It reviews a file for crash bugs and fixes them:

# pip install claude-agent-sdk   (Python 3.10+, set ANTHROPIC_API_KEY)
import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, ResultMessage

async def main():
    async for message in query(
        prompt="Review utils.py for bugs that would cause crashes. Fix any issues you find.",
        options=ClaudeAgentOptions(
            allowed_tools=["Read", "Edit", "Glob"],
            permission_mode="acceptEdits",
        ),
    ):
        if isinstance(message, AssistantMessage):
            for block in message.content:
                if hasattr(block, "text"):
                    print(block.text)
        elif isinstance(message, ResultMessage):
            print(f"Done: {message.subtype}")

asyncio.run(main())

Notice what is missing: no tool definitions, no tool execution code, no loop logic. The docs put it plainly: "Claude executes tools directly instead of asking you to implement them."

Side by side, in plain words

QuestionAgent SDKmessages.create
Who decides the next step?Claude, inside the SDK's loopYour code
Can it edit files on disk?Yes, built inOnly if you write that tool
Can it run shell commands?Yes, with Bash allowedOnly if you write that tool
Does it remember the conversation?Yes, sessionsNo, you resend history
How predictable is one call?Less: it may take many stepsVery: one request, one answer
Where does it run?A process you operate, with the Claude Code binaryAnywhere you can make an HTTPS call
LanguagesPython, TypeScript; others via the CLISeven official client SDKs

When messages.create wins

  • Inside a web app's request. A user clicks "summarise", you need an answer in a second or two. One call, done.
  • Predictable costs. One request, one bill line. You can estimate it.
  • Structured jobs. Classification, extraction, tagging, rewriting. No files, no shell, no loop needed.
  • Languages other than Python and TypeScript. Go, Java, C#, PHP and Ruby have first-class client SDKs.
  • You want full control. Every tool call passes through your code, so you can log, filter and refuse it.

When the Agent SDK wins

  • Code agents. Fix bugs, write tests and run them, refactor a repo. This is literally what it was built from.
  • File-heavy automation. Reading a folder of documents, editing configs, generating reports to disk.
  • Long multi-step tasks where you do not know the steps in advance.
  • You want Claude Code's safety rails (permission modes, allow and deny rules, hooks) without rebuilding them.
  • CI and internal tools. Anthropic's docs have a hosting guide for Docker, cloud and CI/CD.

The in-between options

The overview names four ways to run Claude, not two:

  1. Claude Code CLI: the terminal tool for interactive work. Not for embedding.
  2. Agent SDK: Claude Code's agent inside your own Python or TypeScript process.
  3. Client SDK: direct API calls, you write the loop, or use the beta tool runner.
  4. Managed Agents: Anthropic hosts the agent harness and runs the loop in an Anthropic-managed cloud sandbox or a self-hosted sandbox, reached through the client SDKs, the ant CLI or the REST API.

If you want an agent but do not want to operate the machine it runs on, Managed Agents is the option to read about next. If you want agent behaviour from Go or Java, the overview says to run the Claude Code CLI as a subprocess with -p and --output-format json.

Auth and the subscription rule

Both use an API key from the Claude Console. The Agent SDK quickstart also lists Amazon Bedrock (CLAUDE_CODE_USE_BEDROCK=1), Claude Platform on AWS, Google Cloud's Agent Platform (CLAUDE_CODE_USE_VERTEX=1) and Microsoft Foundry (CLAUDE_CODE_USE_FOUNDRY=1). One gotcha from the quickstart: the SDK does not load .env files by itself. Load the key yourself or export it in the shell.

The rule that catches people: the Agent SDK docs say that, unless previously approved, Anthropic does not allow third-party developers to offer claude.ai login or rate limits in their products, including agents built on the Agent SDK. So you cannot build an app where users plug in their Claude Pro or Max plan. Usage goes through your API key, and you pay per token. Our Claude API vs subscription page explains how those two billing worlds differ.

Branding, if you ship it

The overview has branding rules for products built on the Agent SDK. Allowed: "Claude Agent", "Claude" inside a menu already labelled Agents, or "YourAgentName Powered by Claude". Not allowed: calling it "Claude Code" or "Claude Code Agent", or copying Claude Code's look. Use is governed by Anthropic's Commercial Terms.

Verdict

  • Pick messages.create if you are adding an AI feature to an app: a reply, a summary, a label, a chat. It is simpler, cheaper per call and works in seven languages.
  • Pick the Claude Agent SDK if you want Claude to do multi-step work with files and commands on a machine you run, and you would otherwise end up rebuilding Claude Code's loop, tools and permissions by hand.
  • Use both if your product has both kinds of feature. That is common, and it is fine.

Shopping around? See autonomous AI coding agents, open source AI coding agents, or the full AI tools category.

Questions people ask

What is the difference between the Claude Agent SDK and the Messages API?

The Messages API is one call: you send messages, Claude returns its next message, and nothing is remembered. The Agent SDK wraps the Claude Code agent: it plans steps, calls built-in tools like Read, Edit and Bash, loops until the task is done, and keeps sessions. Anthropic's overview says with the Client SDK you write the tool loop yourself.

Is the Claude Agent SDK the same as the Anthropic Python SDK?

No. The Anthropic Python SDK is the package named anthropic, a general Messages API client. The Agent SDK is claude-agent-sdk, which runs Claude Code as a library, and bundles a native Claude Code binary on most installs. Different packages, different jobs, same API key.

Can users log in with their Claude Pro or Max plan in my Agent SDK app?

Not unless Anthropic approved it. The Agent SDK docs say Anthropic does not allow third-party developers to offer claude.ai login or rate limits for their products, including agents built on the Agent SDK, and point you to API key authentication instead. Your app pays for usage through the API key.

Do I still need messages.create if I use the Agent SDK?

Often, yes. Many apps use both: messages.create for quick, cheap, predictable calls like tagging or summarising, and the Agent SDK for the heavy agent jobs that need files and commands. Mixing is normal. Pick per feature, not per project.

Is the Agent SDK more expensive than messages.create?

Both bill tokens on your API account. An agent usually costs more per task, because it loops: reading files, calling tools and re-sending context many times. A single messages.create call costs exactly one request. Our Claude API vs subscription page covers how API billing works in general.

Can I use the Agent SDK from Go or Java?

Not as a library today. The Agent SDK is Python and TypeScript. Anthropic's overview says to drive the same agent loop from another language, run the Claude Code CLI as a subprocess with the -p flag and --output-format json. For plain API calls, client SDKs exist for C#, Go, Java, PHP and Ruby too.

Sources

Every fact above comes from these pages. Prices change, so each one carries the date we read it.

  1. Claude Code docs: Agent SDK overview, checked 4 Dec 2026
  2. Claude Code docs: Agent SDK quickstart, checked 4 Dec 2026
  3. Claude Platform docs: Messages API reference (POST /v1/messages), checked 4 Dec 2026
  4. Claude Platform docs: SDKs, CLI and libraries overview, checked 4 Dec 2026
  5. FTC: Disclosures 101 for social media influencers, checked 4 Dec 2026