Why Do AI Tools Need Proxy?
In 2026, mainstream AI platforms have varying levels of restrictions on mainland China IPs:
- ChatGPT (OpenAI) — Completely blocks mainland China IPs, both registration and usage require proxy
- Claude (Anthropic) — Only available in some regions, China IPs cannot access
- Gemini (Google) — Some features have regional restrictions
- GitHub Copilot — Usually doesn't restrict IPs, but some enterprise versions have regional limits
- Cursor — Calls Claude/GPT backends, some features may need proxy
- OpenAI API — Also blocks China IPs, developers must call through proxy
OpenAI not only blocks China IPs but also datacenter IPs. Many regular VPNs and proxy nodes use datacenter IPs, which are easily flagged by OpenAI's risk control system when shared by many users, leading to account bans. ClashX's routing feature lets you assign dedicated high-quality nodes for AI tools.
ChatGPT Proxy Pitfalls Guide
OpenAI's risk control mechanism detects several dimensions:
High-Risk Behaviors (Likely to Get Banned)
- Using datacenter IPs (most VPN/proxy nodes are)
- Frequently switching IPs from different regions (US today, Japan tomorrow)
- Same IP shared by many ChatGPT users
- Using IPs marked as proxies
Low-Risk Strategies (Recommended)
- Use Residential IPs — Residential IPs are recognized as regular home users, lowest risk
- Fixed Region — Always use nodes from the same region (e.g., US West Coast)
- Dedicated Nodes — Avoid sharing the same IP with many users
- ClashX Dedicated Node Group — Create separate node group for AI tools, separate from daily browsing
ClashX AI Routing Rules Configuration
First download ClashX, then edit the configuration file. The following rules direct all AI platform traffic to dedicated node groups.
Create AI-Dedicated Node Group
proxy-groups:
- name: "🤖 AI Tools"
type: url-test
url: http://www.gstatic.com/generate_204
interval: 300
tolerance: 100
proxies:
- 🇺🇸 US-Residential-IP
- 🇯🇵 Japan-Residential-IP
- 🇺🇸 US-Dedicated-Node
- name: "🤖 AI Manual"
type: select
proxies:
- 🤖 AI Tools
- 🇺🇸 US-Residential-IP
- 🇯🇵 Japan-Residential-IP
- DIRECTAI Platform Routing Rules
rules:
# ===== OpenAI / ChatGPT =====
- DOMAIN-SUFFIX,openai.com,🤖 AI Tools
- DOMAIN-SUFFIX,ai.com,🤖 AI Tools
- DOMAIN-SUFFIX,chatgpt.com,🤖 AI Tools
- DOMAIN-SUFFIX,oaistatic.com,🤖 AI Tools
- DOMAIN-SUFFIX,oaiusercontent.com,🤖 AI Tools
- DOMAIN-KEYWORD,openai,🤖 AI Tools
# ===== Anthropic / Claude =====
- DOMAIN-SUFFIX,anthropic.com,🤖 AI Tools
- DOMAIN-SUFFIX,claude.ai,🤖 AI Tools
# ===== Google AI / Gemini =====
- DOMAIN-SUFFIX,gemini.google.com,🤖 AI Tools
- DOMAIN-SUFFIX,aistudio.google.com,🤖 AI Tools
- DOMAIN-SUFFIX,generativelanguage.googleapis.com,🤖 AI Tools
# ===== GitHub Copilot =====
- DOMAIN-SUFFIX,copilot.github.com,🤖 AI Tools
- DOMAIN-SUFFIX,githubcopilot.com,🤖 AI Tools
# ===== Cursor =====
- DOMAIN-SUFFIX,cursor.sh,🤖 AI Tools
- DOMAIN-SUFFIX,cursor.com,🤖 AI Tools
# ===== Perplexity =====
- DOMAIN-SUFFIX,perplexity.ai,🤖 AI Tools
# ===== Midjourney =====
- DOMAIN-SUFFIX,midjourney.com,🤖 AI Tools
# ===== Other Traffic =====
- MATCH,DIRECTAPI Call Proxy Configuration
If you're a developer needing to call OpenAI or Anthropic APIs through proxy. After enabling system proxy in ClashX, set environment variables in terminal:
# ClashX default listening port
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7891Python Example
import openai
import httpx
client = openai.OpenAI(
api_key="sk-your-key",
http_client=httpx.Client(
proxy="http://127.0.0.1:7890"
)
)
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)Node.js Example
import Anthropic from '@anthropic-ai/sdk';
import { HttpsProxyAgent } from 'https-proxy-agent';
const client = new Anthropic({
apiKey: 'sk-ant-your-key',
httpAgent: new HttpsProxyAgent('http://127.0.0.1:7890')
});If you don't want to set environment variables every time, you can enable ClashX's TUN mode. TUN mode works at the system network layer, all application traffic automatically goes through proxy without additional configuration.
Multi-Platform All-in-One YAML Template
Below is a complete configuration template integrating all AI platforms, ready to use directly. For detailed syntax, see config.yaml Complete Guide.
proxy-groups:
- name: "🤖 AI Tools"
type: url-test
url: http://www.gstatic.com/generate_204
interval: 300
tolerance: 100
proxies:
- 🇺🇸 US-Residential-1
- 🇺🇸 US-Residential-2
- 🇯🇵 JP-Residential
rule-providers:
ai-tools:
type: http
behavior: classical
url: "https://raw.githubusercontent.com/blackmatrix7/ios_rule_script/master/rule/Clash/OpenAI/OpenAI.yaml"
path: ./ruleset/ai-tools.yaml
interval: 86400
rules:
- DOMAIN-SUFFIX,openai.com,🤖 AI Tools
- DOMAIN-SUFFIX,chatgpt.com,🤖 AI Tools
- DOMAIN-SUFFIX,ai.com,🤖 AI Tools
- DOMAIN-SUFFIX,oaistatic.com,🤖 AI Tools
- DOMAIN-SUFFIX,oaiusercontent.com,🤖 AI Tools
- DOMAIN-SUFFIX,anthropic.com,🤖 AI Tools
- DOMAIN-SUFFIX,claude.ai,🤖 AI Tools
- DOMAIN-SUFFIX,gemini.google.com,🤖 AI Tools
- DOMAIN-SUFFIX,aistudio.google.com,🤖 AI Tools
- DOMAIN-SUFFIX,generativelanguage.googleapis.com,🤖 AI Tools
- DOMAIN-SUFFIX,copilot.github.com,🤖 AI Tools
- DOMAIN-SUFFIX,cursor.sh,🤖 AI Tools
- DOMAIN-SUFFIX,cursor.com,🤖 AI Tools
- DOMAIN-SUFFIX,perplexity.ai,🤖 AI Tools
- DOMAIN-SUFFIX,midjourney.com,🤖 AI Tools
- RULE-SET,ai-tools,🤖 AI Tools
- MATCH,DIRECTSecurity Considerations
- Fixed IP Strategy: Set higher
tolerancevalue in proxy-group (e.g., 100ms) to avoid frequent automatic node switching causing IP changes - Fixed Region: AI node group should only contain nodes from one region (e.g., all US) to avoid cross-region switching
- Use Fallback Group: If primary node is unavailable, automatically switch to backup node in same region
- API Key Security: Don't store API Keys in configuration files, use environment variables
- Regular Checks: Confirm in ClashX connection panel that AI platform traffic actually goes through designated nodes
FAQ
Q: ChatGPT shows "Access denied", what to do?
A: This usually means your IP is banned by OpenAI. Solutions: 1) Switch to residential IP node; 2) Clear browser cookies; 3) Use browser private mode to re-login; 4) If Plus user, contact OpenAI support.
Q: Claude shows "Service unavailable in your region"?
A: Claude is currently only available in some regions. Ensure your node IP is in a supported region (US, UK, etc.). Confirm in ClashX connection panel that claude.ai goes through correct node.
Q: Why is ChatGPT still banning me even with proxy?
A: Possible reasons: 1) Using datacenter IP instead of residential IP; 2) Node IP already used by many ChatGPT users; 3) Frequently switching regions. Recommend using fixed residential IP dedicated node.
Q: API call reports "Connection timed out"?
A: Check: 1) Is ClashX running; 2) Is proxy port correct (default 7890); 3) Are terminal environment variables set; 4) Test if api.openai.com is reachable in ClashX.
Q: Can I use AI proxy and back-to-China proxy simultaneously?
A: Of course. In rules, AI domains go to "🤖 AI Tools" node group, domestic domains go to "🇨🇳 Back-to-China" node group, other traffic direct. This is the power of ClashX routing.
Q: Any recommended residential IP providers?
A: This tutorial doesn't recommend specific providers. When choosing, note: 1) Do they provide residential IP nodes; 2) Do node IPs change frequently; 3) Do they support Clash subscription format.