Skip to content
For Claude Code, ChatGPT and the APIs

ai-proxy-rulesRoute only AI traffic through your proxy.

Domain and IP rules for OpenAI, Claude and Apple Intelligence. Everything else stays direct — no global mode needed just to reach api.anthropic.com.

ClashmihomoShadowrocketSurgeLoonStash
– + – + –

Claude + OpenAI + Apple Intelligence rules

Web apps, APIs, Claude Code, sandboxes, login and CAPTCHA, Anthropic's own IP blocks, plus Siri / Apple Intelligence and Private Relay.

1

One source, every client

Rules live in one list; Clash and Shadowrocket files are generated from it and checked in CI.

0

Servers included

Rules only. Use your own nodes — pick one, and only AI traffic goes through it.

Install ​

Pick your client.

Keep your own config — add a RULE-SET

Add these lines to your config, above FINAL. Replace PROXY with your own policy group if you want a dedicated node.

RULE-SET,https://raw.githubusercontent.com/ma-wenqian/ai-proxy-rules/main/rules/openai.list,PROXY
RULE-SET,https://raw.githubusercontent.com/ma-wenqian/ai-proxy-rules/main/rules/claude.list,PROXY

Apple Intelligence is a separate rule set: point it at a node in a supported region (e.g. US) and place it above any rule that sends apple.com / iCloud direct.

RULE-SET,https://raw.githubusercontent.com/ma-wenqian/ai-proxy-rules/main/rules/apple-intelligence.list,US

Or switch to a standalone config

One tap on your iPhone or iPad imports the config. It contains no servers: PROXY is whichever server is selected in the app, and everything else goes direct.

RULE-SET

The same .list files work in Surge, Loon and Stash. Add them above your final rule.

RULE-SET,https://raw.githubusercontent.com/ma-wenqian/ai-proxy-rules/main/rules/openai.list,PROXY
RULE-SET,https://raw.githubusercontent.com/ma-wenqian/ai-proxy-rules/main/rules/claude.list,PROXY

Apple Intelligence is separate — use a supported-region (e.g. US) policy and put it above any direct apple.com / iCloud rule.

RULE-SET,https://raw.githubusercontent.com/ma-wenqian/ai-proxy-rules/main/rules/apple-intelligence.list,US

Merge into your own config. RULE-SET must come before GEOIP,CN and MATCH, and the policy name must be a group that exists in your proxy-groups.

rule-providers:
  ai-proxy:
    type: http
    behavior: classical
    format: yaml
    interval: 86400
    url: "https://raw.githubusercontent.com/ma-wenqian/ai-proxy-rules/main/Clash/ai-proxy.yaml"
    path: ./ruleset/ai-proxy.yaml

rules:
  - RULE-SET,ai-proxy,AI      # AI = your own proxy group

Full example: Clash/example-config.yaml. On old Clash Premium, drop the format: yaml line.

What's covered ​

Live from rules/*.list — the single source every other file is generated from. What each group is for: What's covered.

Loading rules…

If the web app works but your SDK times out ​

  • Rules only apply to traffic that goes through the proxy client. System-proxy mode usually covers browsers only — curl, Node and Python ignore it.
  • Turn on TUN / enhanced mode so every process is captured, or set HTTPS_PROXY=http://127.0.0.1:7890 in your shell (this proxies everything).
  • Don't match Claude Code with PROCESS-NAME,node — that pulls every Node process through the proxy. Domain rules are more precise.
  • Prefer a residential node and avoid load balancing: both providers are strict about datacenter IPs, and changing exit IP mid-session drops your login.

More in SDK times out?

Domain lists and configuration notes only — no proxy servers are provided. Use within the law where you live.