Vercel AI SDK Integration
Use Aerostack workspace tools with the Vercel AI SDK. Tools auto-execute — no manual tool call handling needed.
Install
Section titled “Install”npm install @aerostack/sdk-vercel-ai ai @ai-sdk/openaiQuick Start
Section titled “Quick Start”import { openai } from '@ai-sdk/openai';import { generateText } from 'ai';import { getTools } from '@aerostack/sdk-vercel-ai';
const { tools } = await getTools({ workspace: 'my-workspace', token: 'mwt_...',});
const { text } = await generateText({ model: openai('gpt-4o'), tools, maxSteps: 5, prompt: 'Create a GitHub issue for the login bug',});
console.log(text);That’s it. The SDK:
- Fetches all MCP tools from your workspace
- Converts them to Vercel AI SDK tool format
- Each tool has a built-in
executefunction that calls the workspace gateway maxStepsenables automatic multi-step tool execution
Streaming Responses
Section titled “Streaming Responses”import { openai } from '@ai-sdk/openai';import { streamText } from 'ai';import { getTools } from '@aerostack/sdk-vercel-ai';
const { tools } = await getTools({ workspace: 'my-workspace', token: 'mwt_...',});
const result = streamText({ model: openai('gpt-4o'), tools, maxSteps: 5, prompt: 'Summarize the latest Notion pages and post to Slack',});
for await (const chunk of result.textStream) { process.stdout.write(chunk);}Use Any LLM Provider
Section titled “Use Any LLM Provider”The Vercel AI SDK supports multiple providers. Aerostack tools work with all of them:
import { anthropic } from '@ai-sdk/anthropic';import { google } from '@ai-sdk/google';import { generateText } from 'ai';import { getTools } from '@aerostack/sdk-vercel-ai';
const { tools } = await getTools({ workspace: 'my-workspace', token: 'mwt_...',});
// Use with Claudeconst { text } = await generateText({ model: anthropic('claude-sonnet-4-20250514'), tools, maxSteps: 5, prompt: 'Check Stripe payments from this week',});Factory Pattern (Recommended for Production)
Section titled “Factory Pattern (Recommended for Production)”Reuse a single client instance across requests:
import { openai } from '@ai-sdk/openai';import { generateText } from 'ai';import { createAerostackVercelAI } from '@aerostack/sdk-vercel-ai';
const aerostack = createAerostackVercelAI({ workspace: 'my-workspace', token: process.env.AEROSTACK_WORKSPACE_TOKEN!,});
// In your API route or server action:export async function POST(req: Request) { const { prompt } = await req.json(); const { tools } = await aerostack.tools();
const { text } = await generateText({ model: openai('gpt-4o'), tools, maxSteps: 5, prompt, });
return Response.json({ text });}What getTools Returns
Section titled “What getTools Returns”const result = await getTools(config);
result.tools // VercelToolSet — pass to generateText/streamTextresult.raw // McpTool[] — raw MCP tool definitions for inspectionNext Steps
Section titled “Next Steps”- Create a workspace and connect MCP servers
- Browse 250+ MCP servers in the registry
- See the full API reference on GitHub