Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Docs: Quickstart fixes (#2192)
Co-authored-by: Soham <sohamganatra1@gmail.com>
Sushmitha Mallesh committed
Nov 22, 2025 at 21:52 UTC
81b5e56c1f291aae7a91a0bfb16f5975a52e59e7
4 files changed
+139
-109
fern/pages/src/get-started/quickstart.mdx
+17
-46
@@ -38,81 +38,52 @@ npm install @composio/core
38
```
39
</CodeGroup>
40
41
-## Initialize the SDK
42
-You’ll need to initialize the SDK with your Composio API key. This allows you to authenticate requests and access tools on behalf of your users.
43
-
44
-<CodeGroup>
45
-```python Python
46
-from composio import Composio
47
-
48
-composio = Composio(
49
- # api_key="your-api-key",
50
-)
51
-```
52
-```typescript TypeScript
53
-import { Composio } from '@composio/core';
54
-
55
-// Initialize the SDK
56
-const composio = new Composio({
57
- // apiKey: 'your-api-key',
58
-});
59
-```
60
-</CodeGroup>
61
-
62
-
41
## Authorize Tools & Run Them with an Agent
42
Composio supports multiple LLM providers. Here’s how to use Composio with some of the most popular ones:
43
<Tabs>
66
-<Tab title="OpenAI (Python)">
67
-Composio ships with support for OpenAI provider out of the box.
68
-<SnippetCode
69
- src="fern/snippets/get-started/python/quickstart.py"
70
- startLine={1}
71
- endLine={34}
72
-/>
73
-</Tab>
74
-<Tab title="Anthropic (Typescript)">
75
-You may install the Anthropic provider as well!
44
+<Tab title="OpenAI Agent(Python)">
45
+Install the OpenAI Agents provider!
46
47
**Installation**
48
```bash
79
-npm install @composio/anthropic
49
+pip install composio openai-agents composio-openai-agents
50
```
51
52
<SnippetCode
83
- src="fern/snippets/get-started/typescript/quickstart.ts"
53
+ src="fern/snippets/get-started/python/quickstart.py"
54
startLine={1}
85
- endLine={30}
55
+ endLine={46}
56
/>
87
-
57
</Tab>
89
-<Tab title="Vercel AI SDK (Typescript)">
90
-You may install the Vercel AI provider as well!
58
+<Tab title="Anthropic (TypeScript)">
59
+Install the Composio Anthropic provider
60
61
**Installation**
62
```bash
94
-npm install @composio/vercel
63
+npm i @composio/core @composio/anthropic
64
+npm i @anthropic-ai/sdk
65
```
66
67
<SnippetCode
98
- src="fern/snippets/get-started/typescript/vercel-quickstart.ts"
68
+ src="fern/snippets/get-started/typescript/quickstart.ts"
69
startLine={1}
100
- endLine={27}
70
+ endLine={57}
71
/>
72
73
</Tab>
104
-<Tab title="OpenAI Agents (Python)">
105
-You may install the OpenAI Agents provider as well!
74
+<Tab title="Vercel AI SDK (Typescript)">
75
+Install the Composio Vercel Provider
76
77
**Installation**
78
```bash
109
-pip install composio_openai_agents==0.8.0
79
+npm i @composio/core @composio/vercel
80
+npm i ai @ai-sdk/openai
81
```
82
83
<SnippetCode
113
- src="fern/snippets/get-started/python/quickstart-openai-agents.py"
84
+ src="fern/snippets/get-started/typescript/vercel-quickstart.ts"
85
startLine={1}
115
- endLine={46}
86
+ endLine={43}
87
/>
88
89
</Tab>
fern/snippets/get-started/python/quickstart.py
+43
-30
@@ -1,33 +1,46 @@
1
+import asyncio
2
from composio import Composio
2
-from openai import OpenAI
3
-
4
-openai = OpenAI()
5
-composio = Composio()
6
-user_id = "user@email.com"
7
-
8
-# Initialize connection request
9
-connection_request = composio.toolkits.authorize(user_id=user_id, toolkit="gmail")
10
-print(f"🔗 Visit the URL to authorize:\n👉 {connection_request.redirect_url}")
11
-
12
-# wait for the connection to be active
13
-connection_request.wait_for_connection()
14
-
15
-# Fetch tools
16
-tools = composio.tools.get(user_id=user_id, toolkits=["GMAIL"])
17
-
18
-# Invoke agent
19
-completion = openai.chat.completions.create(
20
- model="gpt-4o",
21
- messages=[
22
- {
23
- "role": "user",
24
- "content": "say 'hi from the composio quickstart' to soham@composio.dev",
25
- # we'll ship you free merch if you do ;)
26
- },
27
- ],
28
- tools=tools,
3
+from agents import Agent, Runner
4
+from composio_openai_agents import OpenAIAgentsProvider
5
+
6
+composio = Composio(api_key="your-api-key", provider=OpenAIAgentsProvider())
7
+
8
+# Id of the user in your system
9
+externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ad9ebc4"
10
+
11
+# Create an auth config for gmail from the dashboard or programmatically
12
+auth_config_id = "your-auth-config-id"
13
+connection_request = composio.connected_accounts.link(
14
+ user_id=externalUserId,
15
+ auth_config_id=auth_config_id,
16
)
17
31
-# Handle Result from tool call
32
-result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
33
-print(result)
18
+# Redirect user to the OAuth flow
19
+redirect_url = connection_request.redirect_url
20
+
21
+print(
22
+ f"Please authorize the app by visiting this URL: {redirect_url}"
23
+) # Print the redirect url to the user
24
+
25
+# Wait for the connection to be established
26
+connected_account = connection_request.wait_for_connection()
27
+print(
28
+ f"Connection established successfully! Connected account id: {connected_account.id}"
29
+)
30
+
31
+# Get Gmail tools that are pre-configured
32
+tools = composio.tools.get(user_id=externalUserId, tools=["GMAIL_SEND_EMAIL"])
33
+
34
+agent = Agent(
35
+ name="Email Manager", instructions="You are a helpful assistant", tools=tools
36
+)
37
+
38
+# Run the agent
39
+async def main():
40
+ result = await Runner.run(
41
+ starting_agent=agent,
42
+ input="Send an email to soham.g@composio.dev with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'",
43
+ )
44
+ print(result.final_output)
45
+
46
+asyncio.run(main())
\ No newline at end of file
fern/snippets/get-started/typescript/quickstart.ts
+47
-18
@@ -1,28 +1,57 @@
1
-import { Composio } from '@composio/core';
2
-import { AnthropicProvider } from '@composio/anthropic';
3
-import Anthropic from '@anthropic-ai/sdk';
1
+import { Composio } from "@composio/core";
2
+import { AnthropicProvider } from "@composio/anthropic";
3
+import Anthropic from "@anthropic-ai/sdk";
4
5
+// env: ANTHROPIC_API_KEY
6
const anthropic = new Anthropic();
6
-const composio = new Composio({ provider: new AnthropicProvider() });
7
-const userId = 'user@example.com';
7
9
-const connection = await composio.toolkits.authorize(userId, 'LINEAR');
10
-console.log(`🔗 Visit the URL to authorize:\n👉 ${connection.redirectUrl}`);
8
+const composio = new Composio({
9
+ apiKey: "your-api-key",
10
+ provider: new AnthropicProvider(),
11
+ toolkitVersions: {
12
+ "gmail": "20251111_00",
13
+ }
14
+});
15
+
16
+// Id of the user in your system
17
+const externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ad9ebc4";
18
+
19
+// Create an auth config for gmail from the dashboard or programmatically
20
+const authConfigId = "your-auth-config-id";
21
+
22
+const connectionRequest = await composio.connectedAccounts.link(
23
+ externalUserId,
24
+ authConfigId
25
+);
26
+
27
+// redirect the user to the OAuth flow
28
+const redirectUrl = connectionRequest.redirectUrl;
29
+console.log(`Please authorize the app by visiting this URL: ${redirectUrl}`);
30
12
-const tools = await composio.tools.get(userId, { toolkits: ['LINEAR'] });
13
-await connection.waitForConnection();
31
+// wait for connection to be established
32
+const connectedAccount = await connectionRequest.waitForConnection();
33
+console.log(
34
+`Connection established successfully! Connected account id: ${connectedAccount.id}`
35
+);
36
37
+// Fetch tools for your user and execute
38
+const tools = await composio.tools.get(externalUserId, {
39
+ tools: ["GMAIL_SEND_EMAIL"],
40
+});
41
+
42
+console.log(tools);
43
const msg = await anthropic.messages.create({
16
- model: 'claude-3-7-sonnet-latest',
17
- tools: tools,
44
+ model: "claude-sonnet-4-5",
45
messages: [
19
- {
20
- role: 'user',
21
- content: 'Get my linear projects',
22
- },
46
+ {
47
+ role: "user",
48
+ content: `Send an email to soham.g@composio.dev with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'`,
49
+ },
50
],
24
- max_tokens: 1024,
51
+ tools: tools,
52
+ max_tokens: 1000,
53
});
54
27
-const result = await composio.provider.handleToolCalls(userId, msg);
28
-console.log('✅ Tool results:', result);
55
+
56
+const res = await composio.provider.handleToolCalls(externalUserId, msg);
57
+console.log("Email sent successfully!");
fern/snippets/get-started/typescript/vercel-quickstart.ts
+32
-15
@@ -1,26 +1,43 @@
1
-import { Composio } from '@composio/core';
2
-import { generateText } from 'ai';
3
-import { anthropic } from '@ai-sdk/anthropic';
4
-import { VercelProvider } from '@composio/vercel';
5
-import { v4 as uuidv4 } from 'uuid';
1
+import { Composio } from "@composio/core";
2
+import { VercelProvider } from "@composio/vercel";
3
+import { generateText } from "ai";
4
+import { openai } from "@ai-sdk/openai";
5
7
-const userId = uuidv4(); // The user's ID.
6
const composio = new Composio({
9
- apiKey: process.env.COMPOSIO_API_KEY,
7
+ apiKey: "your-api-key",
8
provider: new VercelProvider(),
9
});
10
13
-const connection = await composio.toolkits.authorize(userId, 'gmail');
14
-console.log(`🔗 Visit the URL to authorize:\n👉 ${connection.redirectUrl}`);
11
+// Id of the user in your system
12
+const externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ac9ebc4";
13
16
-await connection.waitForConnection();
14
+// Create an auth config for gmail from the dashboard or programmatically
15
+const authConfigId = "your-auth-config-id";
16
18
-const tools = await composio.tools.get(userId, { tools: ['GMAIL_SEND_EMAIL'] });
17
+const connectionRequest = await composio.connectedAccounts.link(
18
+ externalUserId,
19
+ authConfigId
20
+);
21
22
+// redirect the user to the OAuth flow
23
+const redirectUrl = connectionRequest.redirectUrl;
24
+console.log(`Please authorize the app by visiting this URL: ${redirectUrl}`);
25
+
26
+// wait for connection to be established
27
+const connectedAccount = await connectionRequest.waitForConnection();
28
+
29
+const tools = await composio.tools.get(externalUserId, "GMAIL_SEND_EMAIL");
30
+
31
+// env: OPENAI_API_KEY
32
const { text } = await generateText({
21
- model: anthropic('claude-3-7-sonnet-20250219'),
22
- prompt: "say 'hi from the composio quickstart' to soham.g@composio.dev", // we'll ship you free merch if you do ;)
23
- tools,
33
+ model: openai("gpt-5"),
34
+ messages: [
35
+ {
36
+ role: "user",
37
+ content: `Send an email to soham.g@composio.dev with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'`,
38
+ },
39
+ ],
40
+ tools: tools // cast to `any` to fix type mismatch
41
});
42
26
-console.log(text);
43
+console.log("Email sent successfully!", { text });
\ No newline at end of file