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.

Update examples in readme.md

haxziee9d6756538b2
diff --git a/packages/toolsets/cloudflare/README.md b/packages/toolsets/cloudflare/README.md
new file mode 100644
index 000000000..fde1dfa22
--- /dev/null
+++ b/packages/toolsets/cloudflare/README.md
@@ -0,0 +1,166 @@
+# @composio/cloudflare
+
+The Cloudflare AI toolset for Composio SDK, providing seamless integration with Cloudflare's AI capabilities and Workers AI.
+
+## Features
+
+- **Workers AI Integration**: Seamless integration with Cloudflare Workers AI
+- **Streaming Support**: First-class support for streaming responses
+- **Model Support**: Support for all Cloudflare AI models (@cf/meta/llama-2-7b-chat-int8, etc.)
+- **Edge Deployment**: Deploy and run AI models at the edge
+- **Tool Execution**: Execute tools with proper parameter handling
+- **Type Safety**: Full TypeScript support with proper type definitions
+
+## Installation
+
+```bash
+npm install @composio/cloudflare
+# or
+yarn add @composio/cloudflare
+# or
+pnpm add @composio/cloudflare
+```
+
+## Quick Start
+
+```typescript
+import { Composio } from '@composio/core';
+import { CloudflareToolset } from '@composio/cloudflare';
+
+// Initialize Composio with Cloudflare toolset
+const composio = new Composio({
+ apiKey: 'your-composio-api-key',
+ toolset: new CloudflareToolset({
+ accountId: 'your-cloudflare-account-id',
+ apiToken: 'your-cloudflare-api-token',
+ }),
+});
+
+// Get available tools
+const tools = await composio.tools.get('user123', {
+ apps: ['gmail', 'googlecalendar'],
+ limit: 10,
+});
+```
+
+## Usage Examples
+
+### Basic Chat Completion with Streaming
+
+```typescript
+import { Composio } from '@composio/core';
+import { CloudflareToolset } from '@composio/cloudflare';
+import { Ai } from '@cloudflare/ai';
+
+// Initialize Composio
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new CloudflareToolset(),
+});
+
+// In your Worker
+export default {
+ async fetch(request: Request, env: Env, ctx: ExecutionContext) {
+ const ai = new Ai(env.AI);
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+ });
+
+ const messages = [
+ { role: 'system', content: 'You are a helpful assistant.' },
+ { role: 'user', content: 'What can you do?' },
+ ];
+
+ const stream = await ai.run('@cf/meta/llama-2-7b-chat-int8', {
+ messages,
+ tools,
+ stream: true,
+ });
+
+ return new Response(stream, {
+ headers: {
+ 'content-type': 'text/event-stream',
+ },
+ });
+ },
+};
+```
+
+### Multi-Modal Example
+
+```typescript
+import { Composio } from '@composio/core';
+import { CloudflareToolset } from '@composio/cloudflare';
+import { Ai } from '@cloudflare/ai';
+
+// Initialize Composio
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new CloudflareToolset(),
+});
+
+// In your Worker
+export default {
+ async fetch(request: Request, env: Env, ctx: ExecutionContext) {
+ const ai = new Ai(env.AI);
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+ });
+
+ // Image analysis
+ const imageResponse = await ai.run('@cf/microsoft/resnet-50', {
+ image: await request.arrayBuffer(),
+ });
+
+ // Use image analysis in chat
+ const messages = [
+ { role: 'system', content: 'You are a helpful assistant.' },
+ {
+ role: 'user',
+ content: 'What do you see in this image?',
+ context: { image_analysis: imageResponse },
+ },
+ ];
+
+ const stream = await ai.run('@cf/meta/llama-2-7b-chat-int8', {
+ messages,
+ tools,
+ stream: true,
+ });
+
+ return new Response(stream, {
+ headers: {
+ 'content-type': 'text/event-stream',
+ },
+ });
+ },
+};
+```
+
+## API Reference
+
+### CloudflareToolset Class
+
+The `CloudflareToolset` class extends `BaseComposioToolset` and provides Cloudflare-specific functionality.
+
+#### Methods
+
+##### `executeToolCall(tool: ToolCall): Promise<string>`
+
+Executes a tool call and returns the result.
+
+```typescript
+const result = await composio.toolset.executeToolCall(toolCall);
+```
+
+## Contributing
+
+We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
+
+## License
+
+ISC License
+
+## Support
+
+For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
diff --git a/packages/toolsets/langchain/README.md b/packages/toolsets/langchain/README.md
new file mode 100644
index 000000000..ab2b94c16
--- /dev/null
+++ b/packages/toolsets/langchain/README.md
@@ -0,0 +1,215 @@
+# @composio/langchain
+
+The LangChain toolset for Composio SDK, providing seamless integration with LangChain's ecosystem and tools.
+
+## Features
+
+- **LangChain Integration**: Seamless integration with LangChain's ecosystem
+- **LCEL Support**: Full support for LangChain Expression Language (LCEL)
+- **Streaming Support**: First-class support for streaming responses
+- **Tool Execution**: Execute LangChain tools with proper parameter handling
+- **Chain Integration**: Work with LangChain chains and agents
+- **Type Safety**: Full TypeScript support with proper type definitions
+
+## Installation
+
+```bash
+npm install @composio/langchain
+# or
+yarn add @composio/langchain
+# or
+pnpm add @composio/langchain
+```
+
+## Quick Start
+
+```typescript
+import { Composio } from '@composio/core';
+import { LangChainToolset } from '@composio/langchain';
+
+// Initialize Composio with LangChain toolset
+const composio = new Composio({
+ apiKey: 'your-composio-api-key',
+ toolset: new LangChainToolset(),
+});
+
+// Get available tools
+const tools = await composio.tools.get('user123', {
+ apps: ['gmail', 'googlecalendar'],
+ limit: 10,
+});
+
+// Get a specific tool
+const sendEmailTool = await composio.tools.get('user123', 'GMAIL_SEND_EMAIL');
+```
+
+## Usage Examples
+
+### Basic Chain with Streaming
+
+```typescript
+import { Composio } from '@composio/core';
+import { LangChainToolset } from '@composio/langchain';
+import { ChatPromptTemplate } from '@langchain/core/prompts';
+import { StringOutputParser } from '@langchain/core/output_parsers';
+import { ChatOpenAI } from '@langchain/openai';
+
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new LangChainToolset(),
+});
+
+// Get tools for the chain
+const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+ limit: 10,
+});
+
+const model = new ChatOpenAI({
+ modelName: 'gpt-4',
+ streaming: true,
+});
+
+const prompt = ChatPromptTemplate.fromTemplate('Tell me a joke about {topic}');
+const parser = new StringOutputParser();
+
+const chain = prompt.pipe(model).pipe(parser);
+
+// Stream the response
+const stream = await chain.stream({
+ topic: 'programming',
+});
+
+for await (const chunk of stream) {
+ console.log(chunk);
+}
+```
+
+### Tool Execution with Streaming Events
+
+```typescript
+import { Composio } from '@composio/core';
+import { LangChainToolset } from '@composio/langchain';
+import { ChatPromptTemplate } from '@langchain/core/prompts';
+import { JsonOutputParser } from '@langchain/core/output_parsers';
+import { ChatOpenAI } from '@langchain/openai';
+
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new LangChainToolset(),
+});
+
+// Get tools for the chain
+const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+});
+
+const model = new ChatOpenAI({
+ modelName: 'gpt-4',
+ streaming: true,
+});
+
+const chain = model.pipe(new JsonOutputParser());
+const eventStream = await chain.streamEvents(
+ `Output a list of the countries france, spain and japan and their populations in JSON format.`,
+ { version: 'v2' }
+);
+
+for await (const event of eventStream) {
+ const eventType = event.event;
+ if (eventType === 'on_chat_model_stream') {
+ console.log(`Chat model chunk: ${event.data.chunk.content}`);
+ } else if (eventType === 'on_parser_stream') {
+ console.log(`Parser chunk: ${JSON.stringify(event.data.chunk)}`);
+ }
+}
+```
+
+### RAG Application Example
+
+```typescript
+import { Composio } from '@composio/core';
+import { LangChainToolset } from '@composio/langchain';
+import { ChatPromptTemplate } from '@langchain/core/prompts';
+import { StringOutputParser } from '@langchain/core/output_parsers';
+import { MemoryVectorStore } from 'langchain/vectorstores/memory';
+import { OpenAIEmbeddings } from '@langchain/openai';
+import { ChatOpenAI } from '@langchain/openai';
+import { RunnableSequence, RunnablePassthrough } from '@langchain/core/runnables';
+
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new LangChainToolset(),
+});
+
+// Get tools for the chain
+const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+});
+
+// Setup vector store and retriever
+const vectorstore = await MemoryVectorStore.fromTexts(
+ ['some text', 'more text'],
+ [{ id: 1 }, { id: 2 }],
+ new OpenAIEmbeddings()
+);
+
+const retriever = vectorstore.asRetriever();
+
+// Create RAG chain
+const template = `Answer the question based only on the following context:
+{context}
+
+Question: {question}`;
+
+const prompt = ChatPromptTemplate.fromTemplate(template);
+const model = new ChatOpenAI({
+ modelName: 'gpt-4',
+ streaming: true,
+});
+
+const chain = RunnableSequence.from([
+ {
+ context: retriever.pipe(formatDocs),
+ question: new RunnablePassthrough(),
+ },
+ prompt,
+ model,
+ new StringOutputParser(),
+]);
+
+// Stream the response
+const stream = await chain.stream('What is the answer?');
+
+for await (const chunk of stream) {
+ console.log(chunk);
+}
+```
+
+## API Reference
+
+### LangChainToolset Class
+
+The `LangChainToolset` class extends `BaseComposioToolset` and provides LangChain-specific functionality.
+
+#### Methods
+
+##### `executeToolCall(tool: Tool): Promise<string>`
+
+Executes a LangChain tool call and returns the result.
+
+```typescript
+const result = await toolset.executeToolCall(tool);
+```
+
+## Contributing
+
+We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
+
+## License
+
+ISC License
+
+## Support
+
+For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
diff --git a/packages/toolsets/openai/README.md b/packages/toolsets/openai/README.md
index 736b1b9d5..dda68bbc9 100644
--- a/packages/toolsets/openai/README.md
+++ b/packages/toolsets/openai/README.md
@@ -1,14 +1,15 @@
# @composio/openai
-The OpenAI toolset for Composio SDK, providing seamless integration with OpenAI's API and tools.
+The OpenAI toolset for Composio SDK, providing seamless integration with OpenAI's models and function calling capabilities.
## Features
-- **OpenAI Tool Integration**: Seamlessly integrate OpenAI tools with Composio
-- **Tool Execution**: Execute OpenAI tools with proper parameter handling
-- **Stream Support**: Handle streaming responses from OpenAI
-- **Assistant Integration**: Work with OpenAI Assistants and their tool calls
-- **Thread Management**: Manage OpenAI threads and runs
+- **OpenAI Integration**: Seamless integration with OpenAI's models
+- **Streaming Support**: First-class support for streaming responses
+- **Function Calling**: Support for OpenAI's function calling feature
+- **Tool Execution**: Execute tools with proper parameter handling
+- **Type Safety**: Full TypeScript support with proper type definitions
+- **Model Support**: Support for all OpenAI models (GPT-4, GPT-3.5-turbo, etc.)
## Installation
@@ -29,64 +30,103 @@ import { OpenAIToolset } from '@composio/openai';
// Initialize Composio with OpenAI toolset
const composio = new Composio({
apiKey: 'your-composio-api-key',
- toolset: new OpenAIToolset()
+ toolset: new OpenAIToolset(),
});
-// Get available tools in OpenAI format
-const tools = await composio.getTools();
+// Get available tools
+const tools = await composio.tools.get('user123', {
+ apps: ['gmail', 'googlecalendar'],
+ limit: 10,
+});
-// Execute a tool call
-const result = await composio.toolset.executeToolCall(toolCall, 'user-id');
+// Get a specific tool
+const sendEmailTool = await composio.tools.get('user123', 'GMAIL_SEND_EMAIL');
```
-## API Reference
+## Usage Examples
-### OpenAIToolset Class
-
-The `OpenAIToolset` class extends `BaseComposioToolset` and provides OpenAI-specific functionality.
-
-#### Methods
-
-##### `executeToolCall(tool: OpenAI.ChatCompletionMessageToolCall, userId?: string): Promise<string>`
-Executes a tool call from OpenAI and returns the result.
+### Basic Chat Completion with Streaming
```typescript
-const result = await toolset.executeToolCall(toolCall, 'user-id');
-```
+import { Composio } from '@composio/core';
+import { OpenAIToolset } from '@composio/openai';
+import OpenAI from 'openai';
-##### `handleToolCall(chatCompletion: OpenAI.ChatCompletion, userId?: string): Promise<string[]>`
-Handles tool calls from a chat completion.
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new OpenAIToolset(),
+});
-```typescript
-const outputs = await toolset.handleToolCall(chatCompletion, 'user-id');
+// Example API route
+export async function POST(req: Request) {
+ const { messages } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+ });
+
+ const stream = await openai.chat.completions.create({
+ model: 'gpt-4',
+ messages,
+ tools,
+ stream: true,
+ });
+
+ return new Response(stream, {
+ headers: {
+ 'content-type': 'text/event-stream',
+ },
+ });
+}
```
-##### `handleAssistantMessage(run: OpenAI.Beta.Threads.Run, userId?: string): Promise<OpenAI.Beta.Threads.Runs.RunSubmitToolOutputsParams.ToolOutput[]>`
-Handles tool calls from an assistant message.
+### Tool Execution with Streaming
```typescript
-const toolOutputs = await toolset.handleAssistantMessage(run, 'user-id');
-```
+import { Composio } from '@composio/core';
+import { OpenAIToolset } from '@composio/openai';
+import OpenAI from 'openai';
-##### `waitAndHandleAssistantStreamToolCalls(client: OpenAI, runStream: Stream<OpenAI.Beta.Assistants.AssistantStreamEvent>, thread: OpenAI.Beta.Threads.Thread, userId?: string): AsyncGenerator<OpenAI.Beta.Assistants.AssistantStreamEvent, void, unknown>`
-Waits for and handles tool calls from an assistant stream.
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new OpenAIToolset(),
+});
-```typescript
-for await (const event of toolset.waitAndHandleAssistantStreamToolCalls(client, runStream, thread, 'user-id')) {
- // Handle events
+// Example API route that handles tool execution
+export async function POST(req: Request) {
+ const { messages } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail', 'googlecalendar'],
+ });
+
+ const stream = await openai.chat.completions.create({
+ model: 'gpt-4',
+ messages,
+ tools,
+ tool_choice: 'auto',
+ stream: true,
+ });
+
+ const chunks = [];
+ for await (const chunk of stream) {
+ if (chunk.choices[0]?.delta?.tool_calls) {
+ const toolCall = chunk.choices[0].delta.tool_calls[0];
+ const result = await composio.toolset.executeToolCall(toolCall);
+ // Handle tool execution result
+ chunks.push(result);
+ } else {
+ chunks.push(chunk.choices[0]?.delta?.content || '');
+ }
+ }
+
+ return new Response(chunks.join(''), {
+ headers: {
+ 'content-type': 'text/plain',
+ },
+ });
}
```
-##### `waitAndHandleAssistantToolCalls(client: OpenAI, run: OpenAI.Beta.Threads.Run, thread: OpenAI.Beta.Threads.Thread, userId?: string): Promise<OpenAI.Beta.Threads.Run>`
-Waits for and handles tool calls from an assistant.
-
-```typescript
-const finalRun = await toolset.waitAndHandleAssistantToolCalls(client, run, thread, 'user-id');
-```
-
-## Examples
-
-### Basic Tool Execution
+### JSON Mode Example
```typescript
import { Composio } from '@composio/core';
@@ -94,35 +134,29 @@ import { OpenAIToolset } from '@composio/openai';
import OpenAI from 'openai';
const composio = new Composio({
- apiKey: 'your-composio-api-key',
- toolset: new OpenAIToolset()
-});
-
-const openai = new OpenAI({
- apiKey: 'your-openai-api-key'
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new OpenAIToolset(),
});
-// Get available tools
-const tools = await composio.getTools();
-
-// Create a chat completion with tools
-const completion = await openai.chat.completions.create({
- model: 'gpt-4',
- messages: [{ role: 'user', content: 'What can you do?' }],
- tools: tools
-});
-
-// Handle tool calls
-if (completion.choices[0].message.tool_calls) {
- const result = await composio.toolset.executeToolCall(
- completion.choices[0].message.tool_calls[0],
- 'user-id'
- );
- console.log(result);
+// Example API route that returns JSON
+export async function POST(req: Request) {
+ const { messages } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+ });
+
+ const completion = await openai.chat.completions.create({
+ model: 'gpt-4',
+ messages,
+ tools,
+ response_format: { type: 'json_object' },
+ });
+
+ return Response.json(JSON.parse(completion.choices[0].message.content || '{}'));
}
```
-### Working with Assistants
+### Vision Example
```typescript
import { Composio } from '@composio/core';
@@ -130,37 +164,53 @@ import { OpenAIToolset } from '@composio/openai';
import OpenAI from 'openai';
const composio = new Composio({
- apiKey: 'your-composio-api-key',
- toolset: new OpenAIToolset()
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new OpenAIToolset(),
});
-const openai = new OpenAI({
- apiKey: 'your-openai-api-key'
-});
+// Example API route that handles image analysis
+export async function POST(req: Request) {
+ const { messages, image } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+ });
+
+ const completion = await openai.chat.completions.create({
+ model: 'gpt-4-vision-preview',
+ messages: [
+ ...messages,
+ {
+ role: 'user',
+ content: [
+ { type: 'text', text: 'What do you see in this image?' },
+ { type: 'image_url', image_url: image },
+ ],
+ },
+ ],
+ tools,
+ max_tokens: 500,
+ });
+
+ return Response.json({
+ content: completion.choices[0].message.content,
+ });
+}
+```
-// Create an assistant with tools
-const assistant = await openai.beta.assistants.create({
- name: 'Composio Assistant',
- instructions: 'You are a helpful assistant that can use Composio tools.',
- model: 'gpt-4',
- tools: await composio.getTools()
-});
+## API Reference
-// Create a thread
-const thread = await openai.beta.threads.create();
+### OpenAIToolset Class
-// Create a run
-const run = await openai.beta.threads.runs.create(thread.id, {
- assistant_id: assistant.id
-});
+The `OpenAIToolset` class extends `BaseComposioToolset` and provides OpenAI-specific functionality.
+
+#### Methods
-// Wait for and handle tool calls
-const finalRun = await composio.toolset.waitAndHandleAssistantToolCalls(
- openai,
- run,
- thread,
- 'user-id'
-);
+##### `executeToolCall(tool: ToolCall): Promise<string>`
+
+Executes a tool call and returns the result.
+
+```typescript
+const result = await toolset.executeToolCall(toolCall);
```
## Contributing
@@ -173,4 +223,4 @@ ISC License
## Support
-For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
\ No newline at end of file
+For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).
diff --git a/packages/toolsets/vercel/README.md b/packages/toolsets/vercel/README.md
new file mode 100644
index 000000000..0e71a456c
--- /dev/null
+++ b/packages/toolsets/vercel/README.md
@@ -0,0 +1,217 @@
+# @composio/vercel
+
+The Vercel AI SDK toolset for Composio SDK, providing seamless integration with Vercel's AI SDK and tools.
+
+## Features
+
+- **Vercel AI SDK Integration**: Seamless integration with Vercel's AI SDK
+- **Streaming Support**: First-class support for streaming responses
+- **Model Agnostic**: Works with any model supported by Vercel AI SDK (OpenAI, Anthropic, etc.)
+- **UI Components**: Integration with Vercel's React components for chat interfaces
+- **Tool Execution**: Execute tools with proper parameter handling and streaming
+- **Type Safety**: Full TypeScript support with proper type definitions
+
+## Installation
+
+```bash
+npm install @composio/vercel
+# or
+yarn add @composio/vercel
+# or
+pnpm add @composio/vercel
+```
+
+## Quick Start
+
+```typescript
+import { Composio } from '@composio/core';
+import { VercelToolset } from '@composio/vercel';
+
+// Initialize Composio with Vercel toolset
+const composio = new Composio({
+ apiKey: 'your-composio-api-key',
+ toolset: new VercelToolset(),
+});
+
+// Get available tools
+const tools = await composio.tools.get('user123', {
+ apps: ['gmail', 'googlecalendar'],
+ limit: 10,
+});
+
+// Get a specific tool
+const sendEmailTool = await composio.tools.get('user123', 'GMAIL_SEND_EMAIL');
+```
+
+## Usage Examples
+
+### Basic Chat Completion with Streaming
+
+```typescript
+import { Composio } from '@composio/core';
+import { VercelToolset } from '@composio/vercel';
+import { useChat } from 'ai/react';
+
+// Initialize Composio with Vercel toolset
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new VercelToolset()
+});
+
+// In your React component
+function ChatComponent() {
+ const { messages, input, handleInputChange, handleSubmit } = useChat({
+ api: '/api/chat',
+ });
+
+ return (
+ <div>
+ {messages.map(m => (
+ <div key={m.id}>
+ {m.role === 'user' ? 'User: ' : 'AI: '}
+ {m.content}
+ </div>
+ ))}
+
+ <form onSubmit={handleSubmit}>
+ <input
+ value={input}
+ onChange={handleInputChange}
+ placeholder="Say something..."
+ />
+ <button type="submit">Send</button>
+ </form>
+ </div>
+ );
+}
+
+// In your API route (e.g. app/api/chat/route.ts)
+import { streamText } from 'ai';
+import { openai } from '@ai-sdk/openai';
+
+export async function POST(req: Request) {
+ const { messages } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+ });
+
+ const result = streamText({
+ model: openai('gpt-4'),
+ messages,
+ tools,
+ });
+
+ return result.toDataStreamResponse();
+}
+```
+
+### Tool Execution with Streaming
+
+```typescript
+import { Composio } from '@composio/core';
+import { VercelToolset } from '@composio/vercel';
+import { streamText } from 'ai';
+
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new VercelToolset(),
+});
+
+// Example API route that handles tool execution
+export async function POST(req: Request) {
+ const { messages } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail', 'googlecalendar'],
+ });
+
+ const stream = streamText({
+ model: openai('gpt-4'),
+ messages,
+ tools,
+ callbacks: {
+ onToolCall: async tool => {
+ // Execute the tool and return result
+ return await composio.toolset.executeToolCall(tool);
+ },
+ },
+ });
+
+ return stream.toDataStreamResponse();
+}
+```
+
+### Structured Output with Streaming
+
+```typescript
+import { Composio } from '@composio/core';
+import { VercelToolset } from '@composio/vercel';
+import { streamObject } from 'ai';
+
+const composio = new Composio({
+ apiKey: process.env.COMPOSIO_API_KEY,
+ toolset: new VercelToolset(),
+});
+
+// Example API route that returns structured data
+export async function POST(req: Request) {
+ const { messages } = await req.json();
+ const tools = await composio.tools.get('user123', {
+ apps: ['gmail'],
+ });
+
+ const stream = streamObject({
+ model: openai('gpt-4'),
+ messages,
+ tools,
+ schema: {
+ type: 'object',
+ properties: {
+ name: { type: 'string' },
+ age: { type: 'number' },
+ interests: { type: 'array', items: { type: 'string' } },
+ },
+ required: ['name', 'age', 'interests'],
+ },
+ });
+
+ return stream.toDataStreamResponse();
+}
+```
+
+## API Reference
+
+### VercelToolset Class
+
+The `VercelToolset` class extends `BaseComposioToolset` and provides Vercel AI SDK-specific functionality.
+
+#### Methods
+
+##### `executeToolCall(tool: ToolCall): Promise<string>`
+
+Executes a tool call and returns the result.
+
+```typescript
+const result = await toolset.executeToolCall(toolCall);
+```
+
+##### `handleToolCalls(stream: AIStream): AsyncGenerator<AIStreamEvent>`
+
+Handles tool calls from a stream and yields events.
+
+```typescript
+for await (const event of toolset.handleToolCalls(stream)) {
+ // Handle events
+}
+```
+
+## Contributing
+
+We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for more details.
+
+## License
+
+ISC License
+
+## Support
+
+For support, please visit our [Documentation](https://docs.composio.dev) or join our [Discord Community](https://discord.gg/composio).