Skip to content
Projects

About

A protocol-level reverse-engineered implementation of the official ChatGPT website API. Supports a registration bot to maintain account-pool quotas, GPT-Image-2 and text models, and the OpenAI API protocol. Includes online batch image generation and editing, account-pool management, reverse engineering for editable PPT/PSD files, importing CPA and sub2api account pools, and integration with software such as Cherry Studio and New API.

Design & Media

How these counts are measured

Measured star growth

in 24h
+2
in 7 days
+18
in 15 days
+32
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README_EN.md

Original

ChatGPT2API logo

ChatGPT2API

Expose supported ChatGPT Web capabilities through OpenAI-compatible APIs, with a self-hosted console for multi-account orchestration and image workflows.

简体中文 · English

Version v3.2.3 Python 3.13 Vue 3 PostgreSQL 18 Docker ready License AGPL-3.0

v3.2.3 Release · Changelog · Documentation

QQ Group: 1005859624

[!IMPORTANT] v3.0.0 is a new release baseline. The remote main history has been consolidated, and older source history, Git tags, releases, and container images are no longer maintained as part of the current release line. Version 3.0 uses a new Application Database and cannot read the distributed storage used by 2.x directly. Reconfigure the service or re-import accounts after upgrading.

[!WARNING] This project accesses ChatGPT Web text, image, and file-generation capabilities through reverse engineering and is not an official OpenAI service. Upstream changes may break these interfaces or cause account restrictions and temporary or permanent bans; do not use important, frequently used, or high-value accounts.

Users must understand the technical, account, and compliance risks and comply with OpenAI's terms and applicable laws. Bulk abuse, malicious competition, account theft, fraud, harassment, and the generation or distribution of illegal, violent, sexual, or minor-related content are strictly prohibited. Users assume all risks and consequences.

Quick Start

One-click installer

curl -fsSL https://raw.githubusercontent.com/yukkcat/chatgpt2api/main/deploy/install.sh | sudo bash

The installer lets you choose SQLite, a local PostgreSQL 18 container, or an existing PostgreSQL URL. SQLite requires no additional service. Local PostgreSQL is started and persisted automatically through Compose.

To install the fixed v3.2.3 release:

curl -fsSL https://raw.githubusercontent.com/yukkcat/chatgpt2api/v3.2.3/deploy/install.sh | sudo bash -s -- --branch v3.2.3

Docker Compose

SQLite is used by default:

git clone https://github.com/yukkcat/chatgpt2api.git
cd chatgpt2api
cp .env.example .env
# Edit .env and set a private CHATGPT2API_AUTH_KEY
test -f config.json || printf '{}\n' > config.json
docker compose up -d
Endpoint Address
Admin console http://localhost:3000
OpenAI-compatible API http://localhost:3000/v1
Data directory ./data

CHATGPT2API_AUTH_KEY in .env takes precedence over auth-key in config.json. Compose uses a dedicated runtime volume for console-managed online updates. Console settings, upstream accounts, user keys, call records, and metrics are stored in the Application Database. Do not commit local .env, config.json, or data/ files.

PostgreSQL 18

Set POSTGRES_PASSWORD in .env, then layer the PostgreSQL Compose file over the base stack:

docker compose -f docker-compose.yml -f docker-compose.postgres.yml up -d

This configuration uses postgres:18-alpine, persists data in a named volume, and does not expose the database port by default. To use an existing PostgreSQL server, set:

DATABASE_URL=postgresql://user:password@host:5432/database

See the deployment guide for upgrades, backups, PostgreSQL setup, and troubleshooting.

Project Scope

ChatGPT2API is continuously developed from basketikun/chatgpt2api. It uses the ChatGPT Web protocol to expose the OpenAI-compatible interfaces implemented by this project.

Capabilities

Shared UI components, themes, and interaction primitives come from yukkcat/nanocat-ui. This repository owns the product pages, backend state projections, and domain workflows.

Area Capabilities
🔌 API gateway Chat Completions, Responses, Messages, search, image generation and editing, PPT/PSD generation, and unified editable-file tasks
💬 Chat and image studio Text chat, web search, text-to-image, image-to-image, multiple references, local editing, Markdown, syntax highlighting, citations, and reasoning effort
👥 Account management Manual, OAuth, Access Token, Session JSON, CPA, remote CPA, and Sub2API imports, plus search, filters, groups, exports, and batch actions
🔑 Credentials and quotas Separate AT/RT states, RT-based AT renewal, plan and quota synchronization, pinned-account text/image tests, and invalid-account handling
⚙️ Scheduling and concurrency Multi-account selection, account-processing concurrency, per-account image concurrency, parallel images, account switching, quotas, and rate-limit state
🌐 Proxy egress Account and account-group proxies, multi-egress proxy groups, per-node image concurrency, rotation, default and fallback egress, and connectivity checks
📊 Logs and monitoring Persisted call records, active requests, recent and slow requests, account switches, egress details, image stage timelines, and raw upstream diagnostics
🖼️ Images and files Local/WebDAV storage, gallery, tags, thumbnails, downloads, ZIP archives, compression, cleanup, PPT/PSD artifacts, and optional image upscaling
✨ Prompt library Local prompt assets, cloud-source synchronization, categorized selection, and source health
💾 Data and backups SQLite, PostgreSQL 18, R2 backups, retention policies, request trends, success rates, and model metrics
🖥️ Admin console Dashboard, accounts, proxies, logs, real-time monitoring, gallery, chat and image studio, and settings on desktop and mobile

Architecture

flowchart LR
  Client["Compatible API client"] --> API["/v1 compatible API"]
  User["Administrator / web user"] --> Console["Vue admin console"]
  API --> Services["Domain services"]
  Console --> AdminAPI["/api admin endpoints"]
  AdminAPI --> Services
  Services --> Scheduler["Account scheduling and proxy egress"]
  Scheduler --> Upstream["ChatGPT Web"]
  Services --> AppDB["Application Database<br/>SQLite / PostgreSQL 18"]
  Services --> Assets["Images and generated files<br/>Local / WebDAV"]
  Services --> Monitor["In-process real-time monitor"]
  Services --> Backup["R2 backup"]

The Application Database stores accounts, user keys, settings, call records, and metrics. Images and generated files remain in dedicated file storage. See the storage architecture for ownership boundaries.

API

All AI endpoints use a Bearer key:

Authorization: Bearer <auth-key>
Endpoint Method Description
/v1/models GET Returns the shared console model catalog; default chat models are gpt-5.6 and auto
/v1/chat/completions POST Chat Completions entry point for text, search, and image scenarios
/v1/responses POST Responses entry point with text, search, and image tools
/v1/messages POST Anthropic Messages-compatible entry point
/v1/search POST Returns an answer, citations, and search results
/v1/images/generations POST Image generation with n=1..4
/v1/images/edits POST Image editing from multipart files, remote URLs, base64, data URLs, or multiple references
/v1/editable-file-tasks GET / POST Creates and queries editable PPT/PSD tasks
/v1/editable-file-tasks/{task_id} DELETE Deletes a task owned by the current key
/v1/ppt/generations POST PPT task shortcut
/v1/psd/generations POST PSD task shortcut
/files/{file_path} GET Publicly downloads a generated file from its random storage path

Creating, querying, and deleting file tasks is isolated by API key. The /files/... links returned by successful tasks work like generated-image links: anyone holding the link can download the asset without authentication. Public downloads validate paths and file types and reject path traversal.

Chat Completions example
curl http://localhost:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <auth-key>" \
  -d '{"model":"gpt-5","messages":[{"role":"user","content":"Introduce this project"}],"stream":true}'
Image generation example
curl http://localhost:3000/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <auth-key>" \
  -d '{"model":"gpt-image-2","prompt":"A cat floating in space, cinematic lighting","n":1,"response_format":"b64_json"}'

Available models depend on the upstream accounts and the current /v1/models response.

Configuration

Setting Default Purpose
CHATGPT2API_AUTH_KEY Required Administrator and default API key; the environment variable takes precedence over config.json
DATABASE_URL SQLite Application Database connection; defaults to data/chatgpt2api.db when unset
CHATGPT2API_BASE_URL Current service URL Public base URL used for generated image and file links
CHATGPT2API_THREAD_TOKENS 120 Capacity for synchronous backend worker threads; accepts any positive integer, while accounts, proxies, and upstream services retain their own limits
account_processing_concurrency 30 Capacity for account imports, refreshes, synchronization, and batch processing
image_account_concurrency 1 Per-account image concurrency, configurable from 1 to 3
image_stream_timeout_secs 80 Maximum wait for the upstream image SSE/HTTP stream
image_poll_timeout_secs 60 Maximum wait for image result polling and parsing
log_retention_hours 24 Automatic call-record retention period in hours

Other settings are managed through the console. The current backend projection is authoritative for defaults and constraints.

Screenshots

Console screenshot 1Console screenshot 2
Console screenshot 3Console screenshot 4
Console screenshot 5Console screenshot 6

Local Development

# Backend: Python 3.13 + uv
uv sync
uv run main.py

# Frontend: Node.js + npm
cd web-vue
npm install
npm run dev

The frontend development server defaults to http://localhost:5173, with backend requests forwarded by the Vite development proxy.

Documentation

Document Scope
Documentation index Entry point for current architecture and maintenance documents
Deployment and operations Docker, PostgreSQL, upgrades, backups, and troubleshooting
Storage architecture Application Database and file-storage boundaries
Console architecture Frontend/backend responsibilities, business projections, and interaction state
Image failure handling Image failure classification, retries, and account handling
Upstream SSE Conversation and stream-parsing boundaries

If documentation conflicts with the implementation, the current code, tests, and public API contracts are authoritative.

License

The current repository is distributed under the GNU Affero General Public License v3.0 (AGPL-3.0-only). If you modify the software and make it available over a network, you must offer the corresponding source code to users of that service as required by the license.

Code derived from basketikun/chatgpt2api retains its original MIT copyright and license notice; see NOTICE. Versions previously released under MIT remain available under their original license.

Project Contributors

Original Project and Contributors

This project evolved from basketikun/chatgpt2api. Thanks to the original author and all contributors:

Community and Links

Explore related projects

Loading…