Model or dataset
rawandahmad698/PyChatGPT avatar
rawandahmad698/PyChatGPT

PyChatGPT: A TLS-Based Python Client for ChatGPT Without a Browser

⚡️ Python client for the ChatGPT API with, conversation tracking, proxy support and more.

4,186 stars426 forksPythonMIT

At a glance

What is it?
PyChatGPT is a Python library that authenticates with ChatGPT by reverse-engineering the Auth0 login flow using a TLS client, removing the need for a running browser instance. It supports conversation tracking, session persistence, proxy routing, and a command-line interface, installed as pip install chatgptpy.
Who is it for?
Developers who explored the unofficial ChatGPT API before OpenAI's official release will recognise what PyChatGPT was solving: script-level access to ChatGPT without a browser. The library installs as chatgptpy and includes conversation persistence and proxy support in a compact codebase.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 74 days ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 1, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What PyChatGPT Was Built to Solve

When PyChatGPT was created, most approaches to accessing ChatGPT programmatically required either running a Chromium browser instance in the background or manually extracting an access token from the browser's network inspector. The README describes the motivation: reverse-engineering the API to allow the script to log in automatically, without browser automation.

The library targets Python developers who wanted to query ChatGPT from a script, a server, or a pipeline without starting a browser process. The README lists the practical use cases: saving conversations to a file, resuming conversations after the program exits, routing requests through a proxy, and running a command-line chat session.

This approach has a structural dependency: it relies on the ChatGPT web UI's authentication flow remaining stable. OpenAI released an official API with stable endpoints and API key authentication in March 2023. The README does not address whether PyChatGPT continues to work with the current authentication system.

The TLS Authentication Mechanism

The README explains the authentication approach. Standard HTTP requests to ChatGPT's login endpoint are not sufficient because Auth0 uses a state token, a JWT, to prevent CSRF attacks and bot detection. The library uses a TLS client that mimics a real browser's TLS fingerprint, allowing it to navigate the Auth0 flow without triggering bot detection.

The authentication process in auth.py contains over nine functions, each responsible for a different step in the login sequence. The allow-redirects flag plays a central role in navigating through the login page redirects. After successful authentication, the library saves the access token to a local file so that subsequent sessions do not need to re-authenticate.

The library also automatically refreshes the access token when it expires, avoiding the need to log in again during long sessions. A captcha bypass mechanism is included: if the user gets rate-limited during login, the library handles the captcha challenge.

Installation and First Use

The package is published on PyPI under the name chatgptpy. Install it with:

code
pip install chatgptpy --upgrade

The README recommends using the upgrade flag to get the latest version. Python 3.9 or later is required, as declared in pyproject.toml. The runtime dependencies are tls-client, requests, colorama, svglib, bs4, and reportlab.

The most straightforward usage is an options-configured Chat session:

python
from pychatgpt import Chat, Options

options = Options()
options.log = True
options.track = True
options.proxies = 'http://localhost:8080'

chat = Chat(email="email", password="password", options=options)

Pass your ChatGPT account credentials to the Chat constructor. The options object controls logging, conversation tracking, and proxy routing. For a quick single question without persisting state, the ask method returns a tuple of answer, parent conversation ID, and conversation ID:

python
answer, parent_conversation_id, conversation_id = chat.ask("Hello!")

Conversation Tracking and CLI Chat

PyChatGPT tracks conversations using two identifiers: a parent conversation ID and a conversation ID. The ask method returns both, allowing subsequent calls to continue the same conversation thread. Resuming a conversation after closing the program requires passing these IDs back to the Chat constructor or the ask method:

python
from pychatgpt import Chat

chat = Chat(email="email", password="password",
            conversation_id="Parent Conversation ID",
            previous_convo_id="Previous Conversation ID")

Conversations can also be saved to text files on disk. The options.chat_log and options.id_log settings specify file paths for the conversation text and the conversation IDs respectively. Files are created automatically if they do not exist.

For interactive use, the cli_chat method starts a command-line session that reads input from stdin and prints responses with colorama-formatted output:

python
chat.cli_chat()

Genuine Limitations of the Reverse-Engineering Approach

The fundamental limitation is fragility. The library works by mimicking the ChatGPT web UI's login and conversation API. When OpenAI changes either the authentication flow or the conversation endpoint, the library breaks until someone updates the auth functions.

The changelog in the README documents several breaking changes during the library's development. Version 1.0.2 notes that the ChatGPT API switched the action parameter from action=next to action=variant, requiring a library update. Version 1.0.7 added a moderation endpoint call that was required to avoid receiving crippled responses. These changes happened without notice, and each required a library release to fix.

The library does not use an API key. Accounts used with PyChatGPT face the same rate limits and terms of service as web users. The README notes that if login attempts are too frequent, the account gets rate-limited and the user must wait at least ten minutes or use a VPN.

The README's changelog ends at version 1.0.8. The listed future features include better error handling and multi-user chatting, both marked as incomplete.

How PyChatGPT Compares to the Official OpenAI SDK

The official openai Python package is the supported way to access OpenAI models. It authenticates with an API key rather than account credentials, uses documented stable endpoints, and is maintained by OpenAI directly.

PyChatGPT was built before the official API existed. Its TLS authentication approach was necessary when the only access path was the web interface. The official SDK removes that complexity: authenticate once with a key, call the API, and handle the response. No TLS fingerprinting, no Auth0 state tokens, no captcha handling.

The trade-off was cost. The official API charges per token. PyChatGPT accessed the ChatGPT web tier, which at the time was free for users. The README does not document whether access via PyChatGPT was within OpenAI's terms of service. For production pipelines that need predictable behaviour, SLA guarantees, and long-term maintainability, the official SDK is the appropriate choice.

Maintenance Status and Licence

The last push to the repository was on 2026-07-19. The repository is not archived. The package version in pyproject.toml is 1.0.8. The licence is MIT.

The repository includes a .github/ directory, suggesting some automated tooling is configured. The dependencies include reportlab and svglib alongside the expected requests and colorama, which suggests the library may have capabilities beyond text output that are not fully documented in the README.

The README includes a donation link and a note asking users to star the repository to maintain its visibility. Contributions are accepted through the GitHub repository but no contributing guide is documented in the README.

Editorial conclusion

Developers who explored the unofficial ChatGPT API before OpenAI's official release will recognise what PyChatGPT was solving: script-level access to ChatGPT without a browser. The library installs as chatgptpy and includes conversation persistence and proxy support in a compact codebase. Because the library relies on reverse-engineered authentication, compatibility depends on whether OpenAI has changed the Auth0 login flow since the library was last updated. Engineers who need a stable, supported path to OpenAI's models should use the official openai Python package instead and authenticate with an API key.

Frequently asked questions

How does PyChatGPT authenticate with ChatGPT?

PyChatGPT uses a TLS client that mimics a real browser's TLS fingerprint to navigate the Auth0 login flow. The README describes over nine functions in auth.py that handle each step of the authentication sequence, including the state token used to prevent CSRF attacks.

What is the PyPI package name for PyChatGPT?

The package is published under the name chatgptpy, not pychatgpt. Install it with pip install chatgptpy --upgrade as shown in the README.

Does PyChatGPT support proxy routing?

Yes. The Options class accepts a proxies field. The README shows setting options.proxies = 'http://localhost:8080' before creating a Chat session. The README also notes that using a proxy is recommended if the token creation process is failing.

Official sources

  1. Issues
  2. License: MIT
  3. rawandahmad698/PyChatGPT on GitHub
  4. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rawandahmad698-pychatgpt.svg)](https://hysenlabs.com/projects/rawandahmad698-pychatgpt)