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
- 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
| Product | Line in your dashboard | Notes |
|---|---|---|
| Static ISP proxies | IP:PORT:USER:PASS | One line per dedicated IP. With IP whitelisting turned on, the line is just IP:PORT and no password is sent. |
| Rotating residential and mobile | HOST:PORT:USER:PASS | Generated 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
Find the web-facing layer
Browser tools usually run Playwright or Chromium; fetch tools usually run requests, httpx, aiohttp or Node fetch. - 2
Configure the proxy there
Use the library's own proxy option (see the Playwright and Requests guides), or environment variables. - 3
Keep LLM calls direct
If you use environment variables, add the LLM provider's API host toNO_PROXYso model traffic doesn't use your proxy bandwidth. - 4
Verify from inside the agent
Ask the agent to fetchhttps://api.ipify.orgwith 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:
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.
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 toolChromium 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.
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()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
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.
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.
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
| Problem | Likely cause | Fix |
|---|---|---|
| Agent's browser shows your own IP | Environment variables set, but Chromium ignores them. | Set the proxy in the browser launch or context options. |
| LLM calls slow or failing | HTTPS_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 proxy | aiohttp ignores env vars by default. | Create the session with trust_env=True or an explicit proxy=. |
| 407 Proxy Authentication Required | Credentials 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 tools | Chromium 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.