Guide Claude AI complete
Tool Use, System Prompts, API & Extended Thinking
Everything you need to know about Claude from Anthropic — what sets it apart, how to write System Prompts that work, Tool Use step by step, and how to build smart agents with the API.
What is Claude?
Claude is a large language model (LLM) from Anthropic — an AI company founded in 2021 by former OpenAI employees, led by Dario Amodei and Daniela Amodei. Anthropic's DNA is AI Safety — building safer, more honest and more transparent models.
Claude is considered one of the strongest competitors to GPT-4o, and in several areas — especially coding, document analysis and long-context understanding — it simply wins.
The current versions (April 2026)
What sets Claude apart?
- A 200K-token context window — about 150,000 words. Enough for a whole book, a large codebase, or a very long conversation
- Constitutional AI — Claude was designed to answer honestly, admit mistakes, and refuse harmful requests politely and with explanation
- Artifacts — generating code files, SVG, React components, HTML directly from the chat with Preview
- Analytical honesty — Claude is less prone to "sycophancy" than competing models
- Extended Thinking — a deep-thinking mode for complex problems (in Claude Sonnet 4.6)
Quick comparison: Claude vs ChatGPT vs Gemini
| Criterion | Claude Sonnet 4.6 | GPT-4o | Gemini 2.5 Pro |
|---|---|---|---|
| Context Window | 200K | 128K | 2M 🏆 |
| coding | Excellent 🏆 | Great | Great |
| Hebrew | Good | Great 🏆 | Good |
| Honesty & transparency | Excellent 🏆 | Good | Good |
| Tool Use / Agents | Excellent 🏆 | Great | Good |
| Extended Thinking | Yes | o1 / o3 | Yes 🏆 |
| Artifacts / Canvas | Artifacts 🏆 | Canvas | No |
A roadmap to mastering Claude
Here is a structured learning path — from Zero to building advanced agents with the Claude API. Each step builds on the previous one.
System Prompts in Claude — depth and practice
A System Prompt is the instruction sent to Claude before every conversation with the user. This is where you define who it is, what it knows, and what its boundaries are.
What makes System Prompts special in Claude?
Claude "takes the System Prompt seriously" more than competing models. It will not try to bypass it, andConstitutional AI ensures it acts according to built-in values even when someone tries to persuade it otherwise.
Anthropic trained Claude on a "constitution" — a system of ethical principles. When Claude receives an instruction that contradicts the constitution, it will refuse gently and explain why. This makes it more reliable in Production environments that require consistency.
Best Practices for a System Prompt
- A clear role — "you are an expert in X" works better than general instructions
- XML Tags — Claude responds excellently to tags like
<context>,<instructions>,<examples> - Response format — specify whether you want Markdown, JSON, short lists
- Negative boundaries — "do not answer X" works well in Claude, unlike some models
- Examples — Few-shot examples in the System Prompt dramatically improve consistency
A full template for a Claude agent
You are [role] assisting [organization/user].
<context>
[background on the company, product, or user]
</context>
<capabilities>
Skills:
- [skill 1]
- [skill 2]
- [skill 3]
</capabilities>
<constraints>
Constraints:
- Do not answer questions unrelated to [topic]
- Always [important rule]
- If you don't know, say "I don't know" and do not make things up
</constraints>
<format>
Response format:
Use Markdown. Be concise but complete.
Always end with: "Is there anything else you'd like to know?"
</format>
Unlike GPT-4o which responds well to Markdown headers, Claude responds better to XML Tags inside the System Prompt. Anthropic even recommends this in the official documentation — it "understands" the structure and uses it to split the instructions into clear segments.
Tool Use / Function Calling — in depth
Tool Use (also called Function Calling) is Claude's ability to call external functions you define. Instead of answering from memory, Claude can query a database, call an API, send an email, or perform any action you write for it.
The Tool Use lifecycle
stop_reason: "tool_use" with the tool name and parametersFull Python code — Tool Use
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-...")
# Define tools
tools = [
{
"name": "get_weather",
"description": "Returns current weather for a given city",
"input_schema": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "City name in English, e.g.: Tel Aviv"
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "Temperature unit"
}
},
"required": ["city"]
}
}
]
# First call — Claude picks a tool
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
tools=tools,
messages=[
{"role": "user", "content": "What's the weather in Tel Aviv today?"}
]
)
# check if Claude requested a tool
if response.stop_reason == "tool_use":
tool_use = next(
b for b in response.content if b.type == "tool_use"
)
print(f"Claude requested: {tool_use.name}")
print(f"Parameters: {tool_use.input}")
# run our function
tool_result = get_weather(
tool_use.input["city"],
tool_use.input.get("unit", "celsius")
)
# send the result back to Claude
final_response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
tools=tools,
messages=[
{"role": "user", "content": "What's the weather in Tel Aviv today?"},
{"role": "assistant", "content": response.content},
{
"role": "user",
"content": [{
"type": "tool_result",
"tool_use_id": tool_use.id,
"content": str(tool_result)
}]
}
]
)
print(final_response.content[0].text)
Multi-turn Tool Use
In Multi-turn Tool Use, Claude can call several tools in sequence. For example: "Find all the leads that didn't respond this week, send them a follow-up email, and update the CRM". Claude manages the sequence itself.
1. You forgot to send the tool_result back — Claude will wait for the answer and won't continue. 2. An error in the JSON Schema — Claude won't be able to understand the tool. 3. An inaccurate description — Claude will pick the wrong tool.
Extended Thinking
Extended Thinking is a special mode in Claude Sonnet 4.6 that lets the model "think out loud" before answering. Similar to Chain of Thought, but at a larger scale — with a dedicated token budget for thinking.
How is it different from regular Chain of Thought?
- A defined budget — you control how much "thinking time" Claude gets (
budget_tokens) - Internal thinking — the thinking blocks aren't sent to the user (you can read them in debug)
- Much better results — on math, code and complex-logic problems
- Higher cost — every thinking token costs money, plan accordingly
When to use Extended Thinking?
- Complex math problems and algorithms
- debugging code with deep bugs
- legal / strategic analysis with complex trade-offs
- scientific questions that require multi-step reasoning
Code — enabling Extended Thinking
import anthropic
client = anthropic.Anthropic(api_key="sk-ant-...")
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=16000,
thinking={
"type": "enabled",
"budget_tokens": 10000 # the token budget for thinking
},
messages=[{
"role": "user",
"content": """
I have a system of 3 servers. Server A is down 40% of the time,
server B is down 70% of the time, server C is down 20% of the time.
What is the probability that at least two servers are running simultaneously?
Explain the solution step by step.
"""
}]
)
# iterate over blocks (there is a thinking block + text block)
for block in response.content:
if block.type == "thinking":
print("--- internal thinking process ---")
print(block.thinking[:500], "...") # print part
elif block.type == "text":
print("--- final answer ---")
print(block.text)
Simple problem: 1,000–3,000. Medium problem: 5,000–10,000. Very complex problem: up to 32,000. Note thatmax_tokens must be greater thanbudget_tokens.
Artifacts, Computer Use & Vision
Artifacts — creating directly from the chat
Artifacts is a feature unique to Claude.ai that lets you create files with a real-time Preview. When you ask Claude to write code, it opens a separate Panel with an editor + preview.
- HTML/CSS/JS — sites and apps that run directly in the browser
- React Components — interactive components with state
- SVG — vector graphics, diagrams, logos
- Markdown — formatted content for management
- Code Files — Python, TypeScript, SQL and more
Write "create an Artifact of..." to force Claude to open the Artifact Panel. Without that word, it sometimes writes code inline in the chat.
Computer Use — Claude controls the computer
Computer Use is an experimental capability that lets Claude receive screenshots of the screen and perform actions — mouse clicks, typing, scrolling. It sees the screen and responds to it.
- Automatic form filling without an API
- Navigating complex websites
- Automated UI tests (E2E testing)
- Automating business processes that have no API
Vision API — analyzing images and documents
import anthropic
import base64
client = anthropic.Anthropic(api_key="sk-ant-...")
# read the image
with open("screenshot.png", "rb") as f:
image_data = base64.standard_b64encode(f.read()).decode("utf-8")
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": image_data,
},
},
{
"type": "text",
"text": "What is in the image? Describe every detail."
}
],
}]
)
print(response.content[0].text)
Claude API — the technical guide
Installation & Authentication
# Python
pip install anthropic
# TypeScript / Node.js
npm install @anthropic-ai/sdk
# Environment variable (recommended — not in code!)
export ANTHROPIC_API_KEY="sk-ant-api03-..."
Messages API — all the parameters
import anthropic
client = anthropic.Anthropic() # reads from ANTHROPIC_API_KEY
message = client.messages.create(
model="claude-sonnet-4-6", # model
max_tokens=1024, # max tokens in the response
system="You are a helpful assistant.", # System Prompt
messages=[
{
"role": "user",
"content": "What is the difference between ML and AI?"
}
]
)
print(message.content[0].text)
print(f"Input tokens: {message.usage.input_tokens}")
print(f"Output tokens: {message.usage.output_tokens}")
Streaming — real-time responses
import anthropic
client = anthropic.Anthropic()
# Streaming
with client.messages.stream(
model="claude-sonnet-4-6",
max_tokens=1024,
messages=[{"role": "user", "content": "Write a short story"}]
) as stream:
for text in stream.text_stream:
print(text, end="", flush=True)
TypeScript SDK
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const message = await client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
system: "You are a helpful assistant.",
messages: [
{ role: "user", content: "Hello Claude!" }
],
});
console.log(message.content[0].text);
Pricing table — April 2026
| Model | Input (per 1M) | Output (per 1M) | Context | Recommended for |
|---|---|---|---|---|
| Claude Sonnet 4.6 | $3.00 | $15.00 | 200K | General Production, code |
| Claude Haiku 4.5 | $0.80 | $4.00 | 200K | High volume, chatbots |
| Claude Sonnet 4.6 | $3.00 | $15.00 | 200K | Extended Thinking |
| Claude Opus 4.6 | $15.00 | $75.00 | 200K | Legacy only |
5 hands-on projects with Claude
Here are 5 projects ranked by difficulty — from Hello World to a full Multi-Agent System.
Claude reads a PDF and extracts structured information — names, dates, amounts, action items.
import anthropic, base64, json
client = anthropic.Anthropic()
def analyze_document(pdf_path: str) -> dict:
with open(pdf_path, "rb") as f:
pdf_data = base64.standard_b64encode(f.read()).decode()
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=2048,
system="""You are a professional document analyst.
Extract from the document and return JSON with the fields:
- summary: a short summary (2-3 sentences)
- key_dates: an array of important dates
- action_items: an array of action items
- parties: the names of the involved parties""",
messages=[{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data
}
},
{"type": "text", "text": "Analyze this document"}
]
}]
)
return json.loads(response.content[0].text)
result = analyze_document("contract.pdf")
print(result)
An agent that reviews Pull Requests, identifies issues, and suggests concrete improvements — including code examples.
import anthropic
client = anthropic.Anthropic()
REVIEWER_SYSTEM = """You are a senior engineer performing a Code Review.
For every issue you find, provide:
1. a description of the issue
2. severity level: CRITICAL / MAJOR / MINOR
3. a corrected code example
Check: performance, security, readability, Best Practices."""
def review_code(code: str, language: str = "python") -> str:
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=3000,
system=REVIEWER_SYSTEM,
messages=[{
"role": "user",
"content": f"Do a Code Review on the following code ({language}):\n\n```{language}\n{code}\n```"
}]
)
return response.content[0].text
with open("my_code.py") as f:
code = f.read()
review = review_code(code)
print(review)
A support agent connected to a CRM — pulls customer details, reads inquiry history, and updates tickets in real time.
crm_tools = [
{
"name": "get_customer_info",
"description": "Pulls customer details by ID number",
"input_schema": {
"type": "object",
"properties": {
"customer_id": {"type": "string"}
},
"required": ["customer_id"]
}
},
{
"name": "create_ticket",
"description": "Opens a new support ticket",
"input_schema": {
"type": "object",
"properties": {
"customer_id": {"type": "string"},
"subject": {"type": "string"},
"priority": {
"type": "string",
"enum": ["low", "medium", "high", "critical"]
}
},
"required": ["customer_id", "subject", "priority"]
}
}
]
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=2048,
system="You are a professional support rep. You have access to a CRM. Answer customers warmly and professionally.",
tools=crm_tools,
messages=[{
"role": "user",
"content": "Hi, customer number 12345 is complaining that their order didn't arrive"
}]
)
Claude fills forms, navigates sites, and runs automations on a real screen without an API.
import anthropic
client = anthropic.Anthropic()
# Computer Use tools built into Claude
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
tools=[
{
"type": "computer_20241022",
"name": "computer",
"display_width_px": 1920,
"display_height_px": 1080
}
],
messages=[{
"role": "user",
"content": "Open the browser, go to google.com and search for 'Anthropic Claude'"
}]
)
# Claude returns screenshot actions — clicks, keystrokes, etc.
for block in response.content:
if hasattr(block, "type") and block.type == "tool_use":
print(f"Action: {block.name} — {block.input}")
Claude Sonnet 4.6 as the Orchestrator + Claude Haiku 4.5 as Workers to optimize cost and speed.
import anthropic, json
client = anthropic.Anthropic()
def orchestrate(task: str) -> list:
"""Sonnet splits into small tasks"""
resp = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
system="Split the task into 3 subtasks. Return JSON only: {\"subtasks\": [...]}",
messages=[{"role": "user", "content": task}]
)
return json.loads(resp.content[0].text)["subtasks"]
def execute_subtask(subtask: str) -> str:
"""Haiku runs each subtask — cheap and fast"""
resp = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=512,
messages=[{"role": "user", "content": subtask}]
)
return resp.content[0].text
# run
subtasks = orchestrate("Write a marketing report on a new AI product")
results = [execute_subtask(s) for s in subtasks]
print("\n\n".join(results))
Cheat sheet — Claude API
Models & Model IDs
| Model ID | Name | When |
|---|---|---|
| claude-sonnet-4-6 | Sonnet 4.6 | Most cases + Extended Thinking |
| claude-haiku-4-5-20251001 | Haiku 4.5 | Fast and cheap |
| claude-opus-4-6 | Opus 4.6 | Legacy only |
API Endpoints
# Base URL
https://api.anthropic.com/v1/
# Messages (primary)
POST /messages
# Required headers
x-api-key: sk-ant-...
anthropic-version: 2023-06-01
content-type: application/json
Tool Use Boilerplate — Python
import anthropic
client = anthropic.Anthropic()
def run_tool_loop(user_message: str, tools: list, tool_runner) -> str:
"""An automatic Tool Use loop"""
messages = [{"role": "user", "content": user_message}]
while True:
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=4096,
tools=tools,
messages=messages
)
if response.stop_reason != "tool_use":
# Claude is done — return the final answer
return response.content[0].text
# add Claude's response to the history
messages.append({"role": "assistant", "content": response.content})
# run every tool it requested
tool_results = []
for block in response.content:
if block.type == "tool_use":
result = tool_runner(block.name, block.input)
tool_results.append({
"type": "tool_result",
"tool_use_id": block.id,
"content": str(result)
})
messages.append({"role": "user", "content": tool_results})
Quick Prompt Templates
Summarize the following document in 3 points.
Each point: maximum 20 words.
Format: a numbered list.
<document>
{{DOCUMENT}}
</document>
Extract structured JSON from the following text.
Return JSON only, no explanation.
Schema:
{name, email, phone, company}
Text: {{TEXT}}
Do a Code Review. Note:
- Security issues (CRITICAL)
- Performance issues (MAJOR)
- Readability improvements (MINOR)
```{{LANGUAGE}}
{{CODE}}
```
Translate and improve the phrasing.
Keep a {{TONE}} tone.
Maximum {{MAX_WORDS}} words.
Original text:
{{TEXT}}
Ready to start?
Go to claude.ai and try the interface for free, or get an API key at console.anthropic.com and start building with the examples from this guide.