Use this file to discover all available pages before exploring further.
This example demonstrates how to integrate Composio tools with Anthropic’s Claude API, including support for prompt caching to improve performance and reduce costs.
We initialize Composio with the AnthropicProvider, enabling prompt caching with cacheTools: true. This reduces latency and costs for repeated tool definitions.
2
Fetch and Format Tools
The tools are automatically formatted to match Anthropic’s tool calling format, including the proper schema structure.
3
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.
4
Execute Tool Calls
If Claude decides to use a tool, we extract the tool use blocks and execute them using Composio’s handleToolCalls method.
5
Follow-up Message
We send the tool results back to Claude in a follow-up message, allowing it to generate a final response based on the data.
🔄 Fetching tools from Composio...✅ Fetched 1 tools🔄 Creating message with Anthropic...✅ Message created, processing tool calls if any...✅ Found 1 tool calls✅ Tool results: [...]🔄 Extracting the text response from the follow-up message...✅ Final response:Based on the HackerNews profile for user 'pg' (Paul Graham), here's a summary:Paul Graham is a highly influential figure in the tech community with over 150,000 karma points...
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
The example demonstrates how to handle multi-turn conversations where tool results are fed back to Claude for final processing.
Automatic Tool Formatting
Composio automatically converts tool schemas to Anthropic’s expected format, handling all the complexity of tool definition conversion.