AIstudioProxyAPI  by CJackHwang

Proxy server for Google AI Studio, offering OpenAI API compatibility

created 3 months ago
1,431 stars

Top 29.1% on sourcepulse

GitHubView on GitHub
Project Summary

This project provides a Python + FastAPI + Playwright server that acts as a proxy for Google AI Studio, mimicking the OpenAI API. It's designed for users who want to leverage Google's AI models through existing OpenAI-compatible clients, offering features like streaming responses, system prompts, and automatic chat clearing for better session isolation.

How It Works

The core of the project involves two Node.js scripts. auto_connect_aistudio.cjs launches a headless Chrome instance with a debugging port enabled, specifically setting a narrow window width (460px) to ensure UI elements like the "Clear chat" button are visible. It then navigates to Google AI Studio's new chat page. server.cjs connects to this Chrome instance via Playwright, intercepts incoming OpenAI-like API requests, simulates user interactions on the AI Studio page (including attempting to clear previous chat history), extracts the AI's response, and returns it in the expected OpenAI format.

Quick Start & Requirements

  • Install: git clone https://github.com/CJackHwang/AIstudioProxyAPI then npm install (or yarn install, pnpm install).
  • Run: node auto_connect_aistudio.cjs
  • Prerequisites: Node.js v16+, NPM/Yarn/PNPM, Google Chrome/Chromium, Google AI Studio account.
  • Setup: Requires cloning the repo, installing Node.js dependencies, and ensuring Chrome is installed. The script handles launching Chrome and the server.
  • Docs: Project Repository

Highlighted Details

  • OpenAI API compatibility for /v1/chat/completions and /v1/models.
  • Supports streaming (stream=true) and non-streaming (stream=false) responses.
  • Implements automatic chat clearing to isolate conversations.
  • Captures screenshots and HTML on error for debugging.
  • Designed for cross-platform use (macOS, Linux, Windows via WSL recommended).

Maintenance & Community

The project is maintained by CJackHwang. Updates are described as "随缘更新" (updated as time permits), indicating a potentially slower development pace. There are no explicit links to community channels like Discord or Slack provided in the README.

Licensing & Compatibility

  • License: MIT
  • Compatibility: The MIT license permits commercial use and linking with closed-source projects. However, the project's reliance on web scraping means it may break if Google updates AI Studio's UI, and its use might violate Google's Terms of Service.

Limitations & Caveats

This is a non-official project that relies on web scraping, making it susceptible to breakage from UI changes. The automatic chat clearing feature is particularly fragile and may require manual updates to selectors. It does not support editing past messages or branching conversations. Parameter configuration (like temperature or model selection) must be done manually in the AI Studio web UI, as the proxy does not forward these parameters. The use of a remote debugging port for Chrome requires careful network security considerations.

Health Check
Last commit

1 week ago

Responsiveness

Inactive

Pull Requests (30d)
1
Issues (30d)
6
Star History
943 stars in the last 90 days

Explore Similar Projects

Starred by Chip Huyen Chip Huyen(Author of AI Engineering, Designing Machine Learning Systems), Jeff Hammerbacher Jeff Hammerbacher(Cofounder of Cloudera), and
1 more.

chathub by chathub-dev

0.1%
10k
All-in-one chatbot client
created 2 years ago
updated 4 months ago
Feedback? Help us improve.