A FastAPI service that searches for vendor red flags with the Bright Data SERP API, reads pages through Web Unlocker, scores risk with OpenAI, and generates monitoring scripts with the OpenHands SDK.
Bright Data docs · Bright Data · More examples · studio1hq.com
An agent for third-party risk management. Give it a vendor name and it searches for adverse media, reads the pages it finds, scores the risk, and can generate monitoring scripts that keep checking the vendor's sources.
It uses three Bright Data products: the SERP API to search Google for red flags, Web Unlocker to read pages behind paywalls and CAPTCHAs, and an optional Browser API for JavaScript-heavy sites. OpenAI scores the risk, and the OpenHands SDK writes the monitoring scripts. A FastAPI service exposes it over REST.
- Adverse media search: Litigation, fraud, financial, regulatory and operational risk categories.
- SERP API discovery: Searches Google for red flags per category.
- Web Unlocker access: Extracts content from protected pages.
- AI risk analysis: OpenAI returns severity (low, medium, high, critical), findings and recommended actions.
- Generated monitors: OpenHands SDK writes Python scripts into
scripts/generated/. - REST API: FastAPI endpoints with interactive docs.
- Browser API (optional): Form filling and extraction for complex sites.
| Layer | Tool |
|---|---|
| Search | Bright Data SERP API |
| Page access | Bright Data Web Unlocker |
| Browser (optional) | Bright Data Browser API with Playwright |
| Risk analysis | OpenAI |
| Script generation | OpenHands SDK |
| API | FastAPI |
| Deployment | Railway (Procfile) |
- Python 3.12 or higher
- A Bright Data account with API access
- An OpenAI API key
- An OpenHands Cloud account or your own LLM API key
git clone https://github.com/Studio1HQ/tprm-agent.git
cd tprm-agent
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txtCreate a .env file in the project root.
| Variable | Description |
|---|---|
BRIGHT_DATA_API_TOKEN |
Bright Data API token. |
BRIGHT_DATA_SERP_ZONE |
SERP API zone name. |
BRIGHT_DATA_UNLOCKER_ZONE |
Web Unlocker zone name. |
BRIGHT_DATA_CUSTOMER_ID |
Customer ID for Web Unlocker (in config.py). |
BRIGHT_DATA_UNLOCKER_PASSWORD |
Web Unlocker zone password (in config.py). |
BRIGHT_DATA_BROWSER_USER |
Optional. Browser API username. |
BRIGHT_DATA_BROWSER_PASSWORD |
Optional. Browser API password. |
OPENAI_API_KEY |
OpenAI key for risk analysis. |
LLM_API_KEY |
API key for OpenHands script generation. |
LLM_MODEL |
Model for OpenHands, for example openai/gpt-4o. |
Zones are created in the Bright Data dashboard under Proxies and Scraping Infrastructure: add a SERP API zone, a Web Unlocker zone and, optionally, a Scraping Browser.
Start the API:
python -m uvicorn api.main:app --reloadOpen http://localhost:8000/docs for interactive API docs. To run one investigation directly:
python src/agent.pyDISCOVERY (SERP API) -> ACCESS (Web Unlocker) -> ACTION (OpenAI + OpenHands SDK)
search Google bypass paywalls analyze risks
for red flags and CAPTCHAs generate scripts
tprm-agent/
├── src/
│ ├── config.py # settings
│ ├── discovery.py # SERP API
│ ├── access.py # Web Unlocker
│ ├── actions.py # OpenAI + OpenHands SDK
│ ├── agent.py # orchestration
│ └── browser.py # Browser API (optional)
├── api/main.py # FastAPI endpoints
├── scripts/generated/ # generated monitors
├── run_investigation.py
└── Procfile
Risk categories live in RISK_CATEGORIES in src/discovery.py; add your own keywords there.
Start an investigation:
curl -X POST "http://localhost:8000/investigate" \
-H "Content-Type: application/json" \
-d '{"vendor_name": "Acme Corp", "categories": ["litigation", "fraud"], "generate_monitors": true}'Other endpoints: GET /investigate/{investigation_id} for results, GET /reports/{vendor_name}, and GET /health.
Request fields: vendor_name (required), categories (optional), generate_monitors (optional, default true). A result includes total_sources_found, total_sources_accessed, risk_assessments (category, severity, summary, key findings, sources, recommended actions), monitoring_scripts and errors.
Python use:
from src.agent import TPRMAgent
agent = TPRMAgent()
result = agent.investigate(
vendor_name="Acme Corp",
categories=["litigation", "financial", "fraud"],
generate_monitors=True,
)Run or schedule a generated monitor:
cd scripts/generated
python monitor_acme_corp.py
# cron: 0 9 * * * cd /path/to/tprm-agent/scripts/generated && python3 monitor_acme_corp.pynpm i -g @railway/cli
railway login
railway init
railway upAdd the environment variables in the Railway dashboard under Variables, then generate a domain. The Procfile runs uvicorn api.main:app --host 0.0.0.0 --port $PORT.
- Bright Data auth errors: Check the token and zone names, zone status and available bandwidth.
- OpenAI rate limits: Add retries or reduce concurrency.
- Generated scripts skip Bright Data: Check the Web Unlocker instructions in the prompt in
actions.py. - Deployment failures: Check dependency size and the
Procfile.
Security: do not commit .env, use platform variables in production, rotate keys, and add authentication to the API before exposing it.
- Bright Data SERP API docs: Search zone setup.
- Bright Data Web Unlocker docs: Unlocker zone setup.
- Bright Data Browser API docs: Scraping Browser.
- OpenHands SDK docs: Agent SDK.
- Bright Data: Account and API token.
Built by Studio1, the technical content and DevRel partner for devtool teams. Made with Bright Data.
Browse more open-source examples at github.com/Studio1HQ.
studio1hq.com · Technical content, docs, video and DevRel for devtools