Skip to main content

Building an AI startup?

You might be eligible for our Startup Program. Get fully funded access to the infrastructure you’re reading about right now (up to $50K value).
Vercel AI SDK is a TypeScript toolkit for building AI applications with React, Next.js, Vue, Svelte, Node.js, and more. It provides a unified API for working with different AI providers and includes utilities for streaming, function calling, and building conversational interfaces. The @brightdata/ai-sdk package gives you drop-in tools for web scraping, search, and structured dataset collection, no manual wiring required.

Steps to Get Started

1

Prerequisites

2

Installation

Install the Bright Data AI SDK package alongside the Vercel AI SDK:
Set your API key as an environment variable:
.env.local
3

Import and Use

Import the tools you need directly from @brightdata/ai-sdk and pass them to any Vercel AI SDK call. No additional setup files or wrappers needed, each tool is a factory function that reads your API key automatically from BRIGHTDATA_API_KEY.
4

Usage Examples

Create an API route that uses Bright Data tools with any AI provider:
app/api/chat/route.ts
Then use it in your component:
app/page.tsx

Available Tools

All tools are factory functions, call them with an optional config object (or no arguments at all to use env defaults):

How each tool works

scrape(options?)

Scrape any public webpage and get back clean markdown (or HTML).
LLM input schema:

search(options?)

Search the web via Google, Bing, or Yandex.
LLM input schema:

amazon_product(options?)

Retrieve structured Amazon product data.
LLM input schema:

linkedin_profile(options?)

Collect detailed LinkedIn profile data for one or more profiles.
LLM input schema:

linkedin_jobs(options?)

Search LinkedIn job postings by location and keyword.
LLM input schema:

instagram_profile(options?)

Fetch Instagram profile info and recent posts.
LLM input schema:

facebook_profile(options?)

Collect Facebook profile data.
LLM input schema:

chatgpt(options?)

Query ChatGPT via Bright Data’s ChatGPT dataset API with optional web search.
LLM input schema:

Example Output

Example: scrape a webpage

Prompt: “Scrape https://example.com and tell me what it’s about” AI Response:
Prompt: “Search for best mechanical keyboards 2025” AI Response:

Amazon Product Example

Prompt: “Get info about https://www.amazon.com/dp/B0D2Q9397Y AI Response:

Best Practices

  1. API key management, Use BRIGHTDATA_API_KEY in your environment; avoid hardcoding keys.
  2. Error handling, All tools catch errors internally and return a descriptive string, so LLM loops won’t crash.
  3. Data format, Use markdown for scraping to get clean, LLM-friendly content.
  4. Multi-step agents, Set stopWhen: stepCountIs(N) to let the model chain tool calls autonomously.
  5. Country targeting, Pass a 2-letter country code to get geo-specific results or pricing.
  6. Async datasets, For large dataset jobs (many LinkedIn profiles, etc.), consider setting async: true in the underlying SDK client to avoid timeouts.

Which environment variables to set

.env.local
Get your API key from the Bright Data Dashboard.