Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Fix all small docs errors and some updates to Executing tools (#1881)
Co-authored-by: Soham <sohamganatra1@gmail.com>
Sushmitha Mallesh committed
Aug 30, 2025 at 05:59 UTC
d12566b60ef8aac6dd74685cfb2c2b73c4938d90
13 files changed
+137
-352
fern/docs/get-started/quickstart.mdx
deleted
-236
@@ -1,236 +0,0 @@
1
----
2
-title: Quickstart
3
-image: "https://og.composio.dev/api/og?title=Quickstart" # image for socials
4
-description: "Add authenticated tool-calling to any LLM agent in three steps."
5
-keywords: ""
6
-subtitle: ""
7
-hide-nav-links: true
8
----
9
-
10
-This guide covers authenticated tool calling, one of the most core features of Composio.
11
-You will learn how to:
12
-- Add tools to your AI agent
13
-- Authenticate the agent/tools for a user
14
-- Call the tools generated by the LLM
15
-
16
-**Before you start!**
17
-<Accordion title='Prerequisites'>
18
-1. Ensure you have created an account on [Composio](https://platform.composio.dev) and have Python 3.8+ _or_ NodeJS 16+ installed!
19
-2. Get your API key from the [developer dashboard](https://platform.composio.dev?next_page=/settings) and set it as an environment variable.
20
-```bash
21
-export COMPOSIO_API_KEY=your_api_key
22
-```
23
-<Note title="Note!">Ensure you save the API key in a `.env` file and don't commit it to version control!</Note>
24
-</Accordion>
25
-
26
-## Install the SDK
27
-First and foremost, install the Composio SDK.
28
-<CodeGroup>
29
-```typescript TypeScript
30
-npm install @composio/core
31
-```
32
-```python Python
33
-pip install composio==0.8.0
34
-```
35
-</CodeGroup>
36
-
37
-## Initialise
38
-
39
-To use the SDK, you need to initialize it with your API key:
40
-
41
-<CodeGroup>
42
-```typescript TypeScript
43
-import { Composio } from '@composio/core';
44
-
45
-// Initialize the SDK
46
-const composio = new Composio({
47
- // apiKey: 'your-api-key',
48
-});
49
-```
50
-```python Python
51
-from composio import Composio
52
-
53
-composio = Composio(
54
- # api_key="your-api-key",
55
-)
56
-```
57
-</CodeGroup>
58
-
59
-
60
-## Authorize and run tools
61
-<Tabs>
62
-<Tab title="OpenAI (Python)">
63
-Composio ships with support for OpenAI provider out of the box.
64
-```python maxLines=60
65
-from composio import Composio
66
-from openai import OpenAI
67
-
68
-openai = OpenAI()
69
-composio = Composio()
70
-user_id = "user@email.com"
71
-
72
-# Initialize connection request
73
-connection_request = composio.toolkits.authorize(user_id=user_id, toolkit="gmail")
74
-print(f"🔗 Visit the URL to authorize:\n👉 {connection_request.redirect_url}")
75
-
76
-# wait for the connection to be active
77
-connection_request.wait_for_connection()
78
-
79
-# Fetch tools
80
-tools = composio.tools.get(user_id=user_id, toolkits=["GMAIL"])
81
-
82
-# Invoke agent
83
-completion = openai.chat.completions.create(
84
- model="gpt-4o",
85
- messages=[
86
- {
87
- "role": "user",
88
- "content": "say 'hi from the composio quickstart' to sid@composio.dev",
89
- # we'll ship you free merch if you do ;)
90
- },
91
- ],
92
- tools=tools,
93
-)
94
-
95
-# Handle Result from tool call
96
-result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
97
-print(result)
98
-```
99
-</Tab>
100
-<Tab title="Anthropic (Typescript)">
101
-You may install the Anthropic provider as well!
102
-
103
-**Installation**
104
-```bash
105
-npm install @composio/anthropic
106
-```
107
-
108
-```typescript maxLines=60
109
-import { Composio } from "@composio/core";
110
-import { AnthropicProvider } from "@composio/anthropic";
111
-import Anthropic from "@anthropic-ai/sdk";
112
-
113
-const anthropic = new Anthropic();
114
-const composio = new Composio({
115
- provider: new AnthropicProvider(),
116
-});
117
-
118
-const userId = "user@example.com";
119
-const connection = await composio.toolkits.authorize(userId, "GITHUB");
120
-console.log(
121
- `🔗 Visit the URL to authorize:\n👉 ${connection.redirectUrl}`
122
-);
123
-
124
-await connection.waitForConnection();
125
-const msg = await anthropic.messages.create({
126
- model: "claude-3-7-sonnet-latest",
127
- tools: tools,
128
- messages: [
129
- {
130
- role: "user",
131
- content: "Star the composiohq/composio repository",
132
- },
133
- ],
134
- max_tokens: 1024,
135
-});
136
-
137
-const result = await composio.provider.handleToolCalls(userId, msg);
138
-console.log("✅ Tool results:", result);
139
-```
140
-</Tab>
141
-<Tab title="Vercel AI SDK (Typescript)">
142
-You may install the Vercel AI provider as well!
143
-
144
-**Installation**
145
-```bash
146
-npm install @composio/vercel
147
-```
148
-
149
-<SnippetCode
150
- src="fern/snippets/typescript/quickstart-vercel.ts"
151
- startLine={1}
152
- endLine={33}
153
- highlightStart={13}
154
- highlightEnd={18}
155
- title="Typescript (current)"
156
-/>
157
-</Tab>
158
-<Tab title="OpenAI Agents (Python)">
159
-You may install the OpenAI Agents provider as well!
160
-
161
-**Installation**
162
-```bash
163
-pip install composio_openai_agents==0.8.0
164
-```
165
-
166
-```python maxLines=60
167
-import asyncio
168
-
169
-from agents import Agent, Runner
170
-
171
-from composio import Composio
172
-from composio_openai_agents import OpenAIAgentsProvider
173
-
174
-# Initialize Composio toolset
175
-user_id = "user@email.com"
176
-composio = Composio(provider=OpenAIAgentsProvider())
177
-
178
-# Initialize connection request
179
-connection_request = composio.toolkits.authorize(user_id=user_id, toolkit="gmail")
180
-print(f"🔗 Visit the URL to authorize:\n👉 {connection_request.redirect_url}")
181
-
182
-# wait for the connection to be active
183
-connection_request.wait_for_connection()
184
-
185
-# Get all the tools
186
-tools = composio.tools.get(
187
- user_id=user_id,
188
- tools=["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"],
189
-)
190
-
191
-# Create an agent with the tools
192
-agent = Agent(
193
- name="GitHub Agent",
194
- instructions="You are a helpful assistant that helps users with GitHub tasks.",
195
- tools=tools,
196
-)
197
-
198
-
199
-# Run the agent
200
-async def main():
201
- result = await Runner.run(
202
- starting_agent=agent,
203
- input=(
204
- "Star the repository composiohq/composio on GitHub. If done "
205
- "successfully, respond with 'Action executed successfully'"
206
- ),
207
- )
208
- print(result.final_output)
209
-
210
-
211
-asyncio.run(main())
212
-```
213
-</Tab>
214
-</Tabs>
215
-
216
-<Note title="What just happened?">
217
-You authenticated your account through Composio and used LLMs to execute tools. Composio handled the OAuth flow and tool execution.
218
-</Note>
219
-
220
-
221
-## Next steps
222
-
223
-<CardGroup cols={2}>
224
- <Card title="Use Providers" icon="fa-solid fa-plug" href="/providers">
225
- Learn how to use Composio with various agent SDK and frameworks.
226
- </Card>
227
- <Card title="Work with tools" icon="fa-solid fa-toolbox" href="/docs/executing-tools">
228
- Learn how to work with tools and tool calling on a deeper level with Composio.
229
- </Card>
230
- <Card title="Manage authentication" icon="fa-solid fa-key" href="/docs/custom-auth-configs">
231
- Authorize tools for multiple users.
232
- </Card>
233
- <Card title="Triggers" icon="fa-solid fa-bolt" href="/docs/using-triggers">
234
- Listen for external events to trigger actions in your agents
235
- </Card>
236
-</CardGroup>
\ No newline at end of file
fern/pages/src/get-started/providers.mdx
+5
-5
@@ -224,7 +224,7 @@ With chat completion APIs, the typical flow is:
224
<Card
225
title="Gemini Provider"
226
icon={<img src="../../../assets/images/google-logo.svg" width="24" height="24" />}
227
- href="/providers/google-adk"
227
+ href="/providers/google"
228
>
229
Integrate with Google's Gemini models.
230
</Card>
@@ -235,11 +235,11 @@ These providers work with AI frameworks that can execute tools autonomously. The
235
236
<CardGroup cols={3}>
237
<Card
238
- title="LangGraph Provider"
238
+ title="LangChain Provider"
239
icon={<img src="../../../assets/images/langgraph-logo.svg"/>}
240
- href="/providers/langgraph"
240
+ href="/providers/langchain"
241
>
242
- Add tools to LangGraph agent flows.
242
+ Add tools to LangChain agent flows.
243
</Card>
244
<Card
245
title="CrewAI Provider"
@@ -272,5 +272,5 @@ These providers work with AI frameworks that can execute tools autonomously. The
272
</CardGroup>
273
274
<Tip title="Custom Providers" icon="puzzle">
275
-Using a framework not yet supported by Composio? Create a [custom provider](/providers/custom)!
275
+Using a framework not yet supported by Composio? Create a custom provider in [TypeScript](/providers/custom/typescript) or [Python](/providers/custom/python)!
276
</Tip>
fern/pages/src/get-started/quickstart.mdx
+11
-9
@@ -16,22 +16,24 @@ You'll learn how to:
16
17
Composio provides first-class SDKs for both **TypeScript** and **Python**, making it easy to integrate no matter what stack you're building with.
18
19
-**Before you start!**
20
-<Accordion title='Prerequisites'>
21
-1. Ensure you have created an account on [Composio](https://platform.composio.dev) and have Python 3.8+ _or_ NodeJS 18+ installed!
22
-2. Get your API key from the <a href="https://platform.composio.dev?next_page=/settings" target="_blank">developer dashboard</a> and set it as an environment variable.
19
+## Prerequisites
20
+
21
+Before you begin, ensure you have:
22
+
23
+1. **A Composio account** - [Sign up here](https://platform.composio.dev) if you haven't already
24
+2. **Python 3.8+** or **Node.js 18+** installed on your system
25
+3. **Your API key** - Get it from the [developer dashboard](https://platform.composio.dev?next_page=/settings) and set it as an environment variable:
26
+
27
```bash
28
export COMPOSIO_API_KEY=your_api_key
29
```
26
-<Note title="Note!">Ensure you save the API key in a `.env` file and don't commit it to version control!</Note>
27
-</Accordion>
30
31
## Install the SDK
32
First, install the Composio SDK for your preferred language:
33
34
<CodeGroup>
35
```bash title="Python" for="python"
34
-pip install composio==0.8.0
36
+pip install composio
37
```
38
```bash title="TypeScript" for="typescript"
39
npm install @composio/core
@@ -97,7 +99,7 @@ npm install @composio/vercel
99
<SnippetCode
100
src="fern/snippets/get-started/typescript/vercel-quickstart.ts"
101
startLine={1}
100
- endLine={34}
102
+ endLine={27}
103
/>
104
105
</Tab>
@@ -131,7 +133,7 @@ All OAuth flows and tool execution were automatically handled by Composio.
133
## Next steps
134
135
<CardGroup cols={2}>
134
- <Card title="Use Providers" icon="fa-solid fa-plug" href="/providers">
136
+ <Card title="Use Providers" icon="fa-solid fa-plug" href="/providers/openai">
137
Learn how to use Composio with various agent SDK and frameworks.
138
</Card>
139
<Card title="Work with tools" icon="fa-solid fa-toolbox" href="/docs/executing-tools">
fern/pages/src/get-started/welcome.mdx
+3
-3
@@ -12,13 +12,13 @@ hide-nav-links: false
12
13
Composio is the fastest way to enable your AI agents to take real-world actions—without dealing with individual API integrations, authentication flows, or complex tool formatting.
14
15
-- **Access 3000+ tools** out of the box across popular apps like Slack, GitHub, Notion, and more. [Browse tools →](/tools/)
15
+- **Access 3000+ tools** out of the box across popular apps like Slack, GitHub, Notion, and more. [Browse tools →](/toolkits/introduction)
16
- **Enforce strict access and data controls** with [fine-grained permissions](/docs/authenticating-tools) for each tool and user.
17
- **Trigger agents and workflows** using [external events](/docs/using-triggers) (e.g., new message in Slack, new issue in GitHub).
18
- **Customize tools** for your proprietary APIs or internal functions via [modifiers](/docs/modifiers/schema-modifiers).
19
- **Integrate seamlessly** with frameworks like OpenAI, Anthropic, LangChain, Vercel AI SDK, and more.
20
- **Enhance reliability** with [input/output processing hooks](/docs/modifiers/before-execution) to clean or transform data on the fly.
21
22
-No more writing dozens of bespoke integrations. Composio handles auth, tool normalization, and execution—so your agents can focus on reasoning, not plumbing.
22
+No more writing dozens of integrations. Composio handles auth, tool normalization, and execution—so your agents can focus on reasoning, not plumbing.
23
24
-**We even optimize tool calls automatically for better accuracy—free of cost.**
24
+**We even optimize tool calls automatically for better accuracy**
fern/pages/src/tool-calling/executing-tools.mdx
+33
-53
@@ -5,89 +5,69 @@ keywords: ""
5
subtitle: "Learn how to execute Composio's tools with different providers and frameworks"
6
hide-nav-links: false
7
---
8
+LLMs on their own can only do generation. Tool calling changes that by letting them interact with external services. Instead of just drafting an email, the model can call `GMAIL_SEND_EMAIL` to actually send it. The tool's results feed back to the LLM, closing the loop so it can decide, *act,* observe, and adapt.
9
9
-Tool calling is a feature of all frontier LLMs to allow them to interact with the outside world. Earlier you might be able to ask an LLM to write you a nice email, but you would have to manually send it. With tool calling, you can now provide an LLM a valid tool, for example, `GMAIL_SEND_EMAIL` to go and accomplish the task autonomously.
10
+
11
+In Composio, every **tool** is a single API action—fully described with schema, parameters, and return type. Tools live inside **toolkits** like *Gmail, Slack, or GitHub*, and Composio handles authentication and user scoping.
12
+
13
+
14
+<Tip icon="info">
15
+**User Scoping**: All tools are scoped to a specific user - that's why every example includes a `user_id`. Each user must authenticate with their respective services (Gmail, Calendar, etc.) before executing tools. [Learn more about authentication →](./authenticating-tools)
16
+</Tip>
17
18
## Using Chat Completions
12
-For non-agent providers—such as OpenAI, Anthropic, and Google AI—you can process tool calls using the tool call handlers provided by the Composio SDK.
13
-This approach works consistently across all supported non-agent providers.
19
15
-To learn how to setup these providers, see [Providers](/providers).
20
+With providers like *OpenAI*, *Anthropic*, and *Google AI*, use the Composio SDK to execute tool calls easily. To learn how to setup these providers, see [Providers](/providers/openai).
21
22
<CodeGroup>
23
<SnippetCode
24
src="fern/snippets/tool-calling/python/exec-tool-completions.py"
20
- startLine={1}
21
- endLine={30}
22
- title="Python (Google)"
25
+ title="Python (OpenAI)"
26
+ highlightStart={32}
27
+ highlightEnd={33}
28
/>
29
<SnippetCode
30
src="fern/snippets/tool-calling/typescript/exec-tool-completions.ts"
26
- startLine={1}
27
- endLine={30}
31
title="TypeScript (Anthropic)"
32
+ highlightStart={37}
33
+ highlightEnd={38}
34
/>
35
</CodeGroup>
36
37
## Using Agentic Frameworks
33
-Composio also has first-party support for agentic frameworks which execute tools, feed the result to the LLM and continue the conversation.
34
-
38
+Agentic frameworks automatically handle the tool execution loop.
39
+Composio provides support for frameworks like this by making sure the tools are formatted into the correct objects for the agentic framework to execute.
40
36
-<Tip icon="info">
37
-Here, the tool execution is handled by the agentic framework. Composio makes sure the tools are formatted into the correct objects for the agentic framework to execute.
38
-</Tip>
41
42
<CodeGroup>
43
<SnippetCode
44
src="fern/snippets/tool-calling/python/exec-tool-agentic.py"
43
- startLine={1}
44
- endLine={37}
45
title="Python (OpenAI Agents SDK)"
46
+ highlightStart={19}
47
+ highlightEnd={23}
48
/>
49
<SnippetCode
50
src="fern/snippets/tool-calling/typescript/exec-tool-agentic.ts"
49
- startLine={1}
50
- endLine={30}
51
title="TypeScript (Anthropic)"
52
+ highlightStart={22}
53
+ highlightEnd={31}
54
/>
55
</CodeGroup>
56
55
-## Tools are scoped to a user
56
-Each tool and tool action is scoped to a user. Hence, a `user_id` is required to fetch and execute tools.
57
-
58
-The authentication state is checked and used while fetching and executing a tool.
59
-
60
-You need to authorize the user to execute tools.
61
-For more information on authentication, see [Authenticating Tools](./authenticating-tools).
62
-
63
-## For Humans (deterministic tool calling)
64
-In case you just want to call a tool manually -- not using any framework or LLM provider, you can do so using the `execute` method.
65
-
57
+## Direct Tool execution
58
+In case you just want to call a tool without using any framework or LLM provider, you can use the `execute` method directly.
59
+<Tip icon="lightbulb">
60
+**Finding tool arguments**: Visit [Composio Toolkits](https://platform.composio.dev?next_page=/marketplace) → Select your toolkit -> Select tool to see its required and optional parameters, types, and descriptions.
61
+</Tip>
62
<CodeGroup>
67
-```python Python maxLines=60 wordWrap
68
-
69
-user_id = "user@example.com"
70
-composio = Composio()
71
-
72
-result = composio.tools.execute(
73
- "HACKERNEWS_GET_USER",
74
- user_id=user_id,
75
- arguments={"username": "pg"}
76
-)
77
-print(result)
78
-```
79
-```typescript TypeScript maxLines=60 wordWrap
80
-const userId = "user@example.com";
81
-const composio = new Composio();
82
-
83
-const result = await composio.tools.execute("HACKERNEWS_GET_USER", {
84
- userId,
85
- arguments: {
86
- username: "pg",
87
- },
88
-});
89
-console.log(result);
90
-```
63
+<SnippetCode
64
+ src="fern/snippets/tool-calling/python/direct-tool-call.py"
65
+ title="Python"
66
+/>
67
+<SnippetCode
68
+ src="fern/snippets/tool-calling/typescript/direct-tool-call.ts"
69
+ title="TypeScript"
70
+/>
71
</CodeGroup>
72
73
### Proxy Execute -- Manually calling toolkit APIs
fern/snippets/get-started/python/quickstart-openai-agents.py
+1
-1
@@ -7,7 +7,7 @@ from composio_openai_agents import OpenAIAgentsProvider
7
8
# Initialize Composio toolset
9
user_id = "user@email.com"
10
-composio = Composio(provider=OpenAIAgentsProvider())
10
+composio = Composio(provider=OpenAIAgentsProvider(), api_key="your-composio-api-key")
11
12
# Initialize connection request
13
connection_request = composio.toolkits.authorize(user_id=user_id, toolkit="github")
fern/snippets/get-started/typescript/vercel-quickstart.ts
+1
-7
@@ -19,14 +19,8 @@ const tools = await composio.tools.get(userId, { tools: ['GMAIL_SEND_EMAIL'] });
19
20
const { text } = await generateText({
21
model: anthropic('claude-3-7-sonnet-20250219'),
22
- messages: [
23
- {
24
- role: 'user',
25
- content: "say 'hi from the composio quickstart' to sid@composio.dev", // we'll ship you free merch if you do ;)
26
- },
27
- ],
22
+ prompt: "say 'hi from the composio quickstart' to soham.g@composio.dev", // we'll ship you free merch if you do ;)
23
tools,
29
- maxSteps: 3,
24
});
25
26
console.log(text);
fern/snippets/tool-calling/python/direct-tool-call.py
new
+12
@@ -0,0 +1,12 @@
1
+from composio import Composio
2
+
3
+user_id = "user-k7334"
4
+composio = Composio(api_key="your_composio_key")
5
+
6
+# Find available arguments for any tool in the Composio dashboard
7
+result = composio.tools.execute(
8
+ "GITHUB_LIST_STARGAZERS",
9
+ user_id=user_id,
10
+ arguments={"owner": "ComposioHQ", "repo": "composio", "page": 1, "per_page": 5}
11
+)
12
+print(result)
\ No newline at end of file
fern/snippets/tool-calling/python/exec-tool-agentic.py
+6
-8
@@ -2,14 +2,14 @@ import asyncio
2
from agents import Agent, Runner
3
from composio import Composio
4
from composio_openai_agents import OpenAIAgentsProvider
5
-from uuid import uuid4
5
7
-user_id = uuid4()
6
+# Use a unique identifier for each user in your application
7
+user_id = "user-k7334"
8
9
# Initialize Composio toolset
10
-composio = Composio(provider=OpenAIAgentsProvider())
10
+composio = Composio(provider=OpenAIAgentsProvider(), api_key="your_composio_api_key")
11
12
-# Get all the tools
12
+# Get all tools for the user
13
tools = composio.tools.get(
14
user_id=user_id,
15
toolkits=["COMPOSIO_SEARCH"],
@@ -22,14 +22,12 @@ agent = Agent(
22
tools=tools,
23
)
24
25
-
26
-# Run the agent
25
async def main():
26
result = await Runner.run(
27
starting_agent=agent,
30
- input=("Do a thorough DEEP research on Ilya Sutskever"),
28
+ input=("Do a thorough DEEP research on Golden Gate Bridge"),
29
)
30
print(result.final_output)
31
34
-
32
+# Run the agent
33
asyncio.run(main())
fern/snippets/tool-calling/python/exec-tool-completions.py
+26
-19
@@ -1,27 +1,34 @@
1
from composio import Composio
2
-from composio_gemini import GeminiProvider
3
-from google import genai
4
-from google.genai import types
2
+from composio_openai import OpenAIProvider
3
+from openai import OpenAI
4
+from datetime import datetime
5
6
-user_id = "0000-1111-2222"
6
+# Use a unique identifier for each user in your application
7
+user_id = "user-k7334"
8
9
# Create composio client
9
-composio = Composio(provider=GeminiProvider())
10
+composio = Composio(provider=OpenAIProvider(), api_key="your_composio_api_key")
11
11
-# Create google client
12
-client = genai.Client()
12
+# Create openai client
13
+openai = OpenAI()
14
+
15
+# Get calendar tools for this user
16
+tools = composio.tools.get(
17
+ user_id=user_id,
18
+ tools=["GOOGLECALENDAR_EVENTS_LIST"]
19
+)
20
14
-# Create genai client config
15
-config = types.GenerateContentConfig(
16
- tools=composio.tools.get(
17
- user_id=user_id,
18
- tools=[
19
- "COMPOSIO_SEARCH_DUCK_DUCK_GO_SEARCH",
20
- ],
21
- )
21
+# Ask the LLM to check calendar
22
+result = openai.chat.completions.create(
23
+ model="gpt-4o-mini",
24
+ tools=tools,
25
+ messages=[
26
+ {"role": "system", "content": "You are a helpful assistant."},
27
+ {"role": "user", "content": f"What's on my calendar for the next 7 days. Its {datetime.now().strftime("%Y-%m-%d")} today.",}
28
+ ]
29
)
30
24
-# Use the chat interface.
25
-chat = client.chats.create(model="gemini-2.0-flash", config=config)
26
-response = chat.send_message("What's new happening with Cluely?")
27
-print(response.text)
31
+
32
+# Handle tool calls
33
+result = composio.provider.handle_tool_calls(user_id=user_id, response=result)
34
+print(result)
\ No newline at end of file
fern/snippets/tool-calling/typescript/direct-tool-call.ts
new
+16
@@ -0,0 +1,16 @@
1
+import { Composio } from "@composio/core";
2
+
3
+const userId = "user-k7334";
4
+const composio = new Composio({apiKey: "your_composio_key"});
5
+
6
+// Find available arguments for any tool in the Composio dashboard
7
+const result = await composio.tools.execute("GITHUB_LIST_STARGAZERS", {
8
+ userId,
9
+ arguments: {
10
+ "owner": "ComposioHQ",
11
+ "repo": "composio",
12
+ "page": 1,
13
+ "per_page": 5
14
+ },
15
+});
16
+console.log('✅ GitHub stargazers:', JSON.stringify(result, null, 2));
\ No newline at end of file
fern/snippets/tool-calling/typescript/exec-tool-agentic.ts
+8
-5
@@ -3,28 +3,31 @@ import { generateText } from 'ai';
3
import { anthropic } from '@ai-sdk/anthropic';
4
import { VercelProvider } from '@composio/vercel';
5
6
-const userId = '0000-1111-2222-3333';
6
+// Use a unique identifier for each user in your application
7
+const userId = 'user-k7334';
8
9
+// Initialize Composio toolset
10
const composio = new Composio({
11
apiKey: process.env.COMPOSIO_API_KEY,
12
provider: new VercelProvider(),
13
});
14
15
+// Get all tools for the user
16
const tools = await composio.tools.get(userId, {
14
- toolkits: ['COMPOSIO_SEARCH'],
17
+ toolkits: ['HACKERNEWS_GET_LATEST_POSTS'],
18
limit: 10,
19
});
20
21
+// Generate a deep research on hackernews
22
const { text } = await generateText({
19
- model: anthropic('claude-3-7-sonnet-20250219'),
23
+ model: anthropic('claude-sonnet-4-20250514'),
24
messages: [
25
{
26
role: 'user',
23
- content: 'Do a thorough DEEP research on Ilya Sutskever',
27
+ content: 'Do a thorough DEEP research on the top articles on Hacker News about Composio',
28
},
29
],
30
tools,
27
- maxSteps: 5,
31
});
32
33
console.log(text);
fern/snippets/tool-calling/typescript/exec-tool-completions.ts
+15
-6
@@ -2,29 +2,38 @@ import { Composio } from '@composio/core';
2
import { AnthropicProvider } from '@composio/anthropic';
3
import { Anthropic } from '@anthropic-ai/sdk';
4
5
-const userId = '0000-1111-2222-3333'; // User's UUID
5
+// Use a unique identifier for each user in your application
6
+const userId = 'user-k7334';
7
8
+// Create anthropic client
9
const anthropic = new Anthropic();
10
+
11
+// Create Composio client
12
const composio = new Composio({
9
- apiKey: process.env.COMPOSIO_API_KEY,
13
+ apiKey: "your-composio-api-key",
14
provider: new AnthropicProvider(),
15
});
16
17
+// Get calendar tools for this user
18
const tools = await composio.tools.get(userId, {
14
- tools: ['COMPOSIO_SEARCH_DUCK_DUCK_GO_SEARCH'],
19
+ tools: ['GOOGLECALENDAR_EVENTS_LIST'],
20
});
21
22
+const today = new Date();
23
+
24
+// Ask the LLM to check calendar
25
const msg = await anthropic.messages.create({
18
- model: 'claude-3-7-sonnet-latest',
26
+ model: 'claude-sonnet-4-20250514',
27
tools: tools,
28
messages: [
29
{
30
role: 'user',
23
- content: "What's new with OpenAI?",
31
+ content: `What's on my calendar for the next 7 days starting today:${today.toLocaleDateString()}?`,
32
},
33
],
34
max_tokens: 1024,
35
});
36
37
+// Handle tool calls
38
const result = await composio.provider.handleToolCalls(userId, msg);
30
-console.log(result);
39
+console.log('Results:', JSON.stringify(result, null, 2));