Documentation Index
Fetch the complete documentation index at: https://docs.brightdata.com/llms.txt
Use this file to discover all available pages before exploring further.
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 $20K value).
How to Integrate Bright Data With Mastra
Prerequisites
- Node.js
- npm (latest version)
- Bright Data API key
- OpenAI API key (for GPT-4o-mini)
- Bright Data zones will be auto-created if needed
Obtain Your Bright Data API Key
- Log in to your Bright Data dashboard.
- Go to Account Settings.
- Generate an API key if you haven’t already done so.
- Enable SDK access for your API key
Obtain Your OpenAI API Key
- Go to OpenAI Platform
- Navigate to the API keys section
- Create a new API key
- Ensure you have access to the GPT-4o-mini model
Create a New Mastra Project Using the Template
Create a new project using the Bright Data Mastra template:
Alternatively, you can clone the repository directly:
Start the Development Server
Run the Mastra development server with hot reloading:Your Bright Data-powered web agent is now ready to use!
Example Usage
The web agent comes pre-configured with four powerful tools. Here’s how the agent works:Example queries you can ask the agent:
- “Search for the latest developments in quantum computing”
- “Scrape the pricing information from example.com”
- “Get details and reviews for this Amazon product: [URL]”
- “Collect LinkedIn profiles for executives at [company name]”
Available Tools
The integration provides four powerful tools:1. Search Tool
- Search across Google, Bing, or Yandex
- Returns results in markdown or HTML format
- Automatic anti-bot protection bypass
- Supports localized results with country codes
- Extract website content in clean markdown format
- Automatic CAPTCHA and bot detection bypass
- Country-specific proxy support
- Get pricing, ratings, reviews, and specifications
- Location-specific data with ZIP code support
- Comprehensive product information
- Fetch professional background, experience, and education
- Batch processing for multiple profiles
- Detailed skills and work history
How the project is structured
Key Features
- AI-Powered Intelligence: Uses OpenAI GPT-4o-mini for intelligent reasoning
- Bright Data SDK Integration: Direct integration with Bright Data’s web data tools
- Multiple Data Sources: Search engines, web scraping, Amazon, LinkedIn
- Anti-Bot Protection: Automatic CAPTCHA and bot detection bypass
- Persistent Memory: Maintains conversation history using LibSQL
- TypeScript Support: Fully typed for better development experience
How to deploy to production
Build and start your production server:Troubleshooting
“Bright Data API key is required to initialize tools”- Ensure
.envfile exists with a validBRIGHTDATA_API_KEY - Verify the API key has SDK access permissions
- Check that the API key is not expired
- Verify
OPENAI_API_KEYin.env - Ensure the API key has access to GPT-4o-mini model
- Check your OpenAI account has available credits
- The integration uses
autoCreateZones: trueto automatically create zones - Check that the zones were created in your Bright Data account