FrameworksJavaScript FrameworksUsing Composio JS SDK with OpenAIDemo 1Get Composio API KeyFollow this Get API Key to get your Composio API Key2Install DependenciesInstall dependencies$npm install composio-core openai >yarn add composio-core openai >pnpm add composio-core openai3Define method to let user connect their GitHub accountindex.mjs1import { OpenAI } from "openai";2import { OpenAIToolSet } from "composio-core";34const COMPOSIO_API_KEY = "<your-composio-api-key>"5const OPEN_AI_API_KEY = "<your-openai-api-key>"6const toolset = new OpenAIToolSet({apiKey: COMPOSIO_API_KEY,});78const appName = 'github';910async function setupUserConnectionIfNotExists(entityId) {11 const entity = toolset.client.getEntity(entityId);12 const connection = await entity.getConnection({ appName: appName });1314 if (!connection) {15 const connection = await entity.initiateConnection({appName: appName});16 console.log("Log in via: ", connection.redirectUrl);17 return connection.waitUntilActive(60);18 }1920 return connection;21}Learn more about entities here4Setup Agent with OpenAIindex.mjs1async function executeAgent(repo,entityName="default") {2 const entity = toolset.client.getEntity(entityName)3 await setupUserConnectionIfNotExists(entity.id);45 const tools = await toolset.getTools({ actions: ["github_issues_create"] }, entity.id);6 const instruction = `Make an issue with sample title in the repo - ${repo}`78 const client = new OpenAI({ apiKey: OPEN_AI_API_KEY })9 const response = await client.chat.completions.create({10 model: "gpt-4-turbo",11 messages: [{12 role: "user",13 content: instruction,14 }],15 tools: tools,16 tool_choice: "auto",17 })1819 console.log(response.choices[0].message.tool_calls);20 await toolset.handleToolCall(response, entity.id);21}5Invoke Your Agentindex.mjs1executeAgent("himanshu-dixit/custom-repo-breaking")Tada 🎉! It was this simple to create a powerful Agent with Composio and OpenAI.6Complete code snippetView the full snippet hereBuilt with