Providers
Anthropic
Claude Agents SDK
Anthropic API
Install
pip install composio composio-anthropic anthropicnpm install dotenv @composio/core @composio/anthropic @anthropic-ai/sdkConfigure API Keys
Set COMPOSIO_API_KEY with your API key from Settings and ANTHROPIC_API_KEY with your Anthropic API key.
COMPOSIO_API_KEY=xxxxxxxxx
ANTHROPIC_API_KEY=xxxxxxxxxCreate session and run agent
import anthropic
from dotenv import load_dotenv
load_dotenv()
from composio import Composio
from composio_anthropic import AnthropicProvider
# Initialize Composio with Anthropic provider
anthropic_client = anthropic.Anthropic()
composio = Composio(provider=AnthropicProvider())
external_user_id = "user_2nFh83Hde"
recipient_email = "soham.g@composio.dev"
# Create a session
session = composio.create(user_id=external_user_id)
# Get tools from the session
tools = session.tools()
# Get response from the LLM
response = anthropic_client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1024,
tools=tools,
messages=[
{"role": "user", "content": f"Send an email to {recipient_email} with the subject 'Hello from Composio' and the body 'This is a test email!'"},
],
)
# Execute the function calls
result = composio.provider.handle_tool_calls(user_id=external_user_id, response=response)
print(result)import "dotenv/config";
import { Composio } from "@composio/core";
import { AnthropicProvider } from "@composio/anthropic";
import Anthropic from "@anthropic-ai/sdk";
// Initialize Composio with Anthropic provider
const composio = new Composio({
provider: new AnthropicProvider(),
});
const anthropic = new Anthropic();
const externalUserId = "user_2nFh83Hde";
const recipientEmail = "soham.g@composio.dev";
// Create a session
const session = await composio.create(externalUserId);
// Get tools from the session
const tools = await session.tools();
// Get response from the LLM
const msg = await anthropic.messages.create({
model: "claude-sonnet-4-5",
messages: [
{
role: "user",
content: `Send an email to ${recipientEmail} with the subject 'Hello from Composio' and the body 'This is a test email!'`,
},
],
tools: tools,
max_tokens: 1000,
});
// Execute the function calls
const result = await composio.provider.handleToolCalls(externalUserId, msg);
console.log(result);