Claude's tool use API enables structured function calling and agent workflows. Master tool_use content blocks, tool_result messages, parallel tool use patterns, tool_choice control, prompt caching optimization, and streaming tool calls for production AI applications.
0 / 5 completed
1 / 5
The Anthropic API returns a response with content: [{type: "tool_use", id: "toolu_01", name: "get_weather", input: {location: "London"}}]. What must the developer do next?
When the API returns a tool_use content block, Claude is requesting that the developer execute the tool (call the actual function) and return the result. The developer sends a follow-up API call adding a user message with {type: "tool_result", tool_use_id: "toolu_01", content: "...result..."}}, after which Claude generates a final text response.
2 / 5
An API response contains multiple tool_use blocks in the same content array. What does this indicate?
Parallel tool use occurs when Claude determines multiple independent tools can be called simultaneously. The API returns multiple tool_use blocks in one response. The developer should execute all requested tools (ideally concurrently) and return all tool_result blocks in a single user message — improving efficiency by reducing round-trips.
3 / 5
A tool definition includes "cache_control": {"type": "ephemeral"} on the last tool in the tools array. What does this enable?
Placing cache_control on the last tool definition enables prompt caching for the entire tools block. Since tool definitions are often long (JSON Schema descriptions) and don't change between API calls, caching them reduces input token costs significantly on repeated requests — up to 90% savings on the tools portion of the prompt.
4 / 5
The API is called with tool_choice: {type: "any"}. How does this affect Claude's behavior?
tool_choice: {type: "any"} forces Claude to use at least one tool from the provided list, preventing a plain text response. This is useful when you want to guarantee structured output via tools regardless of the prompt. Other options: "auto" (Claude decides), "none" (no tools), {type: "tool", name: "..."} (specific tool required).
5 / 5
During streaming tool use, the API sends an event content_block_delta with delta: {type: "input_json_delta", partial_json: "{\"loc"}. What does this event represent?
During streaming, tool input JSON is delivered incrementally as input_json_delta events — each containing a fragment of the JSON string. Developers must accumulate these chunks and parse the complete JSON only after the content_block_stop event. This enables low-latency streaming even for tool use, though tool execution itself happens after the full input is assembled.