AIstudioProxyAPI is a free, open source networking & connectivity project written in Python and released under AGPL-3.0. It has 2,512 GitHub stars, 426 forks and 24 open issues, and was last pushed 5 months ago. On this registry it ranks #37 of 47 tracked projects in Networking & Connectivity, with 5 head-to-head comparisons available.

What is AIstudioProxyAPI?

AIstudioProxyAPI is a self-hosted Python middleware that turns the Google AI Studio web interface into an OpenAI-compatible API endpoint, for developers who want to call Gemini models through standard OpenAI clients without an official API key.

What it is

AIstudioProxyAPI is a FastAPI application that sits between ordinary OpenAI-format clients and Google AI Studio. It receives requests on standard OpenAI routes, drives a Camoufox browser session via Playwright to submit those requests to the Google AI Studio chat page, and then returns the results in the same OpenAI response format. The project ships with a built-in debugging Web UI, a CLI launcher, a desktop GUI launcher, and a streaming proxy layer, and it is written in Python under the AGPL-3.0 licence.

The concrete problem it solves is access: it gives applications that only know how to speak the OpenAI API a way to reach Google AI Studio's models when no direct API integration exists. Instead of each client reimplementing browser automation and session handling, the project centralises it behind /v1/chat/completions and /v1/models, so any OpenAI-compatible tool can point at a single base URL. It also manages the operational side of that arrangement — authentication profiles, cookie refresh, and function-call translation — which would otherwise have to be handled ad hoc.

Key capabilities

  • Exposes OpenAI-compatible endpoints /v1/chat/completions and /v1/models on the main API port (PORT, default 2048), returning responses in OpenAI format.
  • Supports three function-calling modes — auto, native, and emulated — with fallback behaviour when a mode fails, controlled by FUNCTION_CALLING_MODE.
  • Rotates authentication profiles and refreshes cookies automatically, with periodic refresh and saving on shutdown, governed by AUTO_ROTATE_AUTH_PROFILE.
  • Offers a complete launch chain: the launch_camoufox.py CLI launcher with --headless, --debug, and --virtual-display modes, a built-in Web UI, and a desktop GUI launcher.
  • Runs a separate streaming proxy on STREAM_PORT (default 3120, set to 0 to disable) for real-time responses.
  • Centralises configuration in a single .env file, including PORT, STREAM_PORT, UNIFIED_PROXY_CONFIG for HTTP/HTTPS proxying, and LAUNCH_MODE.
  • Provides a built-in Web UI with a settings page, status checks, and log viewing, plus CI/CD workflows covering PR checks, releases, and upstream sync.

Who uses it and how

  • Developers wiring up OpenAI-compatible front ends: the README's worked example points Open WebUI's settings at http://127.0.0.1:2048/v1, leaving the API key blank when none is configured.
  • Operators running it on a server in --headless mode for daily use, or with --virtual-display on Linux hosts without a GUI, with a minimum of 2GB RAM and 4GB recommended.
  • People performing first-time authentication interactively with launch_camoufox.py --debug, completing the Google login and saving auth before switching to headless operation.
  • Teams running several instances side by side through the multi-instance Docker manager in scripts/multi-instance-manager/.
  • Contributors running the documented checks — poetry run ruff check ., poetry run pyright, and poetry run pytest — plus a frontend build in static/frontend.

Getting started

Clone the repository, run poetry install --with dev, copy .env.example to .env, and then start with poetry run python launch_camoufox.py --debug to authenticate before switching to --headless for daily use.

How it compares

Among the tools named in its own documentation it stands alone in this registry: FastAPI, Playwright, and Camoufox are the pieces it is built from rather than alternatives to it, and Open WebUI appears only as an example client that connects to it. Its role is specifically as a gateway in front of Google AI Studio for OpenAI-format consumers.

When to use it — and when not to

A self-hoster must operate a running Camoufox browser session, maintain valid Google AI Studio login cookies, and manage an .env configuration file on a machine meeting the 2GB RAM floor. It is a poor fit for anyone needing a formally supported API contract, since the project relays requests through a web interface that Google can change at any time, and the browser automation layer is inherently exposed to that breakage. The licence is AGPL-3.0, which obliges distributed modifications to be released, and with 24 open issues the surface of known unresolved problems is worth checking before committing to it.

project readme (upstream, from github) — read inline

AI Studio Proxy API

将 Google AI Studio 网页界面转换为 OpenAI 兼容 API 的代理服务。通过 Camoufox + Playwright 自动化,提供稳定可控的 API 访问。

Star History Chart


主要特性

  • OpenAI 兼容 API:支持 /v1/chat/completions、/v1/models
  • 函数调用三模式:auto / native / emulated,支持失败回退
  • 认证轮转与 Cookie 刷新:支持 profile 自动轮转、周期刷新与关停保存
  • 启动链路完整:CLI 启动器、内置 Web UI、桌面 GUI 启动器
  • 现代化前端:内置设置页、状态检查与日志能力
  • CI/CD 工作流:PR 检查、Release、Upstream Sync

系统要求

组件 要求 推荐
Python >=3.9, =2GB >=4GB

🚀 快速开始

1. 克隆并安装

git clone https://github.com/CJackHwang/AIstudioProxyAPI.git
cd AIstudioProxyAPI
poetry install --with dev

2. 配置环境

cp .env.example .env

建议先确认:PORT、STREAM_PORT、UNIFIED_PROXY_CONFIG、LAUNCH_MODE、FUNCTION_CALLING_MODE。

3. 首次认证并启动

# 首次建议 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 为例:

  1. 进入设置 -> 连接
  2. API Base URL 填 http://127.0.0.1:2048/v1
  3. 若你未配置 API Keys,可留空或填任意字符;若已配置,请填写有效 Key
  4. 保存后即可对话

开发检查

poetry run ruff check .
poetry run pyright
poetry run pytest

前端构建:

cd static/frontend
npm ci
npm run build

致谢

License

AGPLv3

支持作者

如果本项目对你有帮助,欢迎支持作者持续开发:

支持作者

Frequently asked questions

Is AIstudioProxyAPI free to use?

AIstudioProxyAPI is open source under the AGPL-3.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does AIstudioProxyAPI do?

FastAPI + Playwright + Camoufox 中间层代理服务器,兼容OpenAI API且支持参数转发。项目通过浏览器自动化将API请求转发到 Google AI Studio Chat,并同样按照OpenAI标准格式返回的工具。内置调试WebUI面板。

What is AIstudioProxyAPI written in?

AIstudioProxyAPI is primarily written in Python. Its source is publicly available at https://github.com/CJackHwang/AIstudioProxyAPI, and it has 2,512 GitHub stars.