Skip to navigation

Vercel AI SDK

View as MarkdownOpen in Claude

Give your AI applications real-time access to the web through the hosted You.com MCP server. The @youdotcom-oss/ai-sdk-plugin package exposes an async createYouClient() helper that connects to https://api.you.com/mcp and returns the underlying AI SDK MCP client. By default, await client.tools() resolves to the default hosted tool set: you-search, you-contents, you-balance, and you-discover.

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

Getting Started

1

Install the Package

# NPM
npm install @youdotcom-oss/ai-sdk-plugin ai
# Bun
bun add @youdotcom-oss/ai-sdk-plugin ai
# Yarn
yarn add @youdotcom-oss/ai-sdk-plugin ai
2

Set Your API Key

export YDC_API_KEY="<YDC_API_KEY>"

Get your API key at you.com/platform. Set your model provider credentials (e.g. ANTHROPIC_API_KEY) separately.

3

Add Tools to Your Application

Import createYouClient(), await the MCP-backed client, then resolve tools from that client for your AI SDK call:

import { createAnthropic } from '@ai-sdk/anthropic';
import { generateText, stepCountIs } from 'ai';
import { createYouClient } from '@youdotcom-oss/ai-sdk-plugin';
const anthropic = createAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const client = await createYouClient({
apiKey: process.env.YDC_API_KEY,
});
try {
const tools = await client.tools();
const result = await generateText({
model: anthropic('claude-sonnet-4-5-20250929'),
tools,
stopWhen: stepCountIs(5), // Required for tool result processing
prompt: 'Search for the latest developments in quantum computing',
});
console.log(result.text);
} finally {
await client.close();
}

createYouClient() returns the underlying MCP client. Call await client.tools() to resolve the tool set, and await client.close() when finished. Use stopWhen: stepCountIs(n) to enable multi-step tool execution—your AI automatically selects the right tool and handles the orchestration.

4

Test Your Setup

Ask your AI something that needs real-time information:

  • “What are the latest developments in quantum computing?”
  • “Find recent articles about sustainable energy and summarize the key trends”
  • “Extract and analyze the content from https://anthropic.com”

Tool Set

The package always connects to https://api.you.com/mcp.

Default tools:

  • you-search—real-time web and news search
  • you-contents—full page content extraction in markdown or HTML
  • you-balance—remaining credit balance for the API key
  • you-discover—pointed recommendations for the right You.com integration path

Optional tools (not included by default, request explicitly with tools):

  • you-finance—finance-optimized research with citations
  • you-research—comprehensive research with configurable effort levels

Scoping Tools

tools scopes the visible tool set. profile selects a hosted server profile. If provided, profile takes precedence over tools.

Request a specific tool set:

import { createYouClient } from '@youdotcom-oss/ai-sdk-plugin';
const client = await createYouClient({
apiKey: 'your-api-key-here',
tools: ['you-search', 'you-contents'],
});
const tools = await client.tools();

Configuration type

export type YouClientConfig = {
apiKey?: string; // Defaults to YDC_API_KEY
tools?: string | string[]; // Added as ?tools=...
profile?: string; // Added as ?profile=...
};

Using Different Model Providers

This plugin works with any AI SDK compatible model provider:

import { generateText, stepCountIs } from 'ai';
// Anthropic Claude
import { createAnthropic } from '@ai-sdk/anthropic';
const anthropic = createAnthropic({
apiKey: process.env.ANTHROPIC_API_KEY,
});
const client = await createYouClient();
const tools = await client.tools();
const result = await generateText({
model: anthropic('claude-sonnet-4-5-20250929'),
tools,
stopWhen: stepCountIs(3),
prompt: 'Search for AI news',
});

OpenAI (@ai-sdk/openai) and Google Gemini (@ai-sdk/google) work the same way—create the provider with its own credentials and pass the resolved tools into generateText.

Troubleshooting

Set your API key as an environment variable, or pass it directly:

export YDC_API_KEY=your-api-key-here
# Then restart your application
const client = await createYouClient({ apiKey: 'your-api-key-here' });

Get a new key at you.com/platform/api-keys if needed.

Make sure you’re using stopWhen: stepCountIs(n) to enable multi-step tool execution. The deprecated maxSteps option executes tools but doesn’t integrate their results into the response—replace it with stopWhen.

Verify the key is set and correct:

echo $YDC_API_KEY
# If empty, set it
export YDC_API_KEY=your-api-key-here

You’ve hit the API rate limit. Wait a few minutes before retrying, or check your usage at you.com/platform/api-keys.


Resources