Overview
In this example, you’ll learn how to:- Initialize Composio with the Anthropic provider
- Use prompt caching for better performance
- Handle tool calls with Claude
- Process multi-turn conversations with tool results
Prerequisites
Complete Example
How It Works
Initialize with Anthropic Provider
We initialize Composio with the
AnthropicProvider, enabling prompt caching with cacheTools: true. This reduces latency and costs for repeated tool definitions.Fetch and Format Tools
The tools are automatically formatted to match Anthropic’s tool calling format, including the proper schema structure.
First Message with Tools
We send the initial message to Claude along with the available tools. Claude analyzes the request and decides whether to use any tools.
Execute Tool Calls
If Claude decides to use a tool, we extract the tool use blocks and execute them using Composio’s
handleToolCalls method.Expected Output
Key Features
Prompt Caching
Prompt Caching
The
cacheTools: true option enables Anthropic’s prompt caching feature, which caches tool definitions between requests. This significantly reduces latency and API costs for repeated tool usage.Multi-turn Conversations
Multi-turn Conversations
The example demonstrates how to handle multi-turn conversations where tool results are fed back to Claude for final processing.
Automatic Tool Formatting
Automatic Tool Formatting
Composio automatically converts tool schemas to Anthropic’s expected format, handling all the complexity of tool definition conversion.
Next Steps
LangChain Integration
Build agent workflows with LangChain
File Handling
Work with file attachments in tools