claude api tools explained by example
zero cost ai
0:00 / 0:00
claude api tools explained by example
2 просмотра · 2 нед. назад
zero cost ai
1 подписчик
2 просмотра · 2 нед. назад
DESCRIPTION
Claude can't check your database or look up an order on its own. Tools fix that. In this beginner tutorial, you'll learn how Claude tool use works, the full tool use lifecycle with every stop_reason, and how the Tool Runner runs the loop for you.
We build a real order status assistant in Python: define a tool with a JSON schema, write the tool use loop by hand (tool_use, tool_result, end_turn), then replace it with the SDK's Tool Runner and the @beta_tool decorator, handle errors with is_error, and go through every stop_reason.
CHAPTERS
0:00 Introduction
0:22 What is a tool?
0:54 The tool use lifecycle
1:29 Anatomy of a tool call
1:54 When to use tools
2:15 Our use case
2:31 The problem: no tools
2:52 Step 1: Define the tool
3:20 Step 2: Run the loop
3:55 Step 3: Use the Tool Runner
4:27 Step 4: Handle errors
5:04 Step 5: Know stop reasons
5:47 Tips
6:18 Recap
FILES FROM THIS VIDEO
• The order bot code, an offline test (no API key needed) and a cheat sheet: https://tinyurl.com/2a4m7pv8
• All files from this video (with a step-by-step README): https://tinyurl.com/24eyzequ
THE TOOL USE LIFECYCLE
• You send messages + tools
• Claude replies with stop_reason "tool_use" and a tool_use block (id, name, input)
• You run the tool and send a tool_result with the same id
• Repeat while stop_reason is "tool_use"; "end_turn" means Claude has its answer
RESOURCES
• How tool use works (official docs): https://tinyurl.com/28q2va3r
• Tool Runner (SDK): https://tinyurl.com/23famg8y
• Stop reasons: https://tinyurl.com/2aam9nxy
ABOUT ZERO COST AI
Free AI apps and tutorials. I build AI tools and share them for free, along with beginner-friendly guides. Subscribe for more.
#ClaudeAPI #AItools #AItutorial #ZeroCostAI #FreeAI
TAGS
claude api, claude tool use, tool runner, stop_reason, anthropic api, claude function calling, ai agents, python ai tutorial, anthropic sdk, tool calling, ai tutorial, claude ai