Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 18:15 UTC
fix quickstart
Sushmithamallesh committed
Dec 8, 2025 at 18:52 UTC
696ab53af6831e9fe44691e3e017a5056b306ab7
1 file changed
+14
-12
fern/snippets/tool-router/typescript/quickstart-openai.ts
+14
-12
@@ -1,34 +1,36 @@
1
import { Composio } from "@composio/core";
2
import { Agent, run, hostedMcpTool } from "@openai/agents";
3
+import { createInterface } from "readline/promises";
4
+
5
const composioApiKey = process.env.COMPOSIO_API_KEY;
6
const userId = "550e8400-e29b-41d4-a716-446655440000"; // Your user's unique identifier
7
8
const composio = new Composio({ apiKey: composioApiKey });
7
-
9
const { mcp } = await composio.create(userId);
9
-console.log(`Tool Router session created: ${mcp.url}`);
10
11
const agent = new Agent({
12
name: "Personal Assistant",
13
- instructions: "You are a helpful personal assistant. You should use composio tools to take action.",
14
- model: 'gpt-5.1',
13
+ instructions: "You are a helpful personal assistant. Use Composio tools to take action.",
14
+ model: "gpt-5.1",
15
modelSettings: {
16
- reasoning: { effort: 'low' },
16
+ reasoning: { effort: "low" },
17
},
18
tools: [
19
hostedMcpTool({
20
serverLabel: "composio",
21
serverUrl: mcp.url,
22
headers: {
23
- 'x-api-key': composioApiKey,
23
+ "x-api-key": composioApiKey,
24
},
25
}),
26
],
27
});
28
29
-console.log("Running the Open AI agent to fetch gmail inbox")
30
-const result = await run(
31
- agent,
32
- "Summarize all the emails in my Gmail inbox today"
33
-);
34
-console.log(result.finalOutput);
29
+const rl = createInterface({ input: process.stdin, output: process.stdout });
30
+while (true) {
31
+ const input = await rl.question("You: ");
32
+ if (input === "exit") break;
33
+ const result = await run(agent, input);
34
+ console.log(`Agent: ${result.finalOutput}\n`);
35
+}
36
+rl.close();