@devries-cameron20 / composio-1 / commits / 6cda8a630
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

responses

Sushmithamallesh committed Oct 7, 2025 at 17:01 UTC 6cda8a630f8e96484958d7b50679c0a9e1778886
2 files changed +72 -40
fern/snippets/providers/typescript/openai.ts
+34 -40
@@ -1,45 +1,39 @@
1 +import OpenAI from 'openai';
2 import { Composio } from '@composio/core';
2 -import { OpenAIResponsesProvider, OpenAIProvider } from '@composio/openai';
3 -import { OpenAI } from 'openai';
3 +import { OpenAIProvider } from '@composio/openai';
4
5 -// Initialise Composio client with the OpenAI provider.
6 -const composioForResponses = new Composio({ provider: new OpenAIResponsesProvider() });
7 -const openai = new OpenAI();
8 -
9 -const userId = 'your@example.com';
10 -const toolsForResponses = await composioForResponses.tools.get(userId, {
11 - toolkits: ['HACKERNEWS'],
12 -});
13 -
14 -const response = await openai.responses.create({
15 - model: 'gpt-4.1',
16 - input: "What's the lates Hackernews post about?",
17 - tools: toolsForResponses,
5 +// Initialize Composio client with OpenAI Provider
6 +const composio = new Composio({
7 + provider: new OpenAIProvider(),
8 });
9
20 -const result = await composioForResponses.provider.handleResponse(userId, response);
21 -
22 -console.log('RESPONSE API');
23 -console.log(JSON.stringify(result, null, 2));
24 -// will return the raw response from the HACKERNEWS API.
25 -
26 -const composioForCompletions = new Composio({ provider: new OpenAIProvider() });
27 -const toolsForCompletions = await composioForCompletions.tools.get(userId, {
28 - toolkits: ['HACKERNEWS'],
29 -});
30 -
31 -const completion = await openai.chat.completions.create({
32 - model: 'gpt-4o',
33 - messages: [
34 - {
35 - role: 'user',
36 - content: 'What is the latest hackernews post about?',
37 - },
38 - ],
39 - tools: toolsForCompletions,
40 -});
41 -
42 -const newResult = await composioForCompletions.provider.handleToolCalls(userId, completion);
10 +const openai = new OpenAI();
11
44 -console.log(JSON.stringify(newResult, null, 2));
45 -// will return the raw response from the HACKERNEWS API.
12 +// Make sure to create an auth config and a connected account for the user with gmail toolkit
13 +// Make sure to replace "your-user-id" with the actual user ID
14 +const userId = "your-user-id";
15 +
16 +async function main() {
17 + try {
18 + const tools = await composio.tools.get(userId, {tools: ["GMAIL_SEND_EMAIL"]});
19 +
20 + const response = await openai.chat.completions.create({
21 + model: "gpt-5",
22 + tools: tools,
23 + messages: [
24 + {
25 + role: "user",
26 + content: "Send an email to soham.g@composio.dev with the subject 'Running OpenAI Provider snippet' and body 'Hello from the code snippet in openai docs'"
27 + },
28 + ],
29 + });
30 +
31 + // Execute the function calls
32 + const result = await composio.provider.handleToolCalls(userId, response);
33 + console.log(result);
34 + } catch (error) {
35 + console.error('Error:', error);
36 + }
37 +}
38 +
39 +main();
fern/snippets/providers/typescript/openairesponses.ts new
+38
@@ -0,0 +1,38 @@
1 +import OpenAI from 'openai';
2 +import { Composio } from '@composio/core';
3 +import { OpenAIResponsesProvider } from '@composio/openai';
4 +
5 +// Initialize Composio client with OpenAI Provider
6 +const composio = new Composio({
7 + provider: new OpenAIResponsesProvider(),
8 +});
9 +const openai = new OpenAI({});
10 +
11 +// Make sure to create an auth config and a connected account for the user with gmail toolkit
12 +// Make sure to replace "your-user-id" with the actual user ID
13 +const userId ="sush";
14 +
15 +async function main() {
16 + try {
17 + const tools = await composio.tools.get(userId, "GMAIL_SEND_EMAIL");
18 +
19 + const response = await openai.responses.create({
20 + model: "gpt-5",
21 + tools: tools,
22 + input: [
23 + {
24 + role: "user",
25 + content: "Send an email to soham.g@composio.dev with the subject 'Running OpenAI Provider snippet' and body 'Hello from the code snippet in openai docs'"
26 + },
27 + ],
28 + });
29 +
30 + // Execute the function calls
31 + const result = await composio.provider.handleToolCalls(userId, response.output);
32 + console.log(result);
33 + } catch (error) {
34 + console.error('Error:', error);
35 + }
36 +}
37 +
38 +main();