Skip to content
Agent frameworks

How to give AI agents and LLM tools a proxy

Give the agent's browsing and fetching tools the proxy, not the whole process: pass http://USERNAME:PASSWORD@HOST:PORT to the Playwright launch or HTTP client the tool uses, or set HTTPS_PROXY and HTTP_PROXY with a NO_PROXY list that keeps your LLM API calls direct.

What you need

Agent frameworks are layers on top of ordinary HTTP clients and browsers. Find the layer that actually touches the web (a Playwright browser, a requests-based tool, a document loader) and give it a CleanProxies IP. Everything on the other guides applies; this page maps it to agent stacks.
  • An active CleanProxies plan: static ISP proxies for fixed US IPs, or rotating residential / mobile proxies for pools. The trial works too.
  • Your credential line from the dashboard's proxy manager: host (or IP), port, username and password.
  • Your agent framework and the language it runs in (examples use Python).
  • A list of the tools that fetch web pages, so you know which ones need the proxy.

New to proxies? For the overview, read Using proxies with cURL, Python and Node.js and Rotating vs sticky sessions. This guide goes deeper on AI agents and LLM tools only.

Your CleanProxies credentials

Every CleanProxies product works over HTTP(S) and SOCKS5. This is what the dashboard gives you.
ProductLine in your dashboardNotes
Static ISP proxiesIP:PORT:USER:PASSOne line per dedicated IP. With IP whitelisting turned on, the line is just IP:PORT and no password is sent.
Rotating residential and mobileHOST:PORT:USER:PASSGenerated in the proxy manager. The username carries the location and session you pick, so generate a new list to change them.

Most tools want the same details as a URL: http://USERNAME:PASSWORD@HOST:PORT for HTTP(S) or socks5://USERNAME:PASSWORD@HOST:PORT for SOCKS5. The examples on this page use those placeholders; copy the host, port, username and password from your CleanProxies dashboard. To convert a whole list at once, paste it into the proxy list formatter.

How to set up CleanProxies in AI agents and LLM tools

  1. 1

    Find the web-facing layer

    Browser tools usually run Playwright or Chromium; fetch tools usually run requests, httpx, aiohttp or Node fetch.
  2. 2

    Configure the proxy there

    Use the library's own proxy option (see the Playwright and Requests guides), or environment variables.
  3. 3

    Keep LLM calls direct

    If you use environment variables, add the LLM provider's API host to NO_PROXY so model traffic doesn't use your proxy bandwidth.
  4. 4

    Verify from inside the agent

    Ask the agent to fetch https://api.ipify.org with its own tools and report the result.

Environment variables: which tools honour them

Setting HTTP_PROXY/HTTPS_PROXY is the quickest way to proxy tools you don't control, but not every client reads them:

Proxy web traffic, keep model API calls directshell
export HTTP_PROXY="http://USERNAME:PASSWORD@HOST:PORT"
export HTTPS_PROXY="http://USERNAME:PASSWORD@HOST:PORT"
# add your LLM provider's API host, plus local services
export NO_PROXY="localhost,127.0.0.1,api.openai.com,api.anthropic.com"
  • Python requests and HTTPX: yes, by default (HTTPX via trust_env=True).
  • aiohttp: only when the session is created with trust_env=True.
  • Node.js fetch and http: only with NODE_USE_ENV_PROXY=1 (Node 24+ and 22.21+); axios reads them.
  • Go's default transport and .NET HttpClient: yes. Java: no, it uses https.proxyHost-style system properties.
  • Chromium-based browsers launched by agents: no; set the browser's proxy option instead.

Playwright-based agents

Most browser agents launch Playwright or Chromium under the hood. Where the framework exposes launch or context options, pass Playwright's proxy object; where it accepts an existing browser or context, create it yourself with the proxy and hand it over.

Create the proxied context, then give it to your agent toolPython
from playwright.async_api import async_playwright

PROXY = {"server": "http://HOST:PORT", "username": "USERNAME", "password": "PASSWORD"}

async def make_context():
    p = await async_playwright().start()
    browser = await p.chromium.launch()
    return await browser.new_context(proxy=PROXY)  # pass this to the agent's browser tool

Chromium can't authenticate to SOCKS5 proxies, so use the HTTP form of your credentials for any browser-based agent. For browser-use specifically, see the browser-use guide.

LangChain tools and document loaders

LangChain's requests tools (TextRequestsWrapper and the RequestsGetTool family) call Python requests synchronously, so they pick up HTTP_PROXY/HTTPS_PROXY. The async path uses aiohttp, which ignores those variables; pass an aiosession created with a proxy or trust_env=True.

WebBaseLoader has a proxies argument for its requests session.

WebBaseLoader through CleanProxiesPython
from langchain_community.document_loaders import WebBaseLoader

proxy = "http://USERNAME:PASSWORD@HOST:PORT"
loader = WebBaseLoader(
    "https://example.com/pricing",
    proxies={"http": proxy, "https": proxy},
)
docs = loader.load()
Async requests tool with a proxied aiohttp sessionPython
import aiohttp
from langchain_community.utilities.requests import TextRequestsWrapper

session = aiohttp.ClientSession(trust_env=True)  # reads HTTPS_PROXY / NO_PROXY
wrapper = TextRequestsWrapper(aiosession=session)

Proxy patterns that suit agents

  • One identity per agent: a dedicated ISP IP (or sticky residential line) per agent instance, never shared between agents running in parallel.
  • Location by task: generate residential lines for the country a task needs, from 190+ countries and a 50M+ IP pool.
  • Fetch-only tools that read many public pages can use rotating residential lines; browser tools that click through flows should not.
  • Log the exit IP at the start of each run so a misconfigured tool shows up immediately.

Static ISP vs rotating residential in AI agents and LLM tools

Both products use the same setup. What changes is how long an IP stays with you.

Static ISP proxies

For agents that log in, fill forms or revisit the same sites, a static ISP IP per agent is the most reliable: dedicated, never shared, with unlimited bandwidth and threads.

Static ISP ProxiesAs low as $0.75/IP

Rotating residential proxies

For research agents that read many public pages across countries, rotating residential lines spread requests over a huge pool. Switch to sticky lines for any tool that keeps a session.

Rotating Residential ProxiesAs low as $0.63/GB

Verify your exit IP

Ask the agent to call its web tool on https://api.ipify.org and report the result, and check that your LLM requests still go direct (they should keep working with the proxy turned off).

Open What is my IP? through the proxy to see the address and headers a website receives, or paste up to ten lines into the free proxy checker to test connectivity, latency and exit IP before you start.

Troubleshooting AI agents and LLM tools proxy errors

ProblemLikely causeFix
Agent's browser shows your own IPEnvironment variables set, but Chromium ignores them.Set the proxy in the browser launch or context options.
LLM calls slow or failingHTTPS_PROXY routes model API traffic through the proxy too.Add the API host to NO_PROXY, or set proxies per tool instead of globally.
Async tool ignores the proxyaiohttp ignores env vars by default.Create the session with trust_env=True or an explicit proxy=.
407 Proxy Authentication RequiredCredentials missing in a tool that reads env vars, or special characters not encoded.URL-encode the password in HTTP_PROXY/HTTPS_PROXY.
SOCKS5 fails in browser toolsChromium supports no SOCKS5 authentication.Use http:// credentials for browsers.

Still stuck? Our 24/7 support team answers fast: contact us with the error and the line you used (leave the password out).

AI agents and LLM tools proxy FAQs

Agents that browse from a cloud server share data-center IPs that many sites challenge or block. A clean residential-grade IP, such as a CleanProxies US ISP proxy, lets the agent see pages the way a normal visitor does, with fewer CAPTCHAs and in the location the task needs.

Get CleanProxies for AI agents and LLM tools

Super clean US ISP IPs from $0.75/IP with unlimited bandwidth, rotating residential from $0.63/GB and mobile from $0.79/GB. Instant delivery, 99.9% uptime and 24/7 support.