Integrating Bright Data with LangChain enhances LLM-powered agents with reliable, anonymous, and scalable web access for real-world applications.
You can do it either by using the langchain-brightdata Python package is the official LangChain integration for Bright Data, including support for:

  • BrightDataSERP - Bright Data provides a powerful SERP API that allows you to query search engines (Google,Bing, DuckDuckGo,Yandex) with geo-targeting and advanced customization options, particularly useful for AI agents requiring real-time web information.
  • BrightDataUnlocker - Bright Data provides a powerful Web Unlocker API that allows you to access websites that might be protected by anti-bot measures, geo-restrictions, or other access limitations, making it particularly useful for AI agents requiring reliable web content extraction.
  • BrightDataWebScraperAPI - Bright Data provides a powerful Web Scraper API that allows you to extract structured data from 100+ ppular domains, including Amazon product details, LinkedIn profiles, and more, making it particularly useful for AI agents requiring reliable structured web data feeds.

Or by Bright Data’s MCP (Model Context Protocol) - a local server that exposes a wide range of scraping and automation tools. While not part of the langchain-brightdata package, it can be integrated manually using LangChain’s Tool or RequestsWrapper.

How to Integrate Bright Data With LangChain

0

Obtain Your Bright Data API Key

2

Install the Bright Data Integration

Install the Bright Data integration package for LangChain by running the following command:

pip install langchain-brightdata
3

Set the environment variable

Set your Bright Data API key as an environment variable:

import os
os.environ["BRIGHT_DATA_API_KEY"] = "your-api-key"

Or pass it directly when initializing tools:

from langchain_bright_data import BrightDataSERP

tool = BrightDataSERP(bright_data_api_key="your-api-key")
4

Select your preferred Bright Data tool

The Bright Data + LangChain integration currently supports:

API reference: SERP API Documentation

Collect search engine results with geo-targeting

from langchain_brightdata import BrightDataSERP

# Initialize the tool
serp_tool = BrightDataSERP(
    bright_data_api_key="your-api-key"  # Optional if set in environment variables
)

# Run a basic search
results = serp_tool.invoke("latest AI research papers")

print(results)