Anthropic Provider

The Anthropic Provider transforms Composio tools into a format compatible with Anthropic’s function calling capabilities through its Messages API.

Setup

The Anthropic provider can be installed for both SDKs.

$pip install composio_anthropic==1.0.0rc9

You can specify the provider in the constructor. The constructor also takes in an optional cacheTools parameter.

1import anthropic
2
3from composio import Composio
4from composio_anthropic import AnthropicProvider
5
6# Initialize tools.
7anthropic_client = anthropic.Anthropic()
8composio = Composio(provider=AnthropicProvider())

Usage

1# Define your user ID
2user_id = "default"
3
4# Get GitHub tools that are pre-configured
5tools = composio.tools.get(user_id=user_id, toolkits=["GITHUB"])
6
7# Get response from the LLM
8response = anthropic_client.messages.create(
9 model="claude-3-5-sonnet-20240620",
10 max_tokens=1024,
11 tools=tools,
12 messages=[
13 {"role": "user", "content": "Star me composiohq/composio repo in github."},
14 ],
15)
16
17# Execute the function calls.
18result = composio.provider.handle_tool_calls(user_id=user_id, response=response)
19print(result)

Modifiers

Modifiers are functions that can be used to intercept and optionally modify the schema, the tool call request and the response from the tool call.

Anthropic provider modifiers are the standard framework modifiers. Read more here: Framework Modifiers.