gitwtfhub

zqbxdev/webchat2api

99PythonAudience · developerComplexity · 3/5ActiveSetup · moderate

TL;DR

Proxy that wraps the ChatGPT and Grok web chat interfaces behind an OpenAI-style API, with a Next.js admin panel for managing accounts, keys, and image jobs.

Mindmap

mindmap
  root((webchat2api))
    Inputs
      ChatGPT web logins
      Grok web logins
      Bearer API keys
    Outputs
      OpenAI v1 chat completions
      Image generations
      Model list endpoint
    Use Cases
      Reuse paid chat accounts via API
      Self host OpenAI compatible gateway
      Rotate image accounts
    Tech Stack
      FastAPI
      Next.js
      Docker
      Postgres or SQLite
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why anyone would actually build this

REASON 1

Call your ChatGPT or Grok web sessions from code using OpenAI-compatible endpoints.

REASON 2

Self-host an admin panel that pools and rotates GPT and Grok accounts for image jobs.

REASON 3

Front your own tools with a single Bearer-token API that hides which chat backend is used.

Stack

PythonFastAPINext.jsDockerSQLitePostgres

Spinning it up

Difficulty · moderate Time to first run · 30min

Needs Docker plus valid ChatGPT or Grok web session tokens imported into the account pool before any API call works.

Wtf does this do

webchat2api is a proxy server that takes the browser-based chat interfaces of ChatGPT and Grok and exposes them as a standard OpenAI-style API. The idea is that if you already have a web login for ChatGPT or Grok, this project lets you call those chats from your own code using the same endpoints that other tools use to talk to the official OpenAI API, things like /v1/models, /v1/chat/completions, and /v1/images/generations. The README opens with a clear warning. The project is reverse-engineering the web chat experience, and it is meant for personal learning and non-commercial technical exploration. The author tells users not to use it for reselling or any large-scale abuse, and to accept that accounts may get rate-limited or banned. There is also a security note that the default login password is admin, which is only fine for local testing. For any public deployment you have to set a strong LOGIN_SECRET or WEBCHAT2API_AUTH_KEY. The stack is FastAPI on the backend and a Next.js admin web app on top of it. The admin panel manages a pool of GPT and Grok accounts, user API keys, proxy settings, logs, image jobs, files, and overall system config. There is also a playground page for trying chat and image generation, with separate text-to-image and image-to-image modes, plus an image queue and history. When generating images, if one account fails the service rotates to the next available one. Getting started is built around Docker. You clone the repo, build the image, and run a docker container that exposes port 83 with a data volume for persistence. There is a second example that adds a proxy URL pointing to the host machine, useful when you need to tunnel out through your own network. Docker Compose is also supported, and there are commands for local development with uv for the Python side and npm run dev for the web frontend. The API examples in the README show how to call /health, list models, chat, and generate images using a Bearer token. Configuration lives in a .env file and a config.json that you copy from the example. Storage can be plain JSON files, SQLite, Postgres, or even Git as a backend. The data folder holds accounts, keys, logs, and image tasks, and the README is firm that this folder must never be committed to version control.

Yoink these prompts

Prompt 1
Walk me through deploying webchat2api on a fresh VPS with Docker Compose and a strong LOGIN_SECRET.
Prompt 2
Show me a Python script that calls webchat2api /v1/chat/completions and falls back from Grok to GPT on errors.
Prompt 3
Help me switch webchat2api storage from JSON files to Postgres and migrate existing accounts.
Prompt 4
Write a small CLI that imports a list of Grok access tokens into webchat2api via the admin API.
View the repo → Decode another repo

← zqbxdev on gitmyhub — every repo by this author, as a profile.

Don't trust strangers blindly. Verify against the repo.