Thanks to visit codestin.com
Credit goes to docs.brightdata.com

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).
Strands Agents is an open-source Python library that provides a unified toolkit for developing autonomous AI agents. It bridges the gap between large language models and practical applications by offering ready-to-use tools for file operations, system execution, API interactions, mathematical operations, and more.

Steps to Get Started

1

Prerequisites

  • Bright Data API Key
  • Python 3.10+
2

Installation

Set up the strands-agents-tools package by either using the quick pip install or the full development installation with virtual environment and pre-commit hooks.
Quick Install
pip install strands-agents-tools
3

Set the environment variable

Set your Bright Data API key and unlocker zone as an environment variables:
export BRIGHT_DATA_API_KEY="your_api_key_here"
export BRIGHT_DATA_ZONE="your_unlocker_zone_here"
4

Bright Data Usage Examples

from strands import Agent
from strands.models.litellm import LiteLLMModel
import strands_tools.bright_data as bright_data
import os
from dotenv import load_dotenv


load_dotenv()


def main():
load_dotenv()
print("🔍 Testing Bright Data Tool with OpenAI GPT-4o via LiteLLM")
print("=" * 50)

# Configure OpenAI model via LiteLLM
openai_model = LiteLLMModel(
    client_args={
        "api_key": os.getenv("OPENAI_API_KEY"), 
    },
    model_id="openai/gpt-4o",
)

# Create agent with LiteLLM model and bright_data tool
agent = Agent(
    model=openai_model,
    tools=[bright_data],
    system_prompt="you are a helpful Web Search assistant, whenever user asks you to search the web you will use avilable tools, always set zone name to 'unlocker'"
)

# Test the bright_data tool with a relevant query
print("Testing web scraping...")
result = agent("Please scrape the content from https://example.com and return it as markdown")
print(f'\n\nScraping Result:\n{result}')

print("\n" + "=" * 50)
print("Testing web search...")
result2 = agent("Please search Google for 'Python programming tutorials")
print(f'\n\nSearch Result:\n{result2}')


if __name__ == "__main__":
main()