Anthropic Provider

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

Setup

Anthropic provider can be installed for both the SDKs.

1npm install @composio/anthropic @anthropic-ai/sdk

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

1import { Composio } from "@composio/core";
2import { AnthropicProvider } from "@composio/anthropic";
3
4const composio = new Composio({
5 provider: new AnthropicProvider({
6 cacheTools: false, // default
7 }),
8});
9
10const anthropic = new Anthropic();

Usage

1const userId = "user@acme.com";
2const tools = await composio.tools.get(userId, {
3 tools: ["GITHUB_GET_OCTOCAT", "GITHUB_GET_THE_ZEN_OF_GITHUB"]
4})
5
6const msg = await anthropic.messages.create({
7 model: "claude-3-5-sonnet-20240620",
8 messages: [
9 {
10 role: "user",
11 content: "Get me the GitHub Octocat",
12 },
13 ],
14 tools: tools,
15 max_tokens: 1000,
16});
17
18const res = await composio.provider.handleToolCalls(userId, msg);
19
20console.log(JSON.parse(res[0]).details);

Streaming

  • Pending on SDK

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.