AI browser automation library that lets LLMs control web browsers. Route Browser Use sessions through KnoxProxy to give AI agents anonymous, geo-targeted browsing capabilities for research, data extraction, and web interaction tasks.
Install the browser-use library and Playwright dependencies.
pip install browser-use
playwright install chromiumConfigure your LLM API key (OpenAI, Anthropic, etc.) for the AI agent.
export OPENAI_API_KEY="sk-..."Pass KnoxProxy settings to the Browser constructor via Playwright proxy config.
Initialize a Browser Use Agent with the proxied browser and a task description.
Modify the proxy username for country-specific browsing sessions.
proxy_username = "USER-country-jp"Execute the agent task and monitor browser actions in the Playwright trace viewer.
import asyncio
from browser_use import Agent, Browser, BrowserConfig
from langchain_openai import ChatOpenAI
PROXY_USER = "USER"
PROXY_PASS = "PASS"
PROXY_HOST = "gw.knoxproxy.com"
PROXY_PORT = 7000
async def main():
# Configure browser with KnoxProxy
browser = Browser(
config=BrowserConfig(
headless=True,
proxy={
"server": f"http://{PROXY_HOST}:{PROXY_PORT}",
"username": PROXY_USER,
"password": PROXY_PASS,
},
),
)
# For geo-targeted browsing (e.g., browse as if from Germany):
# browser = Browser(
# config=BrowserConfig(
# headless=True,
# proxy={
# "server": f"http://{PROXY_HOST}:{PROXY_PORT}",
# "username": f"{PROXY_USER}-country-de",
# "password": PROXY_PASS,
# },
# ),
# )
# Create AI agent with proxied browser
agent = Agent(
task="Go to httpbin.org/ip and tell me the IP address shown.",
llm=ChatOpenAI(model="gpt-4o"),
browser=browser,
)
result = await agent.run()
print(f"Agent result: {result}")
await browser.close()
if __name__ == "__main__":
asyncio.run(main())Each new Browser instance gets a fresh IP. For sticky sessions across page navigations within one agent run, use USER-session-{task_id} as the proxy username. The same IP persists for the entire browser context lifetime.
| Problem | Fix |
|---|---|
| playwright._impl._errors.Error: net::ERR_PROXY_CONNECTION_FAILED | Verify the proxy server format is "http://host:port" (without credentials). Username and password go in separate fields. |
| Agent stuck on CAPTCHA page | Use residential proxies by adding -type-residential to the username. Set headless=False to debug visually. |
| TimeoutError: page.goto timed out after 30000ms | Increase BrowserConfig timeout. Try a different country proxy or residential proxy type. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
The AI agent sees the real target page rendered by the actual browser Playwright controls, not a modified proxy page. KnoxProxy acts as a transparent forward proxy that only changes the exit IP address of each request and does not alter, inject into, or rewrite any page content the agent reads.
Yes, replace ChatOpenAI with ChatAnthropic imported from langchain_anthropic when you build the Agent, keeping the same task string and proxied Browser instance unchanged. The proxy configuration lives on the Browser object and is completely independent of which LLM provider drives the agent reasoning.
Use a sticky session with USER-session-{task_id} as the proxy username so the same IP persists across the run, then pass a persistent browser context by setting user_data_dir in BrowserConfig. Together, the stable IP and saved browser profile let cookies and login state carry over between separate agent runs.
KnoxProxy only handles IP address rotation and country-level geo-targeting, not the browser fingerprint that sites read to detect automation. For real fingerprint protection, combine KnoxProxy with stealth plugins or the BrowserConfig stealth options in browser-use, which mask signals like headless mode that trigger CAPTCHA challenges on protected sites.
Rotating residential proxies -- 5 minutes setup, instant activation, 14-day money-back guarantee.