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

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

Related

More in LLM & Agentic

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

Unlock Premium