Skip to main content

geminpy

geminpy icon: a browser tipping its hat and handing over a key

Automated OAuth wrapper for Google's Gemini CLI on macOS.

Google's gemini CLI wants you to open a browser, pick your account, and click "Sign in" — every time. geminpy does that clicking for you. It launches Chrome for Testing, runs gemini with your arguments, drives the OAuth screens over the Chrome DevTools Protocol, and hands you back a clean response. Your everyday browser is never touched, and your default browser is restored exactly as it was.

macOS only. geminpy switches the default browser during sign-in using a macOS-only utility. It will not run on Linux or Windows.

Full documentation: https://twardoch.github.io/geminpy/

Three commands to get going

pip install geminpy                       # 1. install
playwright install chromium               # 2. one-time browser setup
geminpy -p "Explain Python decorators"    # 3. ask

The first authenticated call installs Chrome for Testing if it is missing (via @puppeteer/browsers, so Node.js must be available). Every call after that signs in on its own.

Why geminpy

  • Hands-off auth — the OAuth dance runs without you.
  • Your browser, untouched — Chrome for Testing stays isolated; your default browser is put back afterwards.
  • Rate-limit fallback — a 429 triggers an automatic retry on gemini-2.5-flash (with --retry).
  • Clean output — authentication noise is stripped, so scripts get the answer, not the login chatter.
  • Current model aliases — pro and flash resolve to whatever your installed gemini CLI currently ships, not hard-coded IDs.

Command line

geminpy is a drop-in front for gemini — pass the same arguments.

geminpy -p "Explain Python decorators"          # ask a question
geminpy -m pro -p "Write a reverse() function"  # model shortcut: pro / flash
geminpy --user you@gmail.com -p "Hello"         # name the Google account
geminpy --retry -p "Summarise this"             # retry on rate limits
geminpy --quit-browser -p "What day is it?"     # quit Chrome when finished
geminpy --verbose -p "Hello world"              # watch the OAuth flow

Omit -p for interactive mode — gemini runs as usual, sign-in handled for you.

Python

from geminpy import ask

answer = ask("Explain quantum computing in simple terms")
print(answer)

# Named account, model shortcut, retry
answer = ask("Generate a Python function", user="you@gmail.com", model="pro", retry=True)

Inside an event loop, use ask_async. For raw gemini arguments, use call_gemini_cli. See the API reference.

Choosing an account

geminpy resolves the Google account in this order:

  1. The --user argument (or user= in Python).
  2. The GEMINI_CLI_USER environment variable.
  3. The account stored from your last successful sign-in.
  4. The first Google account it finds.
export GEMINI_CLI_USER="you@gmail.com"
geminpy -p "Now I don't need --user"

Requirements

  • Platform: macOS (Darwin).
  • Python: 3.10 or newer.
  • Tools: brew install macdefaultbrowsy, then playwright install chromium.
  • Node.js: needed for the one-time Chrome for Testing install.

How it works

Every call runs four phases — setup, authentication, execution, cleanup — and the cleanup phase always runs, so your default browser ends up where it started. The full walkthrough, including troubleshooting, lives in How it works.

Development

Built with Hatch.

hatch run test:test        # run tests (all browser/network calls are mocked)
hatch run lint:style       # ruff check + format
hatch run lint:typing      # mypy
hatch build                # build wheel + sdist

CI runs the mocked test suite on macOS and Linux across Python 3.10–3.12. Tagging vX.Y.Z builds and publishes to PyPI and GitHub Releases.

License

MIT — see LICENSE.

Metadata

Release files for geminpy 1.5.2

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

Source distribution (sdist)

Source distribution for geminpy 1.5.2
File Size Uploaded Provenance Actions
geminpy-1.5.2.tar.gz 25.9 kB With provenance Details for geminpy-1.5.2.tar.gz

Built distribution (wheel)

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

Total release size: 53.4 kB

Release files / geminpy-1.5.2.tar.gz

Download URL geminpy-1.5.2.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6663aee134b070789b54f8be7a715031d1975053086ab45ab4c58e71250db9d4
BLAKE2b-256 checksum
How to use checksums
96fa0417604946fb1666dcb3ab232b1d11558bfb87248d83db946a323a867607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Release files / geminpy-1.5.2-py3-none-any.whl

Download URL geminpy-1.5.2-py3-none-any.whl
Size 27.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ffb3338f1de727e78a8a6477e7d6c888480fe95b6daaf652b4d612e8b3f24eb7
BLAKE2b-256 checksum
How to use checksums
67b9f4d5ae0d59d59b874b3b5b13b336dbe21e94d604af6c94508b86d448f6ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 17, 2026.

Transparency log

Security for geminpy 1.5.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for geminpy-1.5.2.tar.gz

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 Nov 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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