Skip to main content

Overview

Linkup can be used with the Vercel AI SDK as a tool for web search. This integration allows you to build AI applications that can access real-time information from the internet using any model supported by the AI SDK.

GitHub Repository

Getting Started with Linkup in Vercel AI SDK

1

Install the Linkup AI SDK

npm install linkup-ai-sdk ai @ai-sdk/openai
We have chosen OpenAI as the default model provider, but you can use any provider supported by the Vercel AI SDK (like @ai-sdk/anthropic, @ai-sdk/mistral, etc.)
3

Set up your environment variables

Create a .env file in your project root:
LINKUP_API_KEY=your_linkup_api_key_here
OPENAI_API_KEY=your_openai_api_key_here
4

Create and use the Linkup web search tool

import { openai } from '@ai-sdk/openai';
import { generateText, stepCountIs } from 'ai';
import { webSearch } from 'linkup-ai-sdk';

const { text } = await generateText({
  model: openai('gpt-4o-mini'),
  prompt: 'What was Microsoft's revenue last quarter and was it well perceived by the market?',
  tools: {
    webSearch: webSearch({ depth: 'standard' }),
  },
  stopWhen: stepCountIs(3),
});

console.log(text);

Configuration Options

The webSearch tool accepts the following configuration options:
ParameterTypeDefaultDescription
apiKeystringprocess.env.LINKUP_API_KEYYour Linkup API key. If not provided, it will be read from the environment variable.
depth’standard’ | ‘deep''standard’Search depth. deep performs more thorough research, standard is faster.
includeImagesbooleanfalseWhether to include images in the search results.
includeDomainsstring[][]Array of domains to include in the search results.
excludeDomainsstring[][]Array of domains to exclude from the search results.
fromDateDatenullStart date for filtering search results.
toDateDatenullEnd date for filtering search results.
For more details on search capabilities, see our Search Concepts documentation.

Resources

Facing issues? Reach out to our engineering team at support@linkup.so or via our Discord or book a 15 minutes call with a member of our technical team.