Skip to main content

Hermex

Drive ChatGPT and Gemini from Python — no API keys, no billing, just the free web UI.

PyPI Python 3.11+ GitHub Repo Docs


ChatGPT and Gemini are incredibly capable — but their official APIs are expensive, and for many tasks you simply don't need them. If you want to run OCR on an image, generate artwork, extract text from a screenshot, or just ask a quick question in a script, paying per-token for API access is overkill when the free web UI can do the same thing.

Hermex lets you automate ChatGPT and Gemini with Python — no API keys, no billing, no paywalls. It opens a real Chrome browser, types your message, uploads your files, waits for the response, and hands it back to you as a Python object, just like a human would.

from hermex import ChatGPT

response = ChatGPT.simple_query("What does this receipt say?", attachments=["receipt.jpg"])
print(response.text)

It uses undetected-chromedriver under the hood to avoid bot detection, and reuses a persistent browser profile so your login session survives across runs.

Installation

pip install hermex

Requires Python 3.11+ and Google Chrome 130+

First-time setup

Hermex reuses a persistent Chrome profile so you only need to log in once:

from hermex import Gemini

Gemini.setup()  # opens a browser — log in, browse briefly, then close the window

After setup, all future runs reuse the saved session automatically. Repeat this if your session expires.

Guest mode (no login) works for basic text queries on Gemini but file upload requires a logged-in session. ChatGPT works without login for text queries and file upload, but image generation requires a logged-in session.

Usage

Single query

from hermex import Gemini, ChatGPT

# Gemini
gemini = Gemini()
gemini.open_url()
response = gemini.query("Summarize the history of the internet.")
print(response.text)
gemini.close()

# ChatGPT
chatgpt = ChatGPT()
chatgpt.open_url()
response = chatgpt.query("Summarize the history of the internet.")
print(response.text)
chatgpt.close()

Attaching files

response = gemini.query(
    "Describe what's in this image.",
    attachments=["photo.jpg"],
)
print(response.text)

Supported formats: .jpg, .jpeg, .png, .gif, .webp, .pdf, .csv, .txt, .json. Each platform exposes its allowed types via Gemini.SUPPORTED_ATTACHMENTS and ChatGPT.SUPPORTED_ATTACHMENTS.

One-shot query

from hermex import Gemini, ChatGPT

response = Gemini.simple_query("What is the capital of France?")
print(response.text)

response = ChatGPT.simple_query("What is the capital of France?")
print(response.text)

# With an attachment
response = Gemini.simple_query("Describe this image.", attachments=["photo.jpg"])
print(response.text)

AssistantMessage object

query() and get_last_response() return an AssistantMessage dataclass:

@dataclass
class AssistantMessage:
    text: str | None   # plain text (or markdown if get_markdown=True)
    image: Path | None # path to downloaded image, or None

Scope & limitations

  • Built for hobby, scripting, and research — not production. It drives a real browser UI, so it's slower and less robust than an official API.
  • It can break when the chat UIs change. Hermex depends on the page structure of ChatGPT and Gemini; a redesign on their end may require an update here.
  • Respect each platform's Terms of Service. Automating the web UI isn't appropriate for every use case — use it responsibly and at your own risk.
  • The platforms' own usage limits still apply. Any caps the free web UI enforces (message and image-generation limits, cooldowns) are still in effect.

API reference

Both Gemini and ChatGPT share the same interface — all methods below apply to both unless noted.

Method Description
open_url(url, timeout) Open the chat interface in the browser
send_message(message, attachments, paste, fake_typing, typing_delay, submit) Type and optionally submit a message
query(message, attachments, paste, fake_typing, typing_delay, get_markdown, remove_watermark, timeout) Send a message, wait for the response, and return it
get_last_response(get_markdown, remove_watermark) Retrieve the most recent response
wait_until_idle(timeout) Block until the chatbot finishes generating
get_state() Return the current UI state (State.IDLE, GENERATING, TYPING, UPLOADING)
simple_query(message, attachments, paste, fake_typing, typing_delay, get_markdown, remove_watermark, timeout) Class method — open, query, close in one call
short_wait() Sleep ~7 seconds
long_wait() Sleep ~5 minutes
refresh_page() Reload the current page
close() Close the browser
setup() One-time login setup (class method)

See the full documentation for detailed guides on Gemini and ChatGPT.

Constructor options

Gemini(
    chrome_version=None,      # auto-detected from installed Chrome
    download_dir=Path("."),   # where generated images are saved
    headless=False,
    typing_delay=0.025,       # seconds between keystrokes
    disable_web_security=True,
)
# ChatGPT accepts the same parameters

Watermark removal

Gemini watermarks its generated images. Pass remove_watermark=True to strip it:

response = gemini.query("Generate an image of a sunset.", remove_watermark=True)

Notes

  • Bot detection is mitigated through per-character typing delays, fake typing before paste, a persistent browser profile, and a spoofed user agent. Avoid running headless for sensitive sessions.
  • Browser profile and session data are stored in the platform data directory (~/Library/Application Support/hermex on macOS).
  • See CHANGELOG.md for the full release history.

Release files for hermex 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hermex 0.4.4
File Size Uploaded
hermex-0.4.4.tar.gz 28.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hermex 0.4.4
File Interpreter ABI Platform
hermex-0.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 57.9 kB

Release files / hermex-0.4.4.tar.gz

Download URL hermex-0.4.4.tar.gz
Size 28.8 kB
Tags Source
SHA-256 checksum
How to use checksums
419f02a91b357ac6cdd026cf1ae7dd0814df3fb14245757ba018053c399771ec
BLAKE2b-256 checksum
How to use checksums
da8a611c683e792d64c23a4df00715f3c0f7903abe3ba3a13afc7a73d8bc7fcb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release files / hermex-0.4.4-py3-none-any.whl

Download URL hermex-0.4.4-py3-none-any.whl
Size 29.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d756ff6e046857afab4df96d4015ef10dbd19eb49418a8f7d86565e51f44c29
BLAKE2b-256 checksum
How to use checksums
d8fa36bd5ca6912ae3fb77df17ed8541d627402b74d1349c8311ca0707459dfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 31, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page