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 two ready-made tools for the Vercel AI SDK:

  1. youSearch() for real-time web and news search
  2. youContents() for page content extraction

Drop them 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 YDC_API_KEY=your_api_key

Get your API key at you.com/platform/api-keys.


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);

Combining both tools

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

1import { generateText, stepCountIs } from "ai";
2import { youSearch, 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: "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 },
12 stopWhen: stepCountIs(5),
13});
14
15console.log(text);

Passing the API key explicitly

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

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

Resources