Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
feat(docs): add framework selector to quickstart page
- Add QuickstartFlow and FrameworkOption components for framework switching - Support OpenAI Agents, Claude Agents, LangChain, and Vercel AI - Code snippets match platform snippets exactly - Python/TypeScript tabs with language persistence - Clean component design without unnecessary wrappers Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sushmithamallesh committed
Jan 20, 2026 at 15:33 UTC
696f813f47705fbcbf8600601fb8806879ceb7b1
6 files changed
+666
-223
docs/app/global.css
-1
@@ -472,7 +472,6 @@ nav a[href*="app.composio"]:focus-visible {
472
--color-fd-primary: var(--composio-orange);
473
}
474
475
-
475
@layer base {
476
* {
477
@apply border-border outline-ring/50;
docs/components/quickstart/framework-selector.tsx
new
+107
@@ -0,0 +1,107 @@
1
+'use client';
2
+
3
+import Image from 'next/image';
4
+import { useState } from 'react';
5
+
6
+export type Framework =
7
+ | 'openai-agents'
8
+ | 'claude-agents'
9
+ | 'langchain'
10
+ | 'vercel-ai';
11
+
12
+interface FrameworkOption {
13
+ id: Framework;
14
+ name: string;
15
+ logo: string;
16
+}
17
+
18
+const frameworks: FrameworkOption[] = [
19
+ {
20
+ id: 'openai-agents',
21
+ name: 'OpenAI Agents',
22
+ logo: '/images/providers/openai-logo.svg',
23
+ },
24
+ {
25
+ id: 'claude-agents',
26
+ name: 'Claude Agents',
27
+ logo: '/images/providers/anthropic-logo.svg',
28
+ },
29
+ {
30
+ id: 'langchain',
31
+ name: 'LangChain',
32
+ logo: '/images/providers/langchain-logo.svg',
33
+ },
34
+ {
35
+ id: 'vercel-ai',
36
+ name: 'Vercel AI',
37
+ logo: '/images/providers/vercel-logo.svg',
38
+ },
39
+];
40
+
41
+interface FrameworkCardProps {
42
+ framework: FrameworkOption;
43
+ selected: boolean;
44
+ onSelect: () => void;
45
+}
46
+
47
+function FrameworkCard({ framework, selected, onSelect }: FrameworkCardProps) {
48
+ return (
49
+ <button
50
+ type="button"
51
+ onClick={onSelect}
52
+ className={`
53
+ flex flex-col items-start gap-4 rounded-xl border-2 p-5 text-left transition-all
54
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500 focus-visible:ring-offset-2
55
+ ${selected
56
+ ? 'border-[var(--composio-orange)] bg-fd-card'
57
+ : 'border-fd-border bg-fd-card hover:bg-fd-accent/50'
58
+ }
59
+ `}
60
+ >
61
+ <div className="flex h-10 w-10 shrink-0 items-center justify-center">
62
+ <Image
63
+ src={framework.logo}
64
+ alt={`${framework.name} logo`}
65
+ width={40}
66
+ height={40}
67
+ className="h-8 w-auto dark:invert"
68
+ />
69
+ </div>
70
+
71
+ <span className="text-sm font-medium text-fd-foreground">
72
+ {framework.name}
73
+ </span>
74
+ </button>
75
+ );
76
+}
77
+
78
+interface FrameworkSelectorProps {
79
+ value?: Framework;
80
+ onChange?: (framework: Framework) => void;
81
+}
82
+
83
+export function FrameworkSelector({ value = 'openai-agents', onChange }: FrameworkSelectorProps) {
84
+ const [selected, setSelected] = useState<Framework>(value);
85
+
86
+ const handleSelect = (framework: Framework) => {
87
+ setSelected(framework);
88
+ onChange?.(framework);
89
+ };
90
+
91
+ return (
92
+ <div className="not-prose">
93
+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
94
+ {frameworks.map((framework) => (
95
+ <FrameworkCard
96
+ key={framework.id}
97
+ framework={framework}
98
+ selected={selected === framework.id}
99
+ onSelect={() => handleSelect(framework.id)}
100
+ />
101
+ ))}
102
+ </div>
103
+ </div>
104
+ );
105
+}
106
+
107
+export { frameworks };
docs/components/quickstart/index.tsx
new
+3
@@ -0,0 +1,3 @@
1
+export { FrameworkSelector, frameworks } from './framework-selector';
2
+export { QuickstartFlow, FrameworkOption } from './quickstart-flow';
3
+export type { Framework } from './framework-selector';
docs/components/quickstart/quickstart-flow.tsx
new
+160
@@ -0,0 +1,160 @@
1
+'use client';
2
+
3
+import Image from 'next/image';
4
+import {
5
+ createContext,
6
+ useContext,
7
+ useState,
8
+ useEffect,
9
+ useRef,
10
+ type ReactNode,
11
+} from 'react';
12
+
13
+// Types
14
+interface FrameworkData {
15
+ id: string;
16
+ name: string;
17
+ logo: string;
18
+}
19
+
20
+interface QuickstartContextValue {
21
+ selectedId: string;
22
+ setSelectedId: (id: string) => void;
23
+ registerFramework: (data: FrameworkData) => void;
24
+ frameworks: FrameworkData[];
25
+}
26
+
27
+// Context to share state between QuickstartFlow and FrameworkOption
28
+const QuickstartContext = createContext<QuickstartContextValue | null>(null);
29
+
30
+export function useQuickstartFramework() {
31
+ const context = useContext(QuickstartContext);
32
+ return context?.selectedId ?? null;
33
+}
34
+
35
+// Framework option component - registers itself and conditionally renders content
36
+interface FrameworkOptionProps {
37
+ id: string;
38
+ name: string;
39
+ logo: string;
40
+ children: ReactNode;
41
+}
42
+
43
+export function FrameworkOption({ id, name, logo, children }: FrameworkOptionProps) {
44
+ const context = useContext(QuickstartContext);
45
+ const hasRegistered = useRef(false);
46
+
47
+ useEffect(() => {
48
+ if (context && !hasRegistered.current) {
49
+ context.registerFramework({ id, name, logo });
50
+ hasRegistered.current = true;
51
+ }
52
+ }, [context, id, name, logo]);
53
+
54
+ // Only render if this framework is selected
55
+ if (!context || context.selectedId !== id) {
56
+ return null;
57
+ }
58
+
59
+ return <>{children}</>;
60
+}
61
+
62
+// Card component for framework selection
63
+interface FrameworkCardProps {
64
+ id: string;
65
+ name: string;
66
+ logo: string;
67
+ selected: boolean;
68
+ onSelect: () => void;
69
+}
70
+
71
+function FrameworkCard({ name, logo, selected, onSelect }: FrameworkCardProps) {
72
+ return (
73
+ <button
74
+ type="button"
75
+ onClick={onSelect}
76
+ className={`
77
+ flex items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-all
78
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-orange-500 focus-visible:ring-offset-2
79
+ ${selected
80
+ ? 'border-[var(--composio-orange)] bg-fd-accent/30'
81
+ : 'border-fd-border bg-fd-card hover:bg-fd-accent/50 hover:border-[color-mix(in_srgb,var(--composio-orange)_50%,transparent)]'
82
+ }
83
+ `}
84
+ >
85
+ <div className="flex h-6 w-6 shrink-0 items-center justify-center">
86
+ <Image
87
+ src={logo}
88
+ alt={`${name} logo`}
89
+ width={24}
90
+ height={24}
91
+ className="h-5 w-auto dark:invert"
92
+ />
93
+ </div>
94
+ <span className="text-sm font-medium text-fd-foreground">{name}</span>
95
+ </button>
96
+ );
97
+}
98
+
99
+// Main wrapper component
100
+interface QuickstartFlowProps {
101
+ children: ReactNode;
102
+}
103
+
104
+export function QuickstartFlow({ children }: QuickstartFlowProps) {
105
+ const [frameworks, setFrameworks] = useState<FrameworkData[]>([]);
106
+ const [selectedId, setSelectedId] = useState<string>('');
107
+ const registeredIds = useRef<Set<string>>(new Set());
108
+
109
+ const registerFramework = (data: FrameworkData) => {
110
+ if (!registeredIds.current.has(data.id)) {
111
+ registeredIds.current.add(data.id);
112
+ setFrameworks((prev) => {
113
+ // Check if already exists
114
+ if (prev.some((f) => f.id === data.id)) {
115
+ return prev;
116
+ }
117
+ return [...prev, data];
118
+ });
119
+ }
120
+ };
121
+
122
+ // Set default selection to first framework once registered
123
+ useEffect(() => {
124
+ if (frameworks.length > 0 && !selectedId) {
125
+ setSelectedId(frameworks[0].id);
126
+ }
127
+ }, [frameworks, selectedId]);
128
+
129
+ const contextValue: QuickstartContextValue = {
130
+ selectedId,
131
+ setSelectedId,
132
+ registerFramework,
133
+ frameworks,
134
+ };
135
+
136
+ return (
137
+ <QuickstartContext.Provider value={contextValue}>
138
+ {/* Framework selector */}
139
+ {frameworks.length > 0 && (
140
+ <div className="not-prose mb-6">
141
+ <div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
142
+ {frameworks.map((framework) => (
143
+ <FrameworkCard
144
+ key={framework.id}
145
+ id={framework.id}
146
+ name={framework.name}
147
+ logo={framework.logo}
148
+ selected={selectedId === framework.id}
149
+ onSelect={() => setSelectedId(framework.id)}
150
+ />
151
+ ))}
152
+ </div>
153
+ </div>
154
+ )}
155
+
156
+ {/* Render all children - FrameworkOption will conditionally show based on selection */}
157
+ {children}
158
+ </QuickstartContext.Provider>
159
+ );
160
+}
docs/content/docs/quickstart.mdx
+392
-222
@@ -1,261 +1,431 @@
1
---
2
title: Quickstart
3
-description: Add composio tools to your AI agents
4
-keywords: [tutorial, setup, install, first agent]
3
+description: Build an AI agent with access to 1000+ tools
4
+keywords: [tutorial, setup, first agent]
5
---
6
7
-This guide walks you through **authenticated tool calling**—the foundation of how Composio connects your AI agents to real-world actions.
7
+Build your first AI agent with Composio Tools.
8
9
-You'll learn how to:
10
-1. **Discover and add tools** relevant to your use case (e.g., Slack, GitHub, Notion) to your AI agent
11
-2. **Authenticate tools** securely on behalf of a specific user, with fine-grained access control
12
-3. **Enable your LLM** (like OpenAI, Claude, or LangChain) to invoke these tools reliably using structured tool call formats
9
+<QuickstartFlow>
10
14
-## Prerequisites
15
-
16
-Before you begin, ensure you have:
17
-
18
-1. **A Composio account** - [Sign up here](https://platform.composio.dev) if you haven't already
19
-2. **Python 3.10+** or **Node.js 18+** installed on your system
20
-3. **Your API key** - Get it from the [developer dashboard](https://platform.composio.dev?next_page=/settings) and set it as an environment variable:
11
+<FrameworkOption id="openai-agents" name="OpenAI Agents" logo="/images/providers/openai-logo.svg">
12
+<Steps>
13
+<Step>
14
+### Install
15
16
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
17
+<Tab value="Python">
18
```bash
23
-export COMPOSIO_API_KEY=your_api_key
19
+pip install composio composio-openai-agents openai-agents
20
```
21
+</Tab>
22
+<Tab value="TypeScript">
23
+```bash
24
+npm install @composio/core @composio/openai-agents @openai/agents
25
+```
26
+</Tab>
27
+</Tabs>
28
+</Step>
29
26
-## Install the SDK
30
+<Step>
31
+### Create session and run agent
32
28
-First, install the Composio SDK for your preferred language:
33
+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
34
35
<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
31
- <Tab value="Python">
32
- ```bash
33
- pip install composio
34
- ```
35
- </Tab>
36
- <Tab value="TypeScript">
37
- ```bash
38
- npm install @composio/core
39
- ```
40
- </Tab>
41
-</Tabs>
42
-
43
-## Authorize Tools & Run Them with an Agent
44
-
45
-Composio supports multiple LLM providers. Here's how to use Composio with some of the most popular ones:
36
+<Tab value="Python">
37
+```python
38
+import asyncio
39
+from composio import Composio
40
+from agents import Agent, Runner
41
+from composio_openai_agents import OpenAIAgentsProvider
42
+
43
+# Initialize Composio with OpenAI Agents provider
44
+composio = Composio(api_key="{{apiKey}}", provider=OpenAIAgentsProvider())
45
+
46
+external_user_id = "{{userId}}"
47
+
48
+# Create a tool router session
49
+session = composio.create(
50
+ user_id=external_user_id,
51
+)
52
+
53
+# Get tools from the session (native)
54
+tools = session.tools()
55
+
56
+# Create agent with tools
57
+agent = Agent(
58
+ name="Email Manager",
59
+ instructions="You are a helpful assistant that helps users manage their Gmail accounts.",
60
+ tools=tools,
61
+)
62
+
63
+# Run the agent
64
+async def main():
65
+ result = await Runner.run(
66
+ starting_agent=agent,
67
+ input="Send an email to {{email}} with the subject 'Hello from Composio' and the body 'This is a test email!'",
68
+ )
69
+ print(result.final_output)
70
47
-<Tabs items={['OpenAI Agents (Python)', 'Anthropic (TypeScript)', 'Vercel AI SDK (TypeScript)']}>
48
- <Tab value="OpenAI Agents (Python)">
49
- Install the OpenAI Agents provider:
71
+asyncio.run(main())
72
+```
73
+</Tab>
74
+<Tab value="TypeScript">
75
+```typescript
76
+import { Composio } from "@composio/core";
77
+import { Agent, run } from "@openai/agents";
78
+import { OpenAIAgentsProvider } from "@composio/openai-agents";
79
+
80
+// Initialize Composio with OpenAI Agents provider
81
+const composio = new Composio({
82
+ apiKey: "{{apiKey}}",
83
+ provider: new OpenAIAgentsProvider(),
84
+});
85
+
86
+const externalUserId = "{{userId}}";
87
+
88
+// Create a tool router session
89
+const session = await composio.create(externalUserId);
90
+
91
+// Get tools from the session (native)
92
+const tools = await session.tools();
93
+
94
+// Create agent with tools
95
+const agent = new Agent({
96
+ name: "Email Manager",
97
+ model: "gpt-4o",
98
+ instructions: "You are a helpful assistant. Use Composio tools to execute tasks.",
99
+ tools: tools,
100
+});
101
+
102
+// Run the agent
103
+console.log(`🔄 Running agent...`);
104
+const result = await run(
105
+ agent,
106
+ "Send an email to {{email}} with the subject 'Hello from Composio' and the body 'This is a test email!'"
107
+);
108
+
109
+console.log(`✅ Received response from agent`);
110
+if (result.finalOutput) {
111
+ console.log(result.finalOutput);
112
+}
113
+```
114
+</Tab>
115
+</Tabs>
116
+</Step>
117
+</Steps>
118
+</FrameworkOption>
119
51
- ```bash
52
- pip install composio openai-agents composio-openai-agents
53
- ```
120
+<FrameworkOption id="claude-agents" name="Claude Agents" logo="/images/providers/anthropic-logo.svg">
121
+<Steps>
122
+<Step>
123
+### Install
124
55
- ```python
56
- import asyncio
57
- from composio import Composio
58
- from agents import Agent, Runner
59
- from composio_openai_agents import OpenAIAgentsProvider
125
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
126
+<Tab value="Python">
127
+```bash
128
+pip install composio composio-claude-agent-sdk claude-agent-sdk
129
+```
130
+</Tab>
131
+<Tab value="TypeScript">
132
+```bash
133
+npm install @composio/core @composio/claude-agent-sdk @anthropic-ai/claude-agent-sdk
134
+```
135
+</Tab>
136
+</Tabs>
137
+</Step>
138
61
- composio = Composio(api_key="your-api-key", provider=OpenAIAgentsProvider())
139
+<Step>
140
+### Create session and run agent
141
63
- # Id of the user in your system
64
- externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ad9ebc4"
142
+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
143
66
- # Create an auth config for gmail from the dashboard or programmatically
67
- auth_config_id = "your-auth-config-id"
68
- connection_request = composio.connected_accounts.link(
69
- user_id=externalUserId,
70
- auth_config_id=auth_config_id,
144
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
145
+<Tab value="Python">
146
+```python
147
+import asyncio
148
+from composio import Composio
149
+from composio_claude_agent_sdk import ClaudeAgentSDKProvider
150
+from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions, create_sdk_mcp_server
151
+
152
+# Initialize Composio
153
+composio = Composio(
154
+ api_key="{{apiKey}}",
155
+ provider=ClaudeAgentSDKProvider()
156
+)
157
+
158
+external_user_id = "{{userId}}"
159
+
160
+# Create a tool router session
161
+session = composio.create(
162
+ user_id=external_user_id,
163
+)
164
+
165
+# Get tools from the session (native)
166
+tools = session.tools()
167
+custom_server = create_sdk_mcp_server(name="composio", version="1.0.0", tools=tools)
168
+
169
+# Query Claude with MCP tools
170
+async def main():
171
+ options = ClaudeAgentOptions(
172
+ system_prompt="You are a helpful assistant",
173
+ permission_mode="bypassPermissions",
174
+ mcp_servers={
175
+ "composio": custom_server,
176
+ },
177
)
178
73
- # Redirect user to the OAuth flow
74
- redirect_url = connection_request.redirect_url
179
+ async with ClaudeSDKClient(options=options) as client:
180
+ await client.query(f"Send an email to {{email}} with the subject 'Hello from Composio' and the body 'This is a test email!'")
181
+ # Extract and print response
182
+ async for msg in client.receive_response():
183
+ print(msg)
184
76
- print(
77
- f"Please authorize the app by visiting this URL: {redirect_url}"
78
- ) # Print the redirect url to the user
185
+asyncio.run(main())
186
+```
187
+</Tab>
188
+<Tab value="TypeScript">
189
+```typescript
190
+import { Composio } from "@composio/core";
191
+import { ClaudeAgentSDKProvider} from "@composio/claude-agent-sdk";
192
+import { createSdkMcpServer, query } from "@anthropic-ai/claude-agent-sdk";
193
+
194
+// Initialize Composio
195
+const composio = new Composio({
196
+ apiKey: "{{apiKey}}",
197
+ provider: new ClaudeAgentSDKProvider(),
198
+});
199
+
200
+const externalUserId = "{{userId}}";
201
+
202
+// Create a tool router session
203
+const session = await composio.create(externalUserId);
204
+// Get tools from the session (native)
205
+const tools = await session.tools();
206
+
207
+const customServer = createSdkMcpServer({
208
+ name: "composio",
209
+ version: "1.0.0",
210
+ tools: tools,
211
+});
212
+
213
+// Initialize Claude client
214
+for await (const content of query({
215
+ prompt: "Send an email to {{email}} saying hello",
216
+ options: {
217
+ mcpServers: { composio: customServer },
218
+ permissionMode: "bypassPermissions",
219
+ },
220
+})) {
221
+ if (content.type === "assistant") {
222
+ console.log("Claude:", content.message);
223
+ }
224
+}
225
+
226
+console.log(`✅ Received response from Claude`);
227
+```
228
+</Tab>
229
+</Tabs>
230
+</Step>
231
+</Steps>
232
+</FrameworkOption>
233
80
- # Wait for the connection to be established
81
- connected_account = connection_request.wait_for_connection()
82
- print(
83
- f"Connection established successfully! Connected account id: {connected_account.id}"
84
- )
234
+<FrameworkOption id="langchain" name="LangChain" logo="/images/providers/langchain-logo.svg">
235
+<Steps>
236
+<Step>
237
+### Install
238
86
- # Get Gmail tools that are pre-configured
87
- tools = composio.tools.get(user_id=externalUserId, tools=["GMAIL_SEND_EMAIL"])
239
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
240
+<Tab value="Python">
241
+```bash
242
+pip install composio langchain langchain-openai langchain-mcp-adapters
243
+```
244
+</Tab>
245
+<Tab value="TypeScript">
246
+```bash
247
+npm install @composio/core langchain @langchain/openai @langchain/mcp-adapters
248
+```
249
+</Tab>
250
+</Tabs>
251
+</Step>
252
89
- agent = Agent(
90
- name="Email Manager", instructions="You are a helpful assistant", tools=tools
91
- )
253
+<Step>
254
+### Create session and run agent
255
93
- # Run the agent
94
- async def main():
95
- result = await Runner.run(
96
- starting_agent=agent,
97
- 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!'",
98
- )
99
- print(result.final_output)
100
-
101
- asyncio.run(main())
102
- ```
103
- </Tab>
104
- <Tab value="Anthropic (TypeScript)">
105
- Install the Composio Anthropic provider:
106
-
107
- ```bash
108
- npm i @composio/core @composio/anthropic @anthropic-ai/sdk
109
- ```
110
-
111
- ```typescript
112
- import { Composio } from "@composio/core";
113
- import { AnthropicProvider } from "@composio/anthropic";
114
- import Anthropic from "@anthropic-ai/sdk";
115
-
116
- // env: ANTHROPIC_API_KEY
117
- const anthropic = new Anthropic();
118
-
119
- const composio = new Composio({
120
- apiKey: "your-api-key",
121
- provider: new AnthropicProvider(),
122
- toolkitVersions: {
123
- "gmail": "20251111_00",
124
- }
125
- });
126
-
127
- // Id of the user in your system
128
- const externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ad9ebc4";
129
-
130
- // Create an auth config for gmail from the dashboard or programmatically
131
- const authConfigId = "your-auth-config-id";
132
-
133
- const connectionRequest = await composio.connectedAccounts.link(
134
- externalUserId,
135
- authConfigId
136
- );
137
-
138
- // redirect the user to the OAuth flow
139
- const redirectUrl = connectionRequest.redirectUrl;
140
- console.log(`Please authorize the app by visiting this URL: ${redirectUrl}`);
141
-
142
- // wait for connection to be established
143
- const connectedAccount = await connectionRequest.waitForConnection();
144
- console.log(
145
- `Connection established successfully! Connected account id: ${connectedAccount.id}`
146
- );
147
-
148
- // Fetch tools for your user and execute
149
- const tools = await composio.tools.get(externalUserId, {
150
- tools: ["GMAIL_SEND_EMAIL"],
151
- });
152
-
153
- console.log(tools);
154
- const msg = await anthropic.messages.create({
155
- model: "claude-sonnet-4-5",
156
- messages: [
157
- {
158
- role: "user",
159
- 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!'`,
160
- },
161
- ],
162
- tools: tools,
163
- max_tokens: 1000,
164
- });
165
-
166
- const res = await composio.provider.handleToolCalls(externalUserId, msg);
167
- console.log("Email sent successfully!");
168
- ```
169
- </Tab>
170
- <Tab value="Vercel AI SDK (TypeScript)">
171
- Install the Composio Vercel Provider:
172
-
173
- ```bash
174
- npm i @composio/core @composio/vercel ai @ai-sdk/openai
175
- ```
176
-
177
- ```typescript
178
- import { Composio } from "@composio/core";
179
- import { VercelProvider } from "@composio/vercel";
180
- import { generateText } from "ai";
181
- import { openai } from "@ai-sdk/openai";
182
-
183
- const composio = new Composio({
184
- apiKey: "your-api-key",
185
- provider: new VercelProvider(),
186
- });
187
-
188
- // Id of the user in your system
189
- const externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ac9ebc4";
190
-
191
- // Create an auth config for gmail from the dashboard or programmatically
192
- const authConfigId = "your-auth-config-id";
193
-
194
- const connectionRequest = await composio.connectedAccounts.link(
195
- externalUserId,
196
- authConfigId
197
- );
198
-
199
- // redirect the user to the OAuth flow
200
- const redirectUrl = connectionRequest.redirectUrl;
201
- console.log(`Please authorize the app by visiting this URL: ${redirectUrl}`);
202
-
203
- // wait for connection to be established
204
- const connectedAccount = await connectionRequest.waitForConnection();
205
-
206
- const tools = await composio.tools.get(externalUserId, "GMAIL_SEND_EMAIL");
207
-
208
- // env: OPENAI_API_KEY
209
- const { text } = await generateText({
210
- model: openai("gpt-5"),
211
- messages: [
212
- {
213
- role: "user",
214
- 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!'`,
215
- },
216
- ],
217
- tools: tools
218
- });
256
+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
257
220
- console.log("Email sent successfully!", { text });
221
- ```
222
- </Tab>
258
+<Tabs groupId="language" items={['Python', 'TypeScript']} persist>
259
+<Tab value="Python">
260
+```python
261
+from composio import Composio
262
+from langchain.agents import create_agent
263
+from langchain_openai.chat_models import ChatOpenAI
264
+
265
+# Initialize Composio
266
+composio = Composio(api_key="{{apiKey}}")
267
+
268
+external_user_id = "{{userId}}"
269
+
270
+# Create a tool router session
271
+session = composio.create(
272
+ user_id=external_user_id,
273
+)
274
+
275
+# Get tools from the session (native)
276
+tools = session.tools()
277
+
278
+# Initialize LangChain model
279
+model = ChatOpenAI(model="gpt-4o")
280
+
281
+# Create agent
282
+agent = create_agent(
283
+ tools=tools,
284
+ model=model,
285
+)
286
+
287
+# Run the agent
288
+result = agent.invoke(
289
+ {
290
+ "messages": [
291
+ {
292
+ "role": "user",
293
+ "content": "Send an email to {{email}} with the subject 'Hello from Composio' and the body 'This is a test email!'",
294
+ }
295
+ ]
296
+ }
297
+)
298
+
299
+print("✅ Email sent successfully!")
300
+print(result)
301
+```
302
+</Tab>
303
+<Tab value="TypeScript">
304
+```typescript
305
+import { ChatOpenAI } from "@langchain/openai";
306
+import { createAgent } from "langchain";
307
+import { Composio } from "@composio/core";
308
+
309
+// Initialize Composio
310
+const composio = new Composio({
311
+ apiKey: "{{apiKey}}",
312
+});
313
+
314
+const externalUserId = "{{userId}}";
315
+
316
+// Create a tool router session
317
+const session = await composio.create(externalUserId);
318
+
319
+// Initialize LangChain model
320
+const llm = new ChatOpenAI({
321
+ model: "gpt-4o",
322
+});
323
+
324
+// Get tools from the session (native)
325
+const tools = await session.tools();
326
+
327
+// Create agent
328
+const agent = createAgent({
329
+ name: "Gmail Assistant",
330
+ systemPrompt: "You are a helpful gmail assistant.",
331
+ model: llm,
332
+ tools: tools,
333
+});
334
+
335
+// Run the agent
336
+console.log(`🔄 Running agent...`);
337
+const result = await agent.invoke({
338
+ messages: [
339
+ {
340
+ role: "user",
341
+ content: "Send an email to {{email}} with the subject 'Hello from Composio' and the body 'This is a test email!'",
342
+ },
343
+ ],
344
+});
345
+
346
+console.log(`✅ Received response from agent`);
347
+console.log(result);
348
+```
349
+</Tab>
350
</Tabs>
351
+</Step>
352
+</Steps>
353
+</FrameworkOption>
354
225
-<Callout title="What just happened?" type="info">
226
-You just:
227
-1. Authorized a user account with Composio
228
-2. Passed those tool permissions into an LLM framework
229
-3. Let the LLM securely call real tools on the user's behalf
355
+<FrameworkOption id="vercel-ai" name="Vercel AI" logo="/images/providers/vercel-logo.svg">
356
+<Steps>
357
+<Step>
358
+### Install
359
231
-All OAuth flows and tool execution were automatically handled by Composio.
232
-</Callout>
360
+<Tabs groupId="language" items={['TypeScript']} persist>
361
+<Tab value="TypeScript">
362
+```bash
363
+npm install @composio/core @composio/vercel ai @ai-sdk/openai @ai-sdk/mcp
364
+```
365
+</Tab>
366
+</Tabs>
367
+</Step>
368
+
369
+<Step>
370
+### Create session and run agent
371
+
372
+[Sessions](/tool-router/users-and-sessions) are ephemeral, user-scoped and manage connections and tools for that user.
373
+
374
+<Tabs groupId="language" items={['TypeScript']} persist>
375
+<Tab value="TypeScript">
376
+```typescript
377
+import { openai } from "@ai-sdk/openai";
378
+import { Composio } from "@composio/core";
379
+import { VercelProvider } from "@composio/vercel";
380
+import { stepCountIs, streamText } from "ai";
381
+
382
+// Initialize Composio with Vercel provider
383
+const composio = new Composio({
384
+ apiKey: "{{apiKey}}",
385
+ provider: new VercelProvider(),
386
+});
387
+
388
+const externalUserId = "{{userId}}";
389
+
390
+// Create a tool router session
391
+const session = await composio.create(externalUserId);
392
+
393
+// Get tools from the session (native)
394
+const tools = await session.tools();
395
+
396
+// Stream text with tools
397
+console.log(`🔄 Running agent...`);
398
+const stream = await streamText({
399
+ model: openai("gpt-4o-mini"),
400
+ prompt: "Send an email to {{email}} with the subject 'Hello from Composio' and the body 'This is a test email!'",
401
+ stopWhen: stepCountIs(10),
402
+ tools,
403
+});
404
+
405
+// Stream the response
406
+for await (const textPart of stream.textStream) {
407
+ process.stdout.write(textPart);
408
+}
409
+```
410
+</Tab>
411
+</Tabs>
412
+</Step>
413
+</Steps>
414
+</FrameworkOption>
415
+
416
+</QuickstartFlow>
417
418
## Next steps
419
420
<Cards>
421
<Card
238
- icon={<Plug />}
239
- title="Use Providers"
240
- href="/docs/providers/openai"
241
- description="Learn how to use Composio with various agent SDK and frameworks."
242
- />
243
- <Card
244
- icon={<Wrench />}
245
- title="Work with tools"
246
- href="/docs/executing-tools"
247
- description="Learn how to work with tools and tool calling on a deeper level with Composio."
248
- />
249
- <Card
250
- icon={<Key />}
251
- title="Manage authentication"
252
- href="/docs/custom-auth-configs"
253
- description="Authorize tools for multiple users."
422
+ title="Session management"
423
+ href="/docs/tool-router/users-and-sessions"
424
+ description="Learn about users, sessions, and how they work."
425
/>
426
<Card
256
- icon={<Zap />}
257
- title="Triggers"
258
- href="/docs/using-triggers"
259
- description="Listen for external events to trigger actions in your agents."
427
+ title="Tools and toolkits"
428
+ href="/docs/tool-router/tools-and-toolkits"
429
+ description="Learn about tools, toolkits, and how to configure them."
430
/>
431
</Cards>
docs/mdx-components.tsx
+4
@@ -8,6 +8,7 @@ import { Step, Steps } from 'fumadocs-ui/components/steps';
8
import { Card, Cards } from 'fumadocs-ui/components/card';
9
import { ImageZoom } from 'fumadocs-ui/components/image-zoom';
10
import { ProviderCard, ProviderGrid } from '@/components/provider-card';
11
+import { FrameworkSelector, QuickstartFlow, FrameworkOption } from '@/components/quickstart';
12
import { Figure } from '@/components/figure';
13
import { Video } from '@/components/video';
14
import { CapabilityCard, CapabilityList } from '@/components/capability-card';
@@ -43,6 +44,9 @@ export function getMDXComponents(components?: MDXComponents): MDXComponents {
44
Cards,
45
ProviderCard,
46
ProviderGrid,
47
+ FrameworkSelector,
48
+ QuickstartFlow,
49
+ FrameworkOption,
50
Figure,
51
Video,
52
CapabilityCard,