Skip to content

Instantly share code, notes, and snippets.

@tshu-w
Last active March 12, 2024 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tshu-w/39bb65476ca855a1bebe5a81c582a087 to your computer and use it in GitHub Desktop.
Save tshu-w/39bb65476ca855a1bebe5a81c582a087 to your computer and use it in GitHub Desktop.
OpenAI API 全局请求重定向

使用 MitM 加代理工具实现 OpenAI API 请求全局重定向

Surge (macOS Only)

  1. 在 Surge 中安装 CA 证书并使用 AIProxy.sgmodule 模块。

Clash + MitMProxy

  1. 安装 MitmProxy 以及 CA 证书
  2. 后台运行 MitMProxy 并设定重定向规则,例如:screen mitmproxy --map-remote '|//api.openai.com/|//api.aiproxy.io/' -k
  3. 在 Clash 中添加配置,将 api.openai.com 的请求走 HTTP 8080 端口代理,并开启增强模式
#!name=AIProxy
#!desc=Replace OpenAI API host with AIProxy
[URL Rewrite]
^https?:\/\/api\.openai\.com\/(.*) https://api.aiproxy.io/$1 header
[MITM]
hostname = api.openai.com, *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment