Proxies.ai

AI Agents

Route OpenAI, Anthropic, and LangChain calls through Hyperproxy.

AI agents make many HTTP calls to model providers and third-party APIs. Hyperproxy is designed for exactly this use case — agents get proxy credentials, Hyperproxy holds the real API keys.

OpenAI Python SDK

The OpenAI client accepts a custom http_client. Pass an httpxclient configured with your Hyperproxy endpoint:

python
Sign in with active access to insert your proxy host. This command remains a template.
import httpx
from openai import OpenAI

proxy_url = "https://user:pass@<proxy-host>:443"

client = OpenAI(
    api_key="{$OPENAI_API_KEY}",   # Hyperproxy will replace this placeholder
    http_client=httpx.Client(proxies={"https://": proxy_url}),
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
)

Anthropic Python SDK

python
Sign in with active access to insert your proxy host. This command remains a template.
import httpx
import anthropic

proxy_url = "https://user:pass@<proxy-host>:443"

client = anthropic.Anthropic(
    api_key="{$ANTHROPIC_API_KEY}",
    http_client=httpx.Client(proxies={"https://": proxy_url}),
)

message = client.messages.create(
    model="claude-opus-4-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}],
)

LangChain

python
Sign in with active access to insert your proxy host. This command remains a template.
import os, httpx
from langchain_openai import ChatOpenAI

os.environ["HTTPS_PROXY"] = "https://user:pass@<proxy-host>:443"

# LangChain uses requests/httpx under the hood; HTTPS_PROXY is automatically picked up
llm = ChatOpenAI(
    model="gpt-4o",
    openai_api_key="{$OPENAI_API_KEY}",
)

result = llm.invoke("What's 2+2?")

OpenAI Node.js SDK

typescript
Sign in with active access to insert your proxy host. This command remains a template.
import OpenAI from 'openai'
import { HttpsProxyAgent } from 'https-proxy-agent'

const proxyUrl = 'https://user:pass@<proxy-host>:443'
const agent = new HttpsProxyAgent(proxyUrl)

const openai = new OpenAI({
  apiKey: '{$OPENAI_API_KEY}',    // Hyperproxy resolves this
  httpAgent: agent,
})

const completion = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
})

Recommended Pattern for Agents

Keep your Hyperproxy endpoint URL in your agent's environment. The agent never sees real API keys.

bash
Sign in with active access to insert your proxy host. This command remains a template.
# Agent environment — no real API keys!
HTTPS_PROXY="https://proxy-abc123-u1a2b3:password@<proxy-host>:443"
NO_PROXY=localhost,127.0.0.1
python
# All HTTP calls automatically route through Hyperproxy
# Use {$VAR} placeholders anywhere you'd normally put a key
import requests
r = requests.post(
    "https://api.openai.com/v1/embeddings",
    headers={"Authorization": "Bearer {$OPENAI_API_KEY}"},
    json={"input": "hello", "model": "text-embedding-3-small"},
)

Firewall Mode for Untrusted Agents

For fully autonomous agents (or agents running user-supplied code), use firewall mode with restrictive CEL rules. For example, to allow only OpenAI and GitHub:

bash
# Rule 1: Allow OpenAI API (priority 10)
request.host == "api.openai.com"

# Rule 2: Allow GitHub API (priority 20)  
request.host == "api.github.com"

# Rule 3: Deny everything else (priority 9999)
true  → action: deny

Any attempt to exfiltrate data to an unexpected host is blocked at the proxy layer — regardless of what code the agent runs.