Vercel AI SDK

View as Markdown

Integrate You.com’s real-time web search and webpage content extraction capabilities into any application you’ve built with Vercel’s AI SDK.

The @youdotcom-oss/ai-sdk-plugin package provides three ready-made tools for the Vercel AI SDK:

  1. youSearch() for real-time web and news search
  2. youContents() for page content extraction
  3. youResearch() for comprehensive web research with citations

Drop all three into any generateText, streamText, or generateObject call to give your AI application real-time web access.

Starting from scratch? We recommend using Skills, so your agent can build this integration for you. Learn how.

Getting Started

Install the package

$npm install @youdotcom-oss/ai-sdk-plugin

Set your API key

$export api_key=api_key

Get your API key at you.com/platform.


Usage

Web search with youSearch

Use youSearch() to give a model access to structured real-time web and news results.

1import { generateText, stepCountIs } from "ai";
2import { youSearch } from "@youdotcom-oss/ai-sdk-plugin";
3import { anthropic } from "@ai-sdk/anthropic";
4
5const { text } = await generateText({
6 model: anthropic("claude-sonnet-4-5"),
7 prompt: "What happened in San Francisco last week?",
8 tools: {
9 search: youSearch(),
10 },
11 stopWhen: stepCountIs(3),
12});
13
14console.log(text);

Content extraction with youContents

Use youContents() when the model needs to retrieve entire web page content as HTML or markdown.

1import { generateText, stepCountIs } from "ai";
2import { youContents } from "@youdotcom-oss/ai-sdk-plugin";
3import { anthropic } from "@ai-sdk/anthropic";
4
5const { text } = await generateText({
6 model: anthropic("claude-sonnet-4-5"),
7 prompt: "Summarize the content from vercel.com/blog",
8 tools: {
9 extract: youContents(),
10 },
11 stopWhen: stepCountIs(3),
12});
13
14console.log(text);

Research with youResearch

Use youResearch() when the model needs comprehensive, synthesized answers with inline citations. The Research API supports effort levels (lite, standard, deep, exhaustive) to balance speed against thoroughness—the model selects the appropriate level automatically.

1import { generateText, stepCountIs } from "ai";
2import { youResearch } from "@youdotcom-oss/ai-sdk-plugin";
3import { anthropic } from "@ai-sdk/anthropic";
4
5const { text } = await generateText({
6 model: anthropic("claude-sonnet-4-5"),
7 prompt: "What are the tradeoffs between WebSockets and Server-Sent Events for real-time applications?",
8 tools: {
9 research: youResearch(),
10 },
11 stopWhen: stepCountIs(3),
12});
13
14console.log(text);

Combining all three tools

You can provide all three tools at once and let the model decide which to use:

1import { generateText, stepCountIs } from "ai";
2import { youSearch, youContents, youResearch } from "@youdotcom-oss/ai-sdk-plugin";
3import { anthropic } from "@ai-sdk/anthropic";
4
5const { text } = await generateText({
6 model: anthropic("claude-sonnet-4-5"),
7 prompt: "Find recent blog posts about the Vercel AI SDK, then extract and summarize the top result.",
8 tools: {
9 search: youSearch(),
10 extract: youContents(),
11 research: youResearch(),
12 },
13 stopWhen: stepCountIs(5),
14});
15
16console.log(text);

Passing the API key explicitly

If you prefer not to use environment variables, pass the key directly:

1import { youSearch, youContents, youResearch } from "@youdotcom-oss/ai-sdk-plugin";
2
3const searchTool = youSearch({ apiKey: "api_key" });
4const contentsTool = youContents({ apiKey: "api_key" });
5const researchTool = youResearch({ apiKey: "api_key" });

Resources