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).
@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
- Bright Data API Key, get yours from the Bright Data Dashboard
- Node.js 18+
- TypeScript (recommended)
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
- Next.js App Router
- Node.js Script
- Custom API Key
Create an API route that uses Bright Data tools with any AI provider:Then use it in your component:
app/api/chat/route.ts
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).
search(options?)
Search the web via Google, Bing, or Yandex.
amazon_product(options?)
Retrieve structured Amazon product data.
linkedin_profile(options?)
Collect detailed LinkedIn profile data for one or more profiles.
linkedin_jobs(options?)
Search LinkedIn job postings by location and keyword.
instagram_profile(options?)
Fetch Instagram profile info and recent posts.
facebook_profile(options?)
Collect Facebook profile data.
chatgpt(options?)
Query ChatGPT via Bright Data’s ChatGPT dataset API with optional web search.
Example Output
Example: scrape a webpage
Prompt: “Scrape https://example.com and tell me what it’s about” AI Response:Example: run a Google search
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
- API key management, Use
BRIGHTDATA_API_KEYin your environment; avoid hardcoding keys. - Error handling, All tools catch errors internally and return a descriptive string, so LLM loops won’t crash.
- Data format, Use
markdownfor scraping to get clean, LLM-friendly content. - Multi-step agents, Set
stopWhen: stepCountIs(N)to let the model chain tool calls autonomously. - Country targeting, Pass a 2-letter country code to get geo-specific results or pricing.
- Async datasets, For large dataset jobs (many LinkedIn profiles, etc.), consider setting
async: truein the underlying SDK client to avoid timeouts.
Which environment variables to set
.env.local