Skip to content

Vercel AI SDK Integration

Use Aerostack workspace tools with the Vercel AI SDK. Tools auto-execute — no manual tool call handling needed.

Terminal window
npm install @aerostack/sdk-vercel-ai ai @ai-sdk/openai
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:

  1. Fetches all MCP tools from your workspace
  2. Converts them to Vercel AI SDK tool format
  3. Each tool has a built-in execute function that calls the workspace gateway
  4. maxSteps enables automatic multi-step tool execution
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);
}

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 Claude
const { text } = await generateText({
model: anthropic('claude-sonnet-4-20250514'),
tools,
maxSteps: 5,
prompt: 'Check Stripe payments from this week',
});
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 });
}
const result = await getTools(config);
result.tools // VercelToolSet — pass to generateText/streamText
result.raw // McpTool[] — raw MCP tool definitions for inspection