﻿<head><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4357510538660394"
     crossorigin="anonymous"></script></head>> ## 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.

# Set up Bright Data with Smolagents

> Connect Smolagents to Bright Data (thousands of pre-built scrapers) so your agent can crawl sites, run web searches and access data from LinkedIn and Amazon.

> [card] [Building an AI startup?](https://brightdata.com/ai/ai-startups-program)
>
> 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).

## Why Use Bright Data With Smolagents?

The Bright Data tools for Smolagents provide the following capabilities:

> [accordion] Web Search
>
> * **`search_tool`**\
>   Search Google and get structured search results. This tool can search the web and return relevant results for your queries.
>
> ```python theme={null}
> from smolagents import Tool
>
> web_search = Tool.from_space(
>     "BrightData/brightdata-search-tool",
>     name="search_tool",
>     description="search the web"
> )
> ```

> [accordion] Extract
>
> * **`extract_tool`**\
>   Scrape webpages and extract content as Markdown format. This tool can bypass CAPTCHA and bot detection to reliably extract data from any website.
>
> ```python theme={null}
> from smolagents import Tool
>
> extract = Tool.from_space(
>     "BrightData/brightdata-scraper-tool",
>     name="extract_tool",
>     description="extract data from the web as markdown without getting blocked"
> )
> ```

> [accordion] Structured Data Feeds
>
> * **`data_feeds_tool`**\
>   Retrieve structured data from various platforms including LinkedIn, Amazon, Instagram, Facebook, X (Twitter), Zillow, and more.
>
> ```python theme={null}
> from smolagents import Tool
>
> data_feeds = Tool.from_space(
>     "BrightData/brightdata-dataset-tool",
>     name="data_feeds_tool",
>     description="extract structured data from the web"
> )
> ```
>
> Supported platforms include:
>
> * LinkedIn (profiles and companies)
> * Amazon (products and reviews)
> * Instagram (profiles, posts, reels, comments)
> * Facebook (posts, marketplace listings, company reviews)
> * X/Twitter (posts)
> * Zillow (property listings)
> * Booking.com (hotel listings)
> * YouTube (videos)
> * And many more
>
> For more information, visit the [Bright Data documentation](https://docs.brightdata.com/).

## How to Integrate Bright Data With Smolagents?

**1. Obtain Your Bright Data API Key**

* Log in to your [Bright Data dashboard](https://brightdata.com/cp).
* Go to [Account Settings](https://brightdata.com/cp/setting/users).
* [Generate an API key](https://docs.brightdata.com/api-reference/authentication.md#how-do-i-authenticate-with-api-key%3F) if you haven't already done so.

**2. Installation**

Install the required packages. **Important:** As of December 9, 2025, these specific versions are mandatory to align with Smolagents:

```bash theme={null}
pip install smolagents
pip install --upgrade --force-reinstall "gradio_client<2.0.0" "gradio<6.0.0"
```

**3. Configure API Key**

Set your Bright Data API key as an environment variable:

```bash theme={null}
export BRIGHTDATA_API_KEY="your-api-key"
```

Or set it in your Python code:

```python theme={null}
import os
os.environ["BRIGHTDATA_API_KEY"] = "your-api-key"
```

**4. Obtain Your Hugging Face API Token**

When using `InferenceClientModel`, you need a Hugging Face token for authentication:

* Visit [Hugging Face Settings - Tokens](https://hf.co/settings/tokens)
* Create a new token with "Make calls to the serverless Inference API" permission
* Set it as an environment variable:

```bash theme={null}
    export HF_TOKEN="your-hf-token"
```

Or pass it directly when initializing the model:

```python theme={null}
    model = InferenceClientModel(
        model_id="Qwen/Qwen3-Next-80B-A3B-Thinking",
        token="your-hf-token"
    )
```

**Note:** Free Hugging Face accounts include inference credits. Upgrade to PRO for higher rate limits.

**5. Usage**

Here's a complete example of how to use Bright Data tools with Smolagents:

```python theme={null}
from smolagents import CodeAgent, InferenceClientModel, Tool

# Load Bright Data tools from Hugging Face Spaces
web_search = Tool.from_space(
    "BrightData/brightdata-search-tool",
    name="search_tool",
    description="search the web"
)

extract = Tool.from_space(
    "BrightData/brightdata-scraper-tool",
    name="extract_tool",
    description="extract data from the web as markdown without getting blocked"
)

data_feeds = Tool.from_space(
    "BrightData/brightdata-dataset-tool",
    name="data_feeds_tool",
    description="extract structured data from the web"
)

# Initialize the model
model = InferenceClientModel(model_id="Qwen/Qwen3-Next-80B-A3B-Thinking")

# Create the agent with Bright Data tools
agent = CodeAgent(tools=[web_search, extract, data_feeds], model=model)

# Run the agent
response = agent.run(
    "Improve this prompt, then search the web for it.",
    additional_args={'user_prompt': 'who is elon musk'}
)

print(response)
```

## Example Use Cases

> [accordion] Web Research
>
> Use the search tool to find information across the web:
>
> ```python theme={null}
> agent.run("Search for the latest developments in quantum computing")
> ```

> [accordion] Data Extraction
>
> Scrape and extract content from websites:
>
> ```python theme={null}
> agent.run("Extract the main content from https://example.com/article")
> ```

> [accordion] Competitor Analysis
>
> Extract structured data from e-commerce platforms:
>
> ```python theme={null}
> agent.run("Get product details and reviews for the top-rated laptops on Amazon")
> ```

> [accordion] Social Media Intelligence
>
> Retrieve data from social media platforms:
>
> ```python theme={null}
> agent.run("Get the latest posts and engagement metrics from a LinkedIn company page")
> ```

## Tips for Best Results

* **Be specific** with your prompts to help the agent understand exactly what data you need
* **Combine tools** for complex tasks - the agent can use search, extract, and data feeds together

For more advanced configurations and detailed API documentation, visit [Bright Data's documentation](https://docs.brightdata.com/).
