Introduction

Let your users bring their own ChatGPT subscription

loginwithchatgpt is a drop-in "Login with ChatGPT" button. Your users sign in with their own ChatGPT account, and your app's AI features run on their Plus/Pro subscription instead of an API key you pay for. It uses OpenAI's Codex OAuth flow — the same mechanism the Codex CLI uses.

What this is

One package with three entry points: a headless engine, a React component, and Next.js route handlers. The dev writes about one line; the library handles PKCE, the loopback/device flows, encrypted token storage, and automatic refresh.

Why it exists

  • - Building AI features normally means paying OpenAI per request — costs scale with users.
  • - Your users often already pay for ChatGPT but can't use it inside your app.
  • - This shifts the AI cost to each user's own subscription. Win/win.

The honest scope

Each user logs in with their own account, on their own machine, spending their own subscription — the same posture as the Codex CLI. It is built for local-first contexts: desktop apps, Electron, CLIs, and local-first Next.js tools, where the OAuth redirect lands on the user's own machine. It is not a way to pool or resell subscriptions.

Start here

Head to Quickstart to install and wire it up, or see the API reference.