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.

Requires a ChatGPT Plus or Pro subscription. First time? Enable device code login first: ChatGPT → Settings → Security & Login → Allow device code login.

Before you connect: device code login must be enabled in your ChatGPT account. Go to ChatGPT → Settings → Security & Login → Allow device code login and turn it on, then click the button below.
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 }