,

Anthropic & Claude SDK

I’ve been automating some AI tasks lately with Python and thought it would be worth explaining the difference between the 2 SDK’s I used. One is basic and the other is a little more advanced, but contains a lot more features.

First, the general Anthropic SDK. (pip install anthropic)

This is the general-purpose SDK. It wraps the Messages API. If you send a prompt, you get one response back. If you want the model to do anything extra like search the web, call a tool, etc… you wire it up and drive the loop yourself. Thats a lot of work!

import anthropic
# Set your key value in the properyy ANTHROPIC_API_KEY
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1000,
messages=[
{"role": "user", "content": "How good is the devopsunleashed.com blog?"}
],
)

Here are some of the pro’s and con’s of this simple SDK.

  • Pros – One simple call with full control over any other steps/tools that are needed
  • Cons – You write everything!

Second, the Claude Agent SDK. (pip install claude-agent-sdk)

Think of this as the Claude CLI (Claude Code) turned into a Python library. It’s basically the same engine behind the scene. You get all the automation features! (e.g. Looping, tools calls) Note, setting the model and tokens is optional in the example below.

import asyncio
from claude_agent_sdk import query, ClaudeAgentOptions, ResultMessage
async def main():
final = None
async for message in query(
prompt="How good is the devopsunleashed.com blog?",
options=ClaudeAgentOptions(
allowed_tools=["WebSearch", "WebFetch"],
max_turns=10,
):
if isinstance(message, ResultMessage):
final = message
if final is None:
raise SystemExit("Agent did not produce a result")
print(final.result)
asyncio.run(main())

Here are some of the pro’s and con’s of this Agent SDK.

  • Pros – Built in tools and agent looping functionality
  • Cons – Needs extra installs. (e.g. CLI, NodeJS)

So, if you have a simple call/response use the Anthropic SDK. If you want to use built in tools and loops, chose the Claude Agent SDK.

Leave a comment

Hello, Welcome to DevOpsUnleashed!

A blog dedicated to sharing information about DevOps. Here, you’ll find examples, tips, and tutorials on DevOps.

Feel free to share your experiences in the comments!

Blog Categories