> ## Documentation Index
> Fetch the complete documentation index at: https://docs.linkup.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

> How to use Linkup with the Vercel AI SDK

## Overview

Linkup can be used with the [Vercel AI SDK](https://sdk.vercel.ai/) 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.

> [card] [GitHub Repository](https://github.com/LinkupPlatform/linkup-ai-sdk)

## Getting Started with Linkup in Vercel AI SDK

**1. Install the Linkup AI SDK**

```bash theme={"system"}
npm install linkup-ai-sdk ai @ai-sdk/openai
```

> [!NOTE]
>
> 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.)

**2. Get your Linkup API Key**

> [card] [Get your API key](https://app.linkup.so)
>
> Create a Linkup account for free to get your API key.

**3. Set up your environment variables**

Create a `.env` file in your project root:

```bash theme={"system"}
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**

```typescript theme={"system"}
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:

<table>
  <thead>
    <tr>
      <th>Parameter</th>
      <th>Type</th>
      <th>Default</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>`apiKey`</td>
      <td>`string`</td>
      <td>`process.env.LINKUP_API_KEY`</td>
      <td>Your Linkup API key. If not provided, it will be read from the environment variable.</td>
    </tr>

    <tr>
      <td>`depth`</td>
      <td>`'flash' | 'fast' | 'standard' | 'deep'`</td>
      <td>`'standard'`</td>
      <td>Search depth. `"flash"` is currently in alpha and offers the lowest latency (under 200 ms, no LLM), `"fast"` is higher-quality one-shot retrieval (\~1s, no LLM), `"standard"` leverages agentic search, `"deep"` performs more thorough research.</td>
    </tr>

    <tr>
      <td>`includeImages`</td>
      <td>`boolean`</td>
      <td>`false`</td>
      <td>Whether to include images in the search results.</td>
    </tr>

    <tr>
      <td>`includeDomains`</td>
      <td>`string[]`</td>
      <td>`[]`</td>
      <td>Array of domains to include in the search results.</td>
    </tr>

    <tr>
      <td>`excludeDomains`</td>
      <td>`string[]`</td>
      <td>`[]`</td>
      <td>Array of domains to exclude from the search results.</td>
    </tr>

    <tr>
      <td>`fromDate`</td>
      <td>`Date`</td>
      <td>`null`</td>
      <td>Start date for filtering search results.</td>
    </tr>

    <tr>
      <td>`toDate`</td>
      <td>`Date`</td>
      <td>`null`</td>
      <td>End date for filtering search results.</td>
    </tr>
  </tbody>
</table>

For more details on search capabilities, see our [Search Concepts documentation](https://docs.linkup.so/pages/documentation/endpoints/search/overview.md).

## Resources

* [Linkup AI SDK on npm](https://www.npmjs.com/package/linkup-ai-sdk)
* [Linkup AI SDK on GitHub](https://github.com/LinkupPlatform/linkup-ai-sdk)
* [Vercel AI SDK Documentation](https://sdk.vercel.ai/)
* [Search Concepts](https://docs.linkup.so/pages/documentation/endpoints/search/overview.md)

> [!NOTE]
>
> **Need help?** Email `support@linkup.so`, ping us on [Discord](https://discord.com/invite/9q9mCYJa86), or [talk to us](https://calendar.app.google/zNUZz7RxgMMk9pKW7).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.