FastAPI + Playwright + Camoufox 中间层代理服务器,兼容OpenAI API且支持参数转发。项目通过浏览器自动化将API请求转发到 Google AI Studio Chat,并同样按照OpenAI标准格式返回的工具。内置调试WebUI面板。
See the code将 Google AI Studio 网页界面转换为 OpenAI 兼容 API 的代理服务。通过 Camoufox + Playwright 自动化,提供稳定可控的 API 访问。
/v1/chat/completions、/v1/modelsauto / native / emulated,支持失败回退| 组件 | 要求 | 推荐 |
|---|---|---|
| Python | >=3.9, <4.0 | 3.10+ / 3.11+ |
| 依赖管理 | Poetry | 最新版本 |
| Node.js | 前端构建需要 | LTS |
| 内存 | >=2GB | >=4GB |
git clone https://github.com/CJackHwang/AIstudioProxyAPI.git
cd AIstudioProxyAPI
poetry install --with dev
cp .env.example .env
建议先确认:PORT、STREAM_PORT、UNIFIED_PROXY_CONFIG、LAUNCH_MODE、FUNCTION_CALLING_MODE。
# 首次建议 debug,完成登录并保存 auth
poetry run python launch_camoufox.py --debug
# 日常建议 headless
poetry run python launch_camoufox.py --headless
# 健康检查
curl http://127.0.0.1:2048/health
# 模型列表
curl http://127.0.0.1:2048/v1/models
# 聊天请求
curl -X POST http://127.0.0.1:2048/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"gemini-2.5-pro","messages":[{"role":"user","content":"你好"}]}'
访问 http://127.0.0.1:2048/ 使用内置 Web UI。
graph TD
subgraph "用户端"
User["用户"]
WebUI["Web UI"]
APIClient["API 客户端"]
end
subgraph "启动与配置"
Launcher["launch_camoufox.py"]
Env[".env 配置"]
end
subgraph "核心服务"
FastAPI["FastAPI 应用<br/>api_utils/"]
BrowserOps["页面控制与自动化<br/>browser_utils/"]
StreamProxy["流式代理<br/>stream/"]
end
subgraph "外部依赖"
Camoufox["Camoufox 浏览器"]
AIStudio["Google AI Studio"]
end
User --> Launcher
Launcher --> Env
WebUI --> FastAPI
APIClient --> FastAPI
FastAPI --> BrowserOps
FastAPI --> StreamProxy
BrowserOps --> Camoufox --> AIStudio
StreamProxy --> AIStudio
| 命令 | 说明 | 场景 |
|---|---|---|
python launch_camoufox.py --headless | 无头模式 | 日常使用、服务器 |
python launch_camoufox.py --debug | 调试模式 | 首次认证、故障排查 |
python launch_camoufox.py --virtual-display | 虚拟显示 | Linux 无 GUI 环境 |
项目使用 .env 统一配置管理:
cp .env.example .env
核心配置示例:
| 配置 | 默认值 | 说明 |
|---|---|---|
PORT | 2048 | 主 API 端口 |
STREAM_PORT | 3120 | 流式代理端口(0 关闭) |
UNIFIED_PROXY_CONFIG | 空 | HTTP/HTTPS 代理 |
AUTO_ROTATE_AUTH_PROFILE | true | 认证自动轮转 |
FUNCTION_CALLING_MODE | auto | 函数调用模式 |
详细项见:配置参考
说明:配置默认值以
.env.example为准;少数配置存在代码兜底默认值,详见配置参考中的说明。
以 Open WebUI 为例:
http://127.0.0.1:2048/v1poetry run ruff check .
poetry run pyright
poetry run pytest
前端构建:
cd static/frontend
npm ci
npm run build
如果本项目对你有帮助,欢迎支持作者持续开发:

81 followers · starred Apr 2025
58 followers · starred Nov 2025
6 followers · starred May 2025
18 followers · starred Dec 2025
FastAPI + Playwright + Camoufox 中间层代理服务器,兼容OpenAI API且支持参数转发。项目通过浏览器自动化将API请求转发到 Google AI Studio Chat,并同样按照OpenAI标准格式返回的工具。内置调试WebUI面板。
See the code将 Google AI Studio 网页界面转换为 OpenAI 兼容 API 的代理服务。通过 Camoufox + Playwright 自动化,提供稳定可控的 API 访问。
/v1/chat/completions、/v1/modelsauto / native / emulated,支持失败回退| 组件 | 要求 | 推荐 |
|---|---|---|
| Python | >=3.9, <4.0 | 3.10+ / 3.11+ |
| 依赖管理 | Poetry | 最新版本 |
| Node.js | 前端构建需要 | LTS |
| 内存 | >=2GB | >=4GB |
git clone https://github.com/CJackHwang/AIstudioProxyAPI.git
cd AIstudioProxyAPI
poetry install --with dev
cp .env.example .env
建议先确认:PORT、STREAM_PORT、UNIFIED_PROXY_CONFIG、LAUNCH_MODE、FUNCTION_CALLING_MODE。
# 首次建议 debug,完成登录并保存 auth
poetry run python launch_camoufox.py --debug
# 日常建议 headless
poetry run python launch_camoufox.py --headless
# 健康检查
curl http://127.0.0.1:2048/health
# 模型列表
curl http://127.0.0.1:2048/v1/models
# 聊天请求
curl -X POST http://127.0.0.1:2048/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{"model":"gemini-2.5-pro","messages":[{"role":"user","content":"你好"}]}'
访问 http://127.0.0.1:2048/ 使用内置 Web UI。
graph TD
subgraph "用户端"
User["用户"]
WebUI["Web UI"]
APIClient["API 客户端"]
end
subgraph "启动与配置"
Launcher["launch_camoufox.py"]
Env[".env 配置"]
end
subgraph "核心服务"
FastAPI["FastAPI 应用<br/>api_utils/"]
BrowserOps["页面控制与自动化<br/>browser_utils/"]
StreamProxy["流式代理<br/>stream/"]
end
subgraph "外部依赖"
Camoufox["Camoufox 浏览器"]
AIStudio["Google AI Studio"]
end
User --> Launcher
Launcher --> Env
WebUI --> FastAPI
APIClient --> FastAPI
FastAPI --> BrowserOps
FastAPI --> StreamProxy
BrowserOps --> Camoufox --> AIStudio
StreamProxy --> AIStudio
| 命令 | 说明 | 场景 |
|---|---|---|
python launch_camoufox.py --headless | 无头模式 | 日常使用、服务器 |
python launch_camoufox.py --debug | 调试模式 | 首次认证、故障排查 |
python launch_camoufox.py --virtual-display | 虚拟显示 | Linux 无 GUI 环境 |
项目使用 .env 统一配置管理:
cp .env.example .env
核心配置示例:
| 配置 | 默认值 | 说明 |
|---|---|---|
PORT | 2048 | 主 API 端口 |
STREAM_PORT | 3120 | 流式代理端口(0 关闭) |
UNIFIED_PROXY_CONFIG | 空 | HTTP/HTTPS 代理 |
AUTO_ROTATE_AUTH_PROFILE | true | 认证自动轮转 |
FUNCTION_CALLING_MODE | auto | 函数调用模式 |
详细项见:配置参考
说明:配置默认值以
.env.example为准;少数配置存在代码兜底默认值,详见配置参考中的说明。
以 Open WebUI 为例:
http://127.0.0.1:2048/v1poetry run ruff check .
poetry run pyright
poetry run pytest
前端构建:
cd static/frontend
npm ci
npm run build
如果本项目对你有帮助,欢迎支持作者持续开发:

81 followers · starred Apr 2025
58 followers · starred Nov 2025
6 followers · starred May 2025
18 followers · starred Dec 2025