สถานะ: 🟢 Complete | อัพเดท: 2026-06-27
Claude Agent SDK
คืออะไร
Claude Agent SDK คือ library สำหรับสร้าง AI agents ที่ใช้ Claude — handle agentic loop, tool routing, multi-agent coordination
เริ่มต้น (Python)
pip install anthropicimport anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
tools=[{
"name": "get_weather",
"description": "Get weather for a city",
"input_schema": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}],
messages=[{"role": "user", "content": "อากาศกรุงเทพวันนี้เป็นยังไง?"}]
)Tool Loop
หลังจาก Claude ตอบมาพร้อม tool_use block ต้องรัน tool แล้วส่งผลลัพธ์กลับด้วย tool_result message
ดูตัวอย่างเต็มที่ Tool Use API