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 agent sees the real target page. KnoxProxy is a transparent forward proxy and does not modify page content.
Yes. Replace ChatOpenAI with ChatAnthropic from langchain_anthropic. The proxy config is independent of the LLM provider.
Use a sticky session (USER-session-{id}) to keep the same IP, and pass a persistent browser context with user_data_dir.
KnoxProxy handles IP rotation. For fingerprint protection, combine with stealth plugins or use the BrowserConfig stealth options.
Free trial on rotating residential -- 5 minutes setup, no credit card.