open source · MIT · bring your own subscription

Login with ChatGPT

A drop-in button that lets your users power your app's AI with their own ChatGPT subscription. Ship AI features without ever paying OpenAI for API usage.

bun add loginwithchatgpt

One line in your UI

Drop the button, then make AI calls that bill the connected user. No keys, no token plumbing, no refresh logic.

the button

import { LoginWithChatGPT } from "loginwithchatgpt/react";

export default function Page() {
  return (
    <LoginWithChatGPT
      onConnected={(s) => console.log(s.account.email)}
    />
  );
}

the call

import { createClient } from "loginwithchatgpt";

// billed to the user's ChatGPT subscription — no API key
const text = await createClient().respond("Summarize this thread");

How it works

01

User clicks the button

They sign in with their own ChatGPT account through OpenAI's Codex OAuth flow.

02

Token stored, encrypted

Their subscription token is saved with AES-256-GCM, keyed from the OS keychain.

03

AI runs on their plan

Every call bills the user's ChatGPT subscription. You never pay OpenAI for usage.

Why it's nice

No API bill

Costs scale with users — for them, not you. Each user funds their own AI.

Three login flows

Loopback for desktop, device-code for web, headless paste for SSH and CI.

Encrypted by default

Tokens encrypted at rest, auto-refreshed on expiry and 401. Swap the store in one line.

One package, three entries

Headless engine, a React button, and Next.js route handlers. Install once.

Ship AI without the bill

Your users already pay for ChatGPT. Let them bring it into your app.