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.

Fix all small docs errors and some updates to Executing tools (#1881)

Sushmitha Malleshd12566b60ef8
diff --git a/fern/docs/get-started/quickstart.mdx b/fern/docs/get-started/quickstart.mdx
deleted file mode 100644
index ec28ab0c2..000000000
--- a/fern/docs/get-started/quickstart.mdx
+++ /dev/null
@@ -1,236 +0,0 @@
----
-title: Quickstart
-image: "https://og.composio.dev/api/og?title=Quickstart" # image for socials
-description: "Add authenticated tool-calling to any LLM agent in three steps."
-keywords: ""
-subtitle: ""
-hide-nav-links: true
----
-
-This guide covers authenticated tool calling, one of the most core features of Composio.
-You will learn how to:
-- Add tools to your AI agent
-- Authenticate the agent/tools for a user
-- Call the tools generated by the LLM
-
-**Before you start!**
-<Accordion title='Prerequisites'>
-1. Ensure you have created an account on [Composio](https://platform.composio.dev) and have Python 3.8+ _or_ NodeJS 16+ installed!
-2. Get your API key from the [developer dashboard](https://platform.composio.dev?next_page=/settings) and set it as an environment variable.
-```bash
-export COMPOSIO_API_KEY=your_api_key
-```
-<Note title="Note!">Ensure you save the API key in a `.env` file and don't commit it to version control!</Note>
-</Accordion>
-
-## Install the SDK
-First and foremost, install the Composio SDK.
-<CodeGroup>
-```typescript TypeScript
-npm install @composio/core
-```
-```python Python
-pip install composio==0.8.0
-```
-</CodeGroup>
-
-## Initialise
-
-To use the SDK, you need to initialize it with your API key:
-
-<CodeGroup>
-```typescript TypeScript
-import { Composio } from '@composio/core';
-
-// Initialize the SDK
-const composio = new Composio({
- // apiKey: 'your-api-key',
-});
-```
-```python Python
-from composio import Composio
-
-composio = Composio(
- # api_key="your-api-key",
-)
-```
-</CodeGroup>
-
-
-## Authorize and run tools
-<Tabs>
-<Tab title="OpenAI (Python)">
-Composio ships with support for OpenAI provider out of the box.
-```python maxLines=60
-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,
-)
-
-# Handle Result from tool call
-result = composio.provider.handle_tool_calls(user_id=user_id, response=completion)
-print(result)
-```
-</Tab>
-<Tab title="Anthropic (Typescript)">
-You may install the Anthropic provider as well!
-
-**Installation**
-```bash
-npm install @composio/anthropic
-```
-
-```typescript maxLines=60
-import { Composio } from "@composio/core";
-import { AnthropicProvider } from "@composio/anthropic";
-import Anthropic from "@anthropic-ai/sdk";
-
-const anthropic = new Anthropic();
-const composio = new Composio({
- provider: new AnthropicProvider(),
-});
-
-const userId = "[email protected]";
-const connection = await composio.toolkits.authorize(userId, "GITHUB");
-console.log(
- `🔗 Visit the URL to authorize:\n👉 ${connection.redirectUrl}`
-);
-
-await connection.waitForConnection();
-const msg = await anthropic.messages.create({
- model: "claude-3-7-sonnet-latest",
- tools: tools,
- messages: [
- {
- role: "user",
- content: "Star the composiohq/composio repository",
- },
- ],
- max_tokens: 1024,
-});
-
-const result = await composio.provider.handleToolCalls(userId, msg);
-console.log("✅ Tool results:", result);
-```
-</Tab>
-<Tab title="Vercel AI SDK (Typescript)">
-You may install the Vercel AI provider as well!
-
-**Installation**
-```bash
-npm install @composio/vercel
-```
-
-<SnippetCode
- src="fern/snippets/typescript/quickstart-vercel.ts"
- startLine={1}
- endLine={33}
- highlightStart={13}
- highlightEnd={18}
- title="Typescript (current)"
-/>
-</Tab>
-<Tab title="OpenAI Agents (Python)">
-You may install the OpenAI Agents provider as well!
-
-**Installation**
-```bash
-pip install composio_openai_agents==0.8.0
-```
-
-```python maxLines=60
-import asyncio
-
-from agents import Agent, Runner
-
-from composio import Composio
-from composio_openai_agents import OpenAIAgentsProvider
-
-# Initialize Composio toolset
-user_id = "[email protected]"
-composio = Composio(provider=OpenAIAgentsProvider())
-
-# 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()
-
-# Get all the tools
-tools = composio.tools.get(
- user_id=user_id,
- tools=["GITHUB_STAR_A_REPOSITORY_FOR_THE_AUTHENTICATED_USER"],
-)
-
-# Create an agent with the tools
-agent = Agent(
- name="GitHub Agent",
- instructions="You are a helpful assistant that helps users with GitHub tasks.",
- tools=tools,
-)
-
-
-# Run the agent
-async def main():
- result = await Runner.run(
- starting_agent=agent,
- input=(
- "Star the repository composiohq/composio on GitHub. If done "
- "successfully, respond with 'Action executed successfully'"
- ),
- )
- print(result.final_output)
-
-
-asyncio.run(main())
-```
-</Tab>
-</Tabs>
-
-<Note title="What just happened?">
-You authenticated your account through Composio and used LLMs to execute tools. Composio handled the OAuth flow and tool execution.
-</Note>
-
-
-## Next steps
-
-<CardGroup cols={2}>
- <Card title="Use Providers" icon="fa-solid fa-plug" href="/providers">
- Learn how to use Composio with various agent SDK and frameworks.
- </Card>
- <Card title="Work with tools" icon="fa-solid fa-toolbox" href="/docs/executing-tools">
- Learn how to work with tools and tool calling on a deeper level with Composio.
- </Card>
- <Card title="Manage authentication" icon="fa-solid fa-key" href="/docs/custom-auth-configs">
- Authorize tools for multiple users.
- </Card>
- <Card title="Triggers" icon="fa-solid fa-bolt" href="/docs/using-triggers">
- Listen for external events to trigger actions in your agents
- </Card>
-</CardGroup>
\ No newline at end of file
diff --git a/fern/pages/src/get-started/providers.mdx b/fern/pages/src/get-started/providers.mdx
index 8605e7ce3..b7fe77fb1 100644
--- a/fern/pages/src/get-started/providers.mdx
+++ b/fern/pages/src/get-started/providers.mdx
@@ -224,7 +224,7 @@ With chat completion APIs, the typical flow is:
<Card
title="Gemini Provider"
icon={<img src="../../../assets/images/google-logo.svg" width="24" height="24" />}
- href="/providers/google-adk"
+ href="/providers/google"
>
Integrate with Google's Gemini models.
</Card>
@@ -235,11 +235,11 @@ These providers work with AI frameworks that can execute tools autonomously. The
<CardGroup cols={3}>
<Card
- title="LangGraph Provider"
+ title="LangChain Provider"
icon={<img src="../../../assets/images/langgraph-logo.svg"/>}
- href="/providers/langgraph"
+ href="/providers/langchain"
>
- Add tools to LangGraph agent flows.
+ Add tools to LangChain agent flows.
</Card>
<Card
title="CrewAI Provider"
@@ -272,5 +272,5 @@ These providers work with AI frameworks that can execute tools autonomously. The
</CardGroup>
<Tip title="Custom Providers" icon="puzzle">
-Using a framework not yet supported by Composio? Create a [custom provider](/providers/custom)!
+Using a framework not yet supported by Composio? Create a custom provider in [TypeScript](/providers/custom/typescript) or [Python](/providers/custom/python)!
</Tip>
diff --git a/fern/pages/src/get-started/quickstart.mdx b/fern/pages/src/get-started/quickstart.mdx
index 2289a42c3..eb12e1111 100644
--- a/fern/pages/src/get-started/quickstart.mdx
+++ b/fern/pages/src/get-started/quickstart.mdx
@@ -16,22 +16,24 @@ You'll learn how to:
Composio provides first-class SDKs for both **TypeScript** and **Python**, making it easy to integrate no matter what stack you're building with.
-**Before you start!**
-<Accordion title='Prerequisites'>
-1. Ensure you have created an account on [Composio](https://platform.composio.dev) and have Python 3.8+ _or_ NodeJS 18+ installed!
-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.
+## Prerequisites
+
+Before you begin, ensure you have:
+
+1. **A Composio account** - [Sign up here](https://platform.composio.dev) if you haven't already
+2. **Python 3.8+** or **Node.js 18+** installed on your system
+3. **Your API key** - Get it from the [developer dashboard](https://platform.composio.dev?next_page=/settings) and set it as an environment variable:
+
```bash
export COMPOSIO_API_KEY=your_api_key
```
-<Note title="Note!">Ensure you save the API key in a `.env` file and don't commit it to version control!</Note>
-</Accordion>
## Install the SDK
First, install the Composio SDK for your preferred language:
<CodeGroup>
```bash title="Python" for="python"
-pip install composio==0.8.0
+pip install composio
```
```bash title="TypeScript" for="typescript"
npm install @composio/core
@@ -97,7 +99,7 @@ npm install @composio/vercel
<SnippetCode
src="fern/snippets/get-started/typescript/vercel-quickstart.ts"
startLine={1}
- endLine={34}
+ endLine={27}
/>
</Tab>
@@ -131,7 +133,7 @@ All OAuth flows and tool execution were automatically handled by Composio.
## Next steps
<CardGroup cols={2}>
- <Card title="Use Providers" icon="fa-solid fa-plug" href="/providers">
+ <Card title="Use Providers" icon="fa-solid fa-plug" href="/providers/openai">
Learn how to use Composio with various agent SDK and frameworks.
</Card>
<Card title="Work with tools" icon="fa-solid fa-toolbox" href="/docs/executing-tools">
diff --git a/fern/pages/src/get-started/welcome.mdx b/fern/pages/src/get-started/welcome.mdx
index c4d2e9843..cf25d3832 100644
--- a/fern/pages/src/get-started/welcome.mdx
+++ b/fern/pages/src/get-started/welcome.mdx
@@ -12,13 +12,13 @@ hide-nav-links: false
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.
-- **Access 3000+ tools** out of the box across popular apps like Slack, GitHub, Notion, and more. [Browse tools →](/tools/)
+- **Access 3000+ tools** out of the box across popular apps like Slack, GitHub, Notion, and more. [Browse tools →](/toolkits/introduction)
- **Enforce strict access and data controls** with [fine-grained permissions](/docs/authenticating-tools) for each tool and user.
- **Trigger agents and workflows** using [external events](/docs/using-triggers) (e.g., new message in Slack, new issue in GitHub).
- **Customize tools** for your proprietary APIs or internal functions via [modifiers](/docs/modifiers/schema-modifiers).
- **Integrate seamlessly** with frameworks like OpenAI, Anthropic, LangChain, Vercel AI SDK, and more.
- **Enhance reliability** with [input/output processing hooks](/docs/modifiers/before-execution) to clean or transform data on the fly.
-No more writing dozens of bespoke integrations. Composio handles auth, tool normalization, and execution—so your agents can focus on reasoning, not plumbing.
+No more writing dozens of integrations. Composio handles auth, tool normalization, and execution—so your agents can focus on reasoning, not plumbing.
-**We even optimize tool calls automatically for better accuracy—free of cost.**
+**We even optimize tool calls automatically for better accuracy**
diff --git a/fern/pages/src/tool-calling/executing-tools.mdx b/fern/pages/src/tool-calling/executing-tools.mdx
index 950cad597..ec2e29db0 100644
--- a/fern/pages/src/tool-calling/executing-tools.mdx
+++ b/fern/pages/src/tool-calling/executing-tools.mdx
@@ -5,89 +5,69 @@ keywords: ""
subtitle: "Learn how to execute Composio's tools with different providers and frameworks"
hide-nav-links: false
---
+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.
-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.
+
+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.
+
+
+<Tip icon="info">
+**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)
+</Tip>
## Using Chat Completions
-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.
-This approach works consistently across all supported non-agent providers.
-To learn how to setup these providers, see [Providers](/providers).
+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).
<CodeGroup>
<SnippetCode
src="fern/snippets/tool-calling/python/exec-tool-completions.py"
- startLine={1}
- endLine={30}
- title="Python (Google)"
+ title="Python (OpenAI)"
+ highlightStart={32}
+ highlightEnd={33}
/>
<SnippetCode
src="fern/snippets/tool-calling/typescript/exec-tool-completions.ts"
- startLine={1}
- endLine={30}
title="TypeScript (Anthropic)"
+ highlightStart={37}
+ highlightEnd={38}
/>
</CodeGroup>
## Using Agentic Frameworks
-Composio also has first-party support for agentic frameworks which execute tools, feed the result to the LLM and continue the conversation.
-
+Agentic frameworks automatically handle the tool execution loop.
+Composio provides support for frameworks like this by making sure the tools are formatted into the correct objects for the agentic framework to execute.
-<Tip icon="info">
-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.
-</Tip>
<CodeGroup>
<SnippetCode
src="fern/snippets/tool-calling/python/exec-tool-agentic.py"
- startLine={1}
- endLine={37}
title="Python (OpenAI Agents SDK)"
+ highlightStart={19}
+ highlightEnd={23}
/>
<SnippetCode
src="fern/snippets/tool-calling/typescript/exec-tool-agentic.ts"
- startLine={1}
- endLine={30}
title="TypeScript (Anthropic)"
+ highlightStart={22}
+ highlightEnd={31}
/>
</CodeGroup>
-## Tools are scoped to a user
-Each tool and tool action is scoped to a user. Hence, a `user_id` is required to fetch and execute tools.
-
-The authentication state is checked and used while fetching and executing a tool.
-
-You need to authorize the user to execute tools.
-For more information on authentication, see [Authenticating Tools](./authenticating-tools).
-
-## For Humans (deterministic tool calling)
-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.
-
+## Direct Tool execution
+In case you just want to call a tool without using any framework or LLM provider, you can use the `execute` method directly.
+<Tip icon="lightbulb">
+**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.
+</Tip>
<CodeGroup>
-```python Python maxLines=60 wordWrap
-
-user_id = "[email protected]"
-composio = Composio()
-
-result = composio.tools.execute(
- "HACKERNEWS_GET_USER",
- user_id=user_id,
- arguments={"username": "pg"}
-)
-print(result)
-```
-```typescript TypeScript maxLines=60 wordWrap
-const userId = "[email protected]";
-const composio = new Composio();
-
-const result = await composio.tools.execute("HACKERNEWS_GET_USER", {
- userId,
- arguments: {
- username: "pg",
- },
-});
-console.log(result);
-```
+<SnippetCode
+ src="fern/snippets/tool-calling/python/direct-tool-call.py"
+ title="Python"
+/>
+<SnippetCode
+ src="fern/snippets/tool-calling/typescript/direct-tool-call.ts"
+ title="TypeScript"
+/>
</CodeGroup>
### Proxy Execute -- Manually calling toolkit APIs
diff --git a/fern/snippets/get-started/python/quickstart-openai-agents.py b/fern/snippets/get-started/python/quickstart-openai-agents.py
index 960d0fe2c..bfdbfaaec 100644
--- a/fern/snippets/get-started/python/quickstart-openai-agents.py
+++ b/fern/snippets/get-started/python/quickstart-openai-agents.py
@@ -7,7 +7,7 @@ from composio_openai_agents import OpenAIAgentsProvider
# Initialize Composio toolset
user_id = "[email protected]"
-composio = Composio(provider=OpenAIAgentsProvider())
+composio = Composio(provider=OpenAIAgentsProvider(), api_key="your-composio-api-key")
# Initialize connection request
connection_request = composio.toolkits.authorize(user_id=user_id, toolkit="github")
diff --git a/fern/snippets/get-started/typescript/vercel-quickstart.ts b/fern/snippets/get-started/typescript/vercel-quickstart.ts
index 1e2260ecf..22540fb5f 100644
--- a/fern/snippets/get-started/typescript/vercel-quickstart.ts
+++ b/fern/snippets/get-started/typescript/vercel-quickstart.ts
@@ -19,14 +19,8 @@ const tools = await composio.tools.get(userId, { tools: ['GMAIL_SEND_EMAIL'] });
const { text } = await generateText({
model: anthropic('claude-3-7-sonnet-20250219'),
- messages: [
- {
- role: 'user',
- content: "say 'hi from the composio quickstart' to [email protected]", // we'll ship you free merch if you do ;)
- },
- ],
+ prompt: "say 'hi from the composio quickstart' to [email protected]", // we'll ship you free merch if you do ;)
tools,
- maxSteps: 3,
});
console.log(text);
diff --git a/fern/snippets/tool-calling/python/direct-tool-call.py b/fern/snippets/tool-calling/python/direct-tool-call.py
new file mode 100644
index 000000000..1d568a87d
--- /dev/null
+++ b/fern/snippets/tool-calling/python/direct-tool-call.py
@@ -0,0 +1,12 @@
+from composio import Composio
+
+user_id = "user-k7334"
+composio = Composio(api_key="your_composio_key")
+
+# Find available arguments for any tool in the Composio dashboard
+result = composio.tools.execute(
+ "GITHUB_LIST_STARGAZERS",
+ user_id=user_id,
+ arguments={"owner": "ComposioHQ", "repo": "composio", "page": 1, "per_page": 5}
+)
+print(result)
\ No newline at end of file
diff --git a/fern/snippets/tool-calling/python/exec-tool-agentic.py b/fern/snippets/tool-calling/python/exec-tool-agentic.py
index 28bcdae62..5a61d8f01 100644
--- a/fern/snippets/tool-calling/python/exec-tool-agentic.py
+++ b/fern/snippets/tool-calling/python/exec-tool-agentic.py
@@ -2,14 +2,14 @@ import asyncio
from agents import Agent, Runner
from composio import Composio
from composio_openai_agents import OpenAIAgentsProvider
-from uuid import uuid4
-user_id = uuid4()
+# Use a unique identifier for each user in your application
+user_id = "user-k7334"
# Initialize Composio toolset
-composio = Composio(provider=OpenAIAgentsProvider())
+composio = Composio(provider=OpenAIAgentsProvider(), api_key="your_composio_api_key")
-# Get all the tools
+# Get all tools for the user
tools = composio.tools.get(
user_id=user_id,
toolkits=["COMPOSIO_SEARCH"],
@@ -22,14 +22,12 @@ agent = Agent(
tools=tools,
)
-
-# Run the agent
async def main():
result = await Runner.run(
starting_agent=agent,
- input=("Do a thorough DEEP research on Ilya Sutskever"),
+ input=("Do a thorough DEEP research on Golden Gate Bridge"),
)
print(result.final_output)
-
+# Run the agent
asyncio.run(main())
diff --git a/fern/snippets/tool-calling/python/exec-tool-completions.py b/fern/snippets/tool-calling/python/exec-tool-completions.py
index 1a6fdc081..980097c5b 100644
--- a/fern/snippets/tool-calling/python/exec-tool-completions.py
+++ b/fern/snippets/tool-calling/python/exec-tool-completions.py
@@ -1,27 +1,34 @@
from composio import Composio
-from composio_gemini import GeminiProvider
-from google import genai
-from google.genai import types
+from composio_openai import OpenAIProvider
+from openai import OpenAI
+from datetime import datetime
-user_id = "0000-1111-2222"
+# Use a unique identifier for each user in your application
+user_id = "user-k7334"
# Create composio client
-composio = Composio(provider=GeminiProvider())
+composio = Composio(provider=OpenAIProvider(), api_key="your_composio_api_key")
-# Create google client
-client = genai.Client()
+# Create openai client
+openai = OpenAI()
+
+# Get calendar tools for this user
+tools = composio.tools.get(
+ user_id=user_id,
+ tools=["GOOGLECALENDAR_EVENTS_LIST"]
+)
-# Create genai client config
-config = types.GenerateContentConfig(
- tools=composio.tools.get(
- user_id=user_id,
- tools=[
- "COMPOSIO_SEARCH_DUCK_DUCK_GO_SEARCH",
- ],
- )
+# Ask the LLM to check calendar
+result = openai.chat.completions.create(
+ model="gpt-4o-mini",
+ tools=tools,
+ messages=[
+ {"role": "system", "content": "You are a helpful assistant."},
+ {"role": "user", "content": f"What's on my calendar for the next 7 days. Its {datetime.now().strftime("%Y-%m-%d")} today.",}
+ ]
)
-# Use the chat interface.
-chat = client.chats.create(model="gemini-2.0-flash", config=config)
-response = chat.send_message("What's new happening with Cluely?")
-print(response.text)
+
+# Handle tool calls
+result = composio.provider.handle_tool_calls(user_id=user_id, response=result)
+print(result)
\ No newline at end of file
diff --git a/fern/snippets/tool-calling/typescript/direct-tool-call.ts b/fern/snippets/tool-calling/typescript/direct-tool-call.ts
new file mode 100644
index 000000000..757f8f365
--- /dev/null
+++ b/fern/snippets/tool-calling/typescript/direct-tool-call.ts
@@ -0,0 +1,16 @@
+import { Composio } from "@composio/core";
+
+const userId = "user-k7334";
+const composio = new Composio({apiKey: "your_composio_key"});
+
+// Find available arguments for any tool in the Composio dashboard
+const result = await composio.tools.execute("GITHUB_LIST_STARGAZERS", {
+ userId,
+ arguments: {
+ "owner": "ComposioHQ",
+ "repo": "composio",
+ "page": 1,
+ "per_page": 5
+ },
+});
+console.log('✅ GitHub stargazers:', JSON.stringify(result, null, 2));
\ No newline at end of file
diff --git a/fern/snippets/tool-calling/typescript/exec-tool-agentic.ts b/fern/snippets/tool-calling/typescript/exec-tool-agentic.ts
index 53001a486..a9658e8b2 100644
--- a/fern/snippets/tool-calling/typescript/exec-tool-agentic.ts
+++ b/fern/snippets/tool-calling/typescript/exec-tool-agentic.ts
@@ -3,28 +3,31 @@ import { generateText } from 'ai';
import { anthropic } from '@ai-sdk/anthropic';
import { VercelProvider } from '@composio/vercel';
-const userId = '0000-1111-2222-3333';
+// Use a unique identifier for each user in your application
+const userId = 'user-k7334';
+// Initialize Composio toolset
const composio = new Composio({
apiKey: process.env.COMPOSIO_API_KEY,
provider: new VercelProvider(),
});
+// Get all tools for the user
const tools = await composio.tools.get(userId, {
- toolkits: ['COMPOSIO_SEARCH'],
+ toolkits: ['HACKERNEWS_GET_LATEST_POSTS'],
limit: 10,
});
+// Generate a deep research on hackernews
const { text } = await generateText({
- model: anthropic('claude-3-7-sonnet-20250219'),
+ model: anthropic('claude-sonnet-4-20250514'),
messages: [
{
role: 'user',
- content: 'Do a thorough DEEP research on Ilya Sutskever',
+ content: 'Do a thorough DEEP research on the top articles on Hacker News about Composio',
},
],
tools,
- maxSteps: 5,
});
console.log(text);
diff --git a/fern/snippets/tool-calling/typescript/exec-tool-completions.ts b/fern/snippets/tool-calling/typescript/exec-tool-completions.ts
index e697385c6..e0fd2df1c 100644
--- a/fern/snippets/tool-calling/typescript/exec-tool-completions.ts
+++ b/fern/snippets/tool-calling/typescript/exec-tool-completions.ts
@@ -2,29 +2,38 @@ import { Composio } from '@composio/core';
import { AnthropicProvider } from '@composio/anthropic';
import { Anthropic } from '@anthropic-ai/sdk';
-const userId = '0000-1111-2222-3333'; // User's UUID
+// Use a unique identifier for each user in your application
+const userId = 'user-k7334';
+// Create anthropic client
const anthropic = new Anthropic();
+
+// Create Composio client
const composio = new Composio({
- apiKey: process.env.COMPOSIO_API_KEY,
+ apiKey: "your-composio-api-key",
provider: new AnthropicProvider(),
});
+// Get calendar tools for this user
const tools = await composio.tools.get(userId, {
- tools: ['COMPOSIO_SEARCH_DUCK_DUCK_GO_SEARCH'],
+ tools: ['GOOGLECALENDAR_EVENTS_LIST'],
});
+const today = new Date();
+
+// Ask the LLM to check calendar
const msg = await anthropic.messages.create({
- model: 'claude-3-7-sonnet-latest',
+ model: 'claude-sonnet-4-20250514',
tools: tools,
messages: [
{
role: 'user',
- content: "What's new with OpenAI?",
+ content: `What's on my calendar for the next 7 days starting today:${today.toLocaleDateString()}?`,
},
],
max_tokens: 1024,
});
+// Handle tool calls
const result = await composio.provider.handleToolCalls(userId, msg);
-console.log(result);
+console.log('Results:', JSON.stringify(result, null, 2));