Skip to content

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)

Sushmitha Mallesh81b5e56c1f29
diff --git a/fern/pages/src/get-started/quickstart.mdx b/fern/pages/src/get-started/quickstart.mdx
index 35d7bbb37..9da4c937c 100644
--- a/fern/pages/src/get-started/quickstart.mdx
+++ b/fern/pages/src/get-started/quickstart.mdx
@@ -38,81 +38,52 @@ npm install @composio/core
```
</CodeGroup>
-## Initialize the SDK
-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.
-
-<CodeGroup>
-```python Python
-from composio import Composio
-
-composio = Composio(
- # api_key="your-api-key",
-)
-```
-```typescript TypeScript
-import { Composio } from '@composio/core';
-
-// Initialize the SDK
-const composio = new Composio({
- // apiKey: 'your-api-key',
-});
-```
-</CodeGroup>
-
-
## Authorize Tools & Run Them with an Agent
Composio supports multiple LLM providers. Here’s how to use Composio with some of the most popular ones:
<Tabs>
-<Tab title="OpenAI (Python)">
-Composio ships with support for OpenAI provider out of the box.
-<SnippetCode
- src="fern/snippets/get-started/python/quickstart.py"
- startLine={1}
- endLine={34}
-/>
-</Tab>
-<Tab title="Anthropic (Typescript)">
-You may install the Anthropic provider as well!
+<Tab title="OpenAI Agent(Python)">
+Install the OpenAI Agents provider!
**Installation**
```bash
-npm install @composio/anthropic
+pip install composio openai-agents composio-openai-agents
```
<SnippetCode
- src="fern/snippets/get-started/typescript/quickstart.ts"
+ src="fern/snippets/get-started/python/quickstart.py"
startLine={1}
- endLine={30}
+ endLine={46}
/>
-
</Tab>
-<Tab title="Vercel AI SDK (Typescript)">
-You may install the Vercel AI provider as well!
+<Tab title="Anthropic (TypeScript)">
+Install the Composio Anthropic provider
**Installation**
```bash
-npm install @composio/vercel
+npm i @composio/core @composio/anthropic
+npm i @anthropic-ai/sdk
```
<SnippetCode
- src="fern/snippets/get-started/typescript/vercel-quickstart.ts"
+ src="fern/snippets/get-started/typescript/quickstart.ts"
startLine={1}
- endLine={27}
+ endLine={57}
/>
</Tab>
-<Tab title="OpenAI Agents (Python)">
-You may install the OpenAI Agents provider as well!
+<Tab title="Vercel AI SDK (Typescript)">
+Install the Composio Vercel Provider
**Installation**
```bash
-pip install composio_openai_agents==0.8.0
+npm i @composio/core @composio/vercel
+npm i ai @ai-sdk/openai
```
<SnippetCode
- src="fern/snippets/get-started/python/quickstart-openai-agents.py"
+ src="fern/snippets/get-started/typescript/vercel-quickstart.ts"
startLine={1}
- endLine={46}
+ endLine={43}
/>
</Tab>
diff --git a/fern/snippets/get-started/python/quickstart.py b/fern/snippets/get-started/python/quickstart.py
index 5827cb15c..89d511ec9 100644
--- a/fern/snippets/get-started/python/quickstart.py
+++ b/fern/snippets/get-started/python/quickstart.py
@@ -1,33 +1,46 @@
+import asyncio
from composio import Composio
-from openai import OpenAI
-
-openai = OpenAI()
-composio = Composio()
-user_id = "[email protected]"
-
-# Initialize connection request
-connection_request = composio.toolkits.authorize(user_id=user_id, toolkit="gmail")
-print(f"🔗 Visit the URL to authorize:\n👉 {connection_request.redirect_url}")
-
-# wait for the connection to be active
-connection_request.wait_for_connection()
-
-# Fetch tools
-tools = composio.tools.get(user_id=user_id, toolkits=["GMAIL"])
-
-# Invoke agent
-completion = openai.chat.completions.create(
- model="gpt-4o",
- messages=[
- {
- "role": "user",
- "content": "say 'hi from the composio quickstart' to [email protected]",
- # we'll ship you free merch if you do ;)
- },
- ],
- tools=tools,
+from agents import Agent, Runner
+from composio_openai_agents import OpenAIAgentsProvider
+
+composio = Composio(api_key="your-api-key", provider=OpenAIAgentsProvider())
+
+# Id of the user in your system
+externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ad9ebc4"
+
+# Create an auth config for gmail from the dashboard or programmatically
+auth_config_id = "your-auth-config-id"
+connection_request = composio.connected_accounts.link(
+ user_id=externalUserId,
+ auth_config_id=auth_config_id,
)
-# Handle Result from tool call
-result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
-print(result)
+# Redirect user to the OAuth flow
+redirect_url = connection_request.redirect_url
+
+print(
+ f"Please authorize the app by visiting this URL: {redirect_url}"
+) # Print the redirect url to the user
+
+# Wait for the connection to be established
+connected_account = connection_request.wait_for_connection()
+print(
+ f"Connection established successfully! Connected account id: {connected_account.id}"
+)
+
+# Get Gmail tools that are pre-configured
+tools = composio.tools.get(user_id=externalUserId, tools=["GMAIL_SEND_EMAIL"])
+
+agent = Agent(
+ name="Email Manager", instructions="You are a helpful assistant", tools=tools
+)
+
+# Run the agent
+async def main():
+ result = await Runner.run(
+ starting_agent=agent,
+ input="Send an email to [email protected] with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'",
+ )
+ print(result.final_output)
+
+asyncio.run(main())
\ No newline at end of file
diff --git a/fern/snippets/get-started/typescript/quickstart.ts b/fern/snippets/get-started/typescript/quickstart.ts
index a4d593e1e..90964311d 100644
--- a/fern/snippets/get-started/typescript/quickstart.ts
+++ b/fern/snippets/get-started/typescript/quickstart.ts
@@ -1,28 +1,57 @@
-import { Composio } from '@composio/core';
-import { AnthropicProvider } from '@composio/anthropic';
-import Anthropic from '@anthropic-ai/sdk';
+import { Composio } from "@composio/core";
+import { AnthropicProvider } from "@composio/anthropic";
+import Anthropic from "@anthropic-ai/sdk";
+// env: ANTHROPIC_API_KEY
const anthropic = new Anthropic();
-const composio = new Composio({ provider: new AnthropicProvider() });
-const userId = '[email protected]';
-const connection = await composio.toolkits.authorize(userId, 'LINEAR');
-console.log(`🔗 Visit the URL to authorize:\n👉 ${connection.redirectUrl}`);
+const composio = new Composio({
+ apiKey: "your-api-key",
+ provider: new AnthropicProvider(),
+ toolkitVersions: {
+ "gmail": "20251111_00",
+ }
+});
+
+// Id of the user in your system
+const externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ad9ebc4";
+
+// Create an auth config for gmail from the dashboard or programmatically
+const authConfigId = "your-auth-config-id";
+
+const connectionRequest = await composio.connectedAccounts.link(
+ externalUserId,
+ authConfigId
+);
+
+// redirect the user to the OAuth flow
+const redirectUrl = connectionRequest.redirectUrl;
+console.log(`Please authorize the app by visiting this URL: ${redirectUrl}`);
-const tools = await composio.tools.get(userId, { toolkits: ['LINEAR'] });
-await connection.waitForConnection();
+// wait for connection to be established
+const connectedAccount = await connectionRequest.waitForConnection();
+console.log(
+`Connection established successfully! Connected account id: ${connectedAccount.id}`
+);
+// Fetch tools for your user and execute
+const tools = await composio.tools.get(externalUserId, {
+ tools: ["GMAIL_SEND_EMAIL"],
+});
+
+console.log(tools);
const msg = await anthropic.messages.create({
- model: 'claude-3-7-sonnet-latest',
- tools: tools,
+ model: "claude-sonnet-4-5",
messages: [
- {
- role: 'user',
- content: 'Get my linear projects',
- },
+ {
+ role: "user",
+ content: `Send an email to [email protected] with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'`,
+ },
],
- max_tokens: 1024,
+ tools: tools,
+ max_tokens: 1000,
});
-const result = await composio.provider.handleToolCalls(userId, msg);
-console.log('✅ Tool results:', result);
+
+const res = await composio.provider.handleToolCalls(externalUserId, msg);
+console.log("Email sent successfully!");
diff --git a/fern/snippets/get-started/typescript/vercel-quickstart.ts b/fern/snippets/get-started/typescript/vercel-quickstart.ts
index 22540fb5f..864740718 100644
--- a/fern/snippets/get-started/typescript/vercel-quickstart.ts
+++ b/fern/snippets/get-started/typescript/vercel-quickstart.ts
@@ -1,26 +1,43 @@
-import { Composio } from '@composio/core';
-import { generateText } from 'ai';
-import { anthropic } from '@ai-sdk/anthropic';
-import { VercelProvider } from '@composio/vercel';
-import { v4 as uuidv4 } from 'uuid';
+import { Composio } from "@composio/core";
+import { VercelProvider } from "@composio/vercel";
+import { generateText } from "ai";
+import { openai } from "@ai-sdk/openai";
-const userId = uuidv4(); // The user's ID.
const composio = new Composio({
- apiKey: process.env.COMPOSIO_API_KEY,
+ apiKey: "your-api-key",
provider: new VercelProvider(),
});
-const connection = await composio.toolkits.authorize(userId, 'gmail');
-console.log(`🔗 Visit the URL to authorize:\n👉 ${connection.redirectUrl}`);
+// Id of the user in your system
+const externalUserId = "pg-test-6dadae77-9ae1-40ca-8e2e-ba2d1ac9ebc4";
-await connection.waitForConnection();
+// Create an auth config for gmail from the dashboard or programmatically
+const authConfigId = "your-auth-config-id";
-const tools = await composio.tools.get(userId, { tools: ['GMAIL_SEND_EMAIL'] });
+const connectionRequest = await composio.connectedAccounts.link(
+ externalUserId,
+ authConfigId
+);
+// redirect the user to the OAuth flow
+const redirectUrl = connectionRequest.redirectUrl;
+console.log(`Please authorize the app by visiting this URL: ${redirectUrl}`);
+
+// wait for connection to be established
+const connectedAccount = await connectionRequest.waitForConnection();
+
+const tools = await composio.tools.get(externalUserId, "GMAIL_SEND_EMAIL");
+
+// env: OPENAI_API_KEY
const { text } = await generateText({
- model: anthropic('claude-3-7-sonnet-20250219'),
- prompt: "say 'hi from the composio quickstart' to [email protected]", // we'll ship you free merch if you do ;)
- tools,
+ model: openai("gpt-5"),
+ messages: [
+ {
+ role: "user",
+ content: `Send an email to [email protected] with the subject 'Hello from composio 👋🏻' and the body 'Congratulations on sending your first email using AI Agents and Composio!'`,
+ },
+ ],
+ tools: tools // cast to `any` to fix type mismatch
});
-console.log(text);
+console.log("Email sent successfully!", { text });
\ No newline at end of file