← all repositories
labteral/chatgpt-python

ChatGPT without the browser: a Python wrapper that logs in for you

This SDK automates the messy part—authenticating to ChatGPT's unofficial API—so you can script conversations like any other service.

523 stars Python Chat Assistants
chatgpt-python
Velocity · 7d
+0.4
★ / day
Trend
steady
collecting data…
star history

What it does

chatgpt-python is a thin Python wrapper around ChatGPT’s web API. It handles email/password login, token refresh, and session persistence, then exposes a simple Conversation class with streaming and synchronous chat methods. There’s also a minimal CLI for interactive use.

The interesting bit

The library doesn’t use OpenAI’s official API; it reverse-engineers the browser flow, managing access tokens and caching them to disk. That means you pay nothing per token—but you’re also at the mercy of whatever rate limits and protections OpenAI applies to web users. The stream() method is recommended over chat(), which suggests the authors learned that waiting for a full ChatGPT response feels like watching paint dry.

Key highlights

  • Authenticates via email/password, not API keys; stores tokens in a configurable cache file
  • Supports SOCKS5 proxies and custom timeouts for the login dance
  • CHATGPT_HOME environment variable lets you relocate config and cache
  • Exposes granular error codes (INVALID_ACCESS_TOKEN, LOGIN_ERROR, TIMEOUT_ERROR, etc.)
  • CLI with basic commands: reset (forget context), clear, exit

Caveats

  • Unofficial and fragile by design; OpenAI can break this at any time by changing their web frontend or tightening bot detection
  • Requires storing plaintext credentials in config.json—no mention of keyring integration or encryption
  • 523 stars suggests modest adoption; unclear how actively maintained given the rapid pace of ChatGPT changes

Verdict

Worth a look if you need free, scripted ChatGPT access and can tolerate maintenance pain. If you’re building anything production-grade, OpenAI’s official API is the boring, reliable choice—and boring is the point.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.