1:1 mentoring with Big Tech AI engineers
LLM & Agentic

Tool Use with Claude

Implement tool use with Claude API: define tools, handle tool calls, and build reliable function-calling agents.

Last updated

Core5 min readFirst readMessages APIHow LLMs Call Tools

After this section you can

  • Run the full four-step tool handshake across two API calls
  • Use parallel tool calls, and force a specific tool when the task demands it
  • Write tool definitions Claude actually selects correctly
28

Tool Use: Giving Claude Superpowers

Tools are how Claude reaches past its training data — to your database, the web, a calculator, an action. This is the exact request/response contract, plus the tool-design skill that separates agents that work from agents that thrash.

THE CENTRAL IDEA

Claude never runs your code. When it decides a tool is needed, it emits a structured tool_use block — a JSON request saying “please run get_weather(city="Paris") and tell me the result.” Your code runs the function and hands back a tool_result. That’s the whole mechanism, and it’s a two-message handshake, not a function call. The agent loop (a separate section) just repeats this handshake until Claude is done; here we master the single exchange and, more importantly, how to design the tools so Claude picks the right one.

The tool-use handshake — four steps, two API calls
Your code messages + tools[] executes functions Claude decides & requests Real world DB · API · search calculator · action 1 · messages + tool schemas 2 · stop_reason=tool_use + args 3 · your code runs the function 4 · tool_result → API again → answer

Related

More in LLM & Agentic

Get full access to all 74+ sections with code examples, diagrams, and interactive animations.

Unlock Premium