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

next
ts 24 lines 689 Bytes
Raw
1 import { Composio } from '@composio/core';
2 import { stepCountIs, streamText } from 'ai';
3 import { openai } from '@ai-sdk/openai';
4 import { VercelProvider } from '@composio/vercel';
5
6 /**
7 * Initialize the Composio SDK with the Vercel provider
8 */
9 const composio = new Composio({
10 apiKey: process.env.COMPOSIO_API_KEY,
11 provider: new VercelProvider(),
12 });
13
14 const tools = await composio.tools.get('test-user-id', 'HACKERNEWS_GET_TOP_STORIES');
15 const stream = await streamText({
16 model: openai('gpt-4o-mini'),
17 tools,
18 prompt: 'Summarize the front page of HackerNews',
19 stopWhen: stepCountIs(5),
20 });
21
22 for await (const textPart of stream.textStream) {
23 process.stdout.write(textPart);
24 }