Playground

A live demo, on the SDK itself

This page uses loginwithchatgpt for real. It runs the device-code flow, so it works right here in the browser — connect your ChatGPT account and the call bills your own subscription.

First time? Enable device code authorization in ChatGPT → Settings → Security & Login.

Live demoNot connected
Connect first to run a call.

start the flow

// app/api/chatgpt/device/route.ts
import { deviceStart } from "loginwithchatgpt";

export const runtime = "nodejs";
export async function POST() {
  return Response.json(await deviceStart());
}

poll for the token

// app/api/chatgpt/poll/route.ts
import { devicePoll } from "loginwithchatgpt";

const result = await devicePoll(deviceAuthId, userCode);
// "pending" until the user enters the code, then { tokens }