Using Composio With Vercel AI SDK

Star A Repository on Github

In this example, we will use Vercel AI SDK to star a repository on Github using Composio Tools

1

Install Packages

JavaScript
$npm install @ai-sdk/openai composio-core ai
2

Import Libraries & Initialize ComposioToolSet & LLM

JavaScript
1import { openai } from "@ai-sdk/openai";
2import { VercelAIToolSet } from "composio-core";
3import { generateText } from "ai";
4
5const toolset = new VercelAIToolSet();
3

Get All Github Tools

You can get all the tools for a given app as shown below, but you can get specific actions and filter actions using usecase & tags. Learn more here

JavaScript
1const tools = await toolset.getTools({ apps: ["github"] });
4

Define the Agent

JavaScript
1const output = await generateText({
2 model: openai("gpt-4o-mini"),
3 streamText: false,
4 tools,
5 prompt: 'Star the repository "composiohq/composio"',
6 maxToolRoundtrips: 5,
7});
5

Execute the Agent

JavaScript
1console.log(output.text);
Built with