Vercel AI SDK Integration
Give your AI SDK agent the knowledge of a whole website
Overview
The Vercel AI SDK is the TypeScript toolkit for building AI apps and agents with generateText, streamText and agents. The @asyntai/ai-sdk package gives those agents a website to draw on.
Point Asyntai at a domain. Asyntai crawls the site, reads the product feed, and keeps both fresh. Your agent then asks that website a question and gets the answer a visitor would get, built from the real pages and the real prices.
The same package opens the other side of the website: the chats visitors had, and the email addresses and phone numbers they left.
Tools
The package adds six tools:
askWebsite— answers a question from the website's pages, products and knowledge base.addKnowledgeUrl— reads a page and stores its content.addKnowledgeText— stores a title and a text you write.listKnowledge— lists what the website agent knows.getLeads— returns visitors who left an email address or a phone number, newest first.getConversation— returns the messages of one website chat.
Requirements
- Node.js 20 or higher
- AI SDK 5, 6 or 7 (the
aipackage) andzod - An Asyntai account on the Starter plan or higher, because the package uses the Asyntai API
Installation
Follow these steps to add Asyntai to an AI SDK app:
Install the Package
Run npm install @asyntai/ai-sdk. You also need ai and zod, which most AI SDK apps already have.
Get Your API Key
Sign in to Asyntai, open Settings, then API, and copy your API key.
Set the Key
Put the key in the ASYNTAI_API_KEY environment variable, or pass it as apiKey to any tool.
Add the Tools
Pass the tools to generateText, streamText or an agent. asyntaiTools() gives you all six at once.
Ask a Website a Question
import { generateText, isStepCount } from 'ai';
import { askWebsite } from '@asyntai/ai-sdk';
const { text } = await generateText({
model: 'anthropic/claude-sonnet-5.5',
prompt: 'A customer asks: how long does delivery take?',
tools: { askWebsite: askWebsite() },
stopWhen: isStepCount(3),
});
console.log(text);
Give an Agent Every Tool
import { generateText, isStepCount } from 'ai';
import { asyntaiTools } from '@asyntai/ai-sdk';
const { text } = await generateText({
model: 'anthropic/claude-sonnet-5.5',
prompt: 'List the leads from this week and summarize what each visitor wanted.',
tools: asyntaiTools(),
stopWhen: isStepCount(6),
});
Several Agents on One Account
An Asyntai account can run an agent per website. Name the one you want with websiteId.
const tools = asyntaiTools({ websiteId: 42 });
Agencies run this pattern across a client book: one Asyntai account, one agent per client site, one websiteId per agent.
Tip: The answer quality follows the knowledge base. Add the pages that matter with addKnowledgeUrl, and check the result with listKnowledge.
Errors
Every failure throws AsyntaiError with a message you can show to a user. A wrong key, a plan that is too low, and a reached message limit each have their own message. Inside generateText, the AI SDK passes the error to the model as a tool error, so the agent can explain it.
Plans & Pricing
The package is free. It uses the Asyntai API, which needs the Starter plan or higher. View pricing.
Need Help?
If you have any questions or run into issues, contact us at [email protected].