I Found OpenAI’s $3B Loophole — Transcript
Full transcript
- 0:00This button gives you free AI from
- 0:02OpenAI in any app, and it can literally
- 0:04cost OpenAI billions of dollars per
- 0:06year, which is exactly why I
- 0:08open-sourced it so that by the end of
- 0:10this video, you too will be able to
- 0:11instantly get free OpenAI API, and not
- 0:14only that, due to the way it works,
- 0:15OpenAI can do nothing to stop me. Let me
- 0:18explain. If you want to use OpenAI's AI
- 0:20in any app, you need an API key with
- 0:22every request costing [music] money. In
- 0:24fact, OpenAI makes nearly $3 billion off
- 0:27their API each year. But, there's an
- 0:29obvious exception. You can use ChatGPT
- 0:31and other products by OpenAI themselves
- 0:33for free. And with a subscription, you
- 0:35can use far more AI than you can with
- 0:37the same cost in API. The reason, of
- 0:39course, is that they lure you in and
- 0:41trap you into using their product. But,
- 0:42ironically, this pricing difference
- 0:44between a ChatGPT account and API isn't
- 0:46quite so open, especially given the fact
- 0:49that it's the same [music] compute and
- 0:50exact same cost for OpenAI to run a
- 0:52model in their product or with an API
- 0:54key. So, I always wondered, what [music]
- 0:56if we could turn your ChatGPT account
- 0:58into an API that you can use anywhere? A
- 1:00single sign-in with ChatGPT button
- 1:02[music] that would become OpenAI's
- 1:04billion-dollar button that they
- 1:05definitely don't want you to have. Now,
- 1:07the obvious solution to achieve this is
- 1:09to reverse engineer chat.openai.com,
- 1:11where you can essentially access free AI
- 1:13with your account. You would have to
- 1:14figure out how they store your login
- 1:15credentials and then intercept network
- 1:17requests to see how those credentials
- 1:18are used to authenticate the internal
- 1:20ChatGPT endpoint that the website uses.
- 1:22I would know this because over 3 years
- 1:24ago, I had to reverse-engineer Google AI
- 1:26SDK that used this path before Google
- 1:28even had an API. But, from that, I
- 1:30learned that not only are those [music]
- 1:31credentials unstable, meaning that you
- 1:33would have to constantly update them
- 1:35manually, the internal ChatGPT endpoint
- 1:37is also highly abstracted, meaning that
- 1:39you can't do things like add custom
- 1:41tools or get direct access to the
- 1:42transcript. But, ChatGPT is just one of
- 1:45OpenAI's products. Looking at the
- 1:47selection of all the other products that
- 1:48we can approach and try to
- 1:49reverse-engineer to achieve our goal,
- 1:51the choice becomes obvious: Codex CLI.
- 1:54Like other products, it allows you to
- 1:55log in with your ChatGPT account to use
- 1:57AI. But, unlike other products, it's
- 1:59open source, which means that not only
- 2:01could we easily reverse engineer and
- 2:03replicate their authentication pattern,
- 2:05their API also has to be stable,
- 2:07documented, and feature-rich because the
- 2:09same maintain shipping product OpenAI is
- 2:11constantly updating. Exactly the type of
- 2:14API that we would want to reverse
- 2:15engineer. But, the best part about this
- 2:17is that OpenAI can't block access on
- 2:19this Codex API without breaking Codex
- 2:21itself, meaning that they can't stop you
- 2:23on a technical level from using this
- 2:25endpoint. And even on a practical level,
- 2:28OpenAI has essentially said multiple
- 2:29times that they are okay with using
- 2:31alternate harnesses with a Codex
- 2:33subscription. And this is simply a
- 2:34generalization of that. So, we're good
- 2:36to dig in. The way it works is simple.
- 2:38Codex stores a special set of
- 2:40OAuth-based credentials, which you use
- 2:42to authenticate your requests to an
- 2:44internal endpoint instead of an API key.
- 2:46Since we can simply look at the code,
- 2:47it's trivial to find the exact logic to
- 2:49use those credentials to make requests.
- 2:51We could then build a bridge from that
- 2:52internal endpoint to a standard OpenAI
- 2:55API interface. And while there were some
- 2:57limitations with the Codex internal API,
- 2:59we could hide many of these things
- 3:01within our bridge. For example, Codex's
- 3:03endpoint requires special headers and
- 3:05identifiers. Our bridge can inject those
- 3:07for you. Codex also only supports
- 3:09streaming requests. So, our bridge can
- 3:10stream under the hood and return a
- 3:11non-streaming request if you need it.
- 3:13But, of course, there were other
- 3:14limitations that we simply couldn't work
- 3:16around, such as the fact that even
- 3:17though this works on a free plan, you
- 3:19are still subject to rate limits, or the
- 3:21fact that the models you have access to
- 3:23also varies based on your plan.
- 3:25Nonetheless, just like that, OpenAI
- 3:27themselves had essentially just handed
- 3:29us the ability to turn a ChatGPT account
- 3:31into a free API key. And believe it or
- 3:33not, you can literally try this out
- 3:35right now by typing NPX OpenAI-OAuth
- 3:38into your terminal. It'll take your free
- 3:40or paid ChatGPT account, and using my
- 3:42specially designed bridge, turn it into
- 3:44a free OpenAI API. But, even with that,
- 3:47we're only halfway done because so far,
- 3:49we've only handled using credentials we
- 3:51already have on the user's device. Where
- 3:53it gets really interesting is getting
- 3:55those credentials in the first place,
- 3:57which can enable users beyond developers
- 3:59with Code X CLI to replace their API
- 4:01keys. But to understand why this is so
- 4:03difficult and significant, we have to
- 4:05start back at Code X CLI, reverse
- 4:07engineering how users sign in. It's a
- 4:10pretty standard OAuth flow. When a
- 4:11client device begins sign in, it starts
- 4:13listening at a special localhost port,
- 4:151455. Then it sends you to OpenAI's
- 4:17website, on which you can log in to your
- 4:19account. Most importantly, when you're
- 4:20done, sends those credentials back to
- 4:22the localhost [music] 1455 port from the
- 4:24beginning, so that the client device
- 4:26that initialized the request can use
- 4:27those credentials to make requests just
- 4:29like we have done. Since we have Code
- 4:30X's source, it's trivial to figure out
- 4:32the special OAuth URL needed to
- 4:34initialize the authentication and
- 4:36replicate it locally on the user's
- 4:37computer. We simply have to start a
- 4:39service at 1455, and the rest is
- 4:41straightforward. But now, let's take it
- 4:42a step further. How can we make the sign
- 4:45in flow work in even a browser, so that
- 4:48any user, anywhere, can instantly log in
- 4:50with their ChatGPT account to any
- 4:52website? Something that would allow not
- 4:54only developers, but users all around
- 4:56the world to [music] ditch API keys
- 4:58altogether. The issue though is that
- 5:00OpenAI's OAuth flow only returns
- 5:02credentials to localhost 1455, and a
- 5:04normal browser tab can't read localhost,
- 5:07much less open a service on a port to
- 5:09read those credentials. So natural next
- 5:10step is to have a server on the cloud,
- 5:12which has access to its own localhost
- 5:14and can handle the OAuth flow there. But
- 5:16things quickly fall apart. First, the
- 5:18server doesn't have your OpenAI account.
- 5:20So you have to use OpenAI's device code
- 5:22authentication, which allows you to
- 5:24authenticate into a remote device using
- 5:26a one-time code. But this also requires
- 5:28you to turn on a setting in your ChatGPT
- 5:30account, which is rather annoying and
- 5:32feels like a loss of trust. And that
- 5:33aside, if you just think about it, this
- 5:35is essentially giving away your ChatGPT
- 5:37account to some random third-party
- 5:38server, which I personally would never
- 5:41want to do. So, seems like we are at a
- 5:43dead end. [music] An external server is
- 5:44dangerous, and browser tabs can't
- 5:46interact with localhost unless we accept
- 5:48one trade-off. [music] Browser tabs
- 5:50can't interact with localhost. But, what
- 5:52about the browser itself? You see,
- 5:54browser extensions, which can tap into
- 5:56the capability of the browser itself,
- 5:57can open and thus read existing
- 6:00localhost websites. But, even an
- 6:01extension can't create a service that
- 6:03runs on a localhost 1455 to await
- 6:06credentials. However, what if we don't
- 6:08need to? You see, the purpose of that
- 6:10server is to capture credentials from a
- 6:11remote service locally. But, when OpenAI
- 6:14makes the request to localhost, that
- 6:16request itself already has the
- 6:17authentication data that we need.
- 6:19[music] So, all our extension has to do
- 6:20is to intercept that request and
- 6:22redirect the credentials back to the
- 6:23website that is trying to sign in,
- 6:25instead of ever having to deal with
- 6:27localhost directly. And with a
- 6:28completely open source and local browser
- 6:31extension, we can do this directly
- 6:32between your browser and OpenAI. No
- 6:34credentials leave your system during the
- 6:36sign-in flow, and no need to change any
- 6:38ChatGPT settings. And to make it easy,
- 6:40[music] the first time you use the
- 6:41sign-in flow, it takes you directly to
- 6:43the Chrome Web Store so that there is no
- 6:45friction. Now, we can store these
- 6:46credentials locally, encrypted in
- 6:47browser storage at rest, only used to
- 6:49make [music] API requests through the
- 6:51same bridge that we talked about minutes
- 6:52ago, completing the circuit. And just
- 6:54like that, we've just managed to
- 6:55authenticate an OpenAI account to make
- 6:57requests as if it were an API key. This
- 7:00is OpenAI's [music] billion-dollar
- 7:02button, and I just made it open source.
- 7:05Getting started is simple. With the set
- 7:07of OpenAI OAuth libraries, you can set
- 7:08up the sign-in button with just one
- 7:10React component and connect it to any
- 7:12OpenAI compatible SDK, like the Vercel
- 7:15AI SDK. My vision is that frontier
- 7:17intelligence is accessible to more
- 7:19people, [music] and not just in apps
- 7:20that the labs want you to use. With
- 7:22sign-in with ChatGPT, that is easier
- 7:25than ever. If you want to try it out, a
- 7:26demo sign-in with ChatGPT is available
- 7:28on Vercel at openai-oauth.vercel.app.
- 7:31[music] And you can always get started
- 7:32locally by just running MPX
- 7:34openai-oauth.
- 7:36Feel free to contribute or leave any
- 7:37feedback or issues at
- 7:38github.com/evanjodav/openai-oauth.
- 7:42If you integrate OpenAI OAuth into any
- 7:44apps, please share your creation on X
- 7:46and tag me @EvanJoeDev. I'd be happy to
- 7:48see what everyone is building. Usage of
- 7:50OpenAI OAuth is still subject to
- 7:52OpenAI's terms of use and other user
- 7:53agreements. I'll see you guys next time.
- 7:56Peace.
About this transcript
This page contains the full transcript of I Found OpenAI’s $3B Loophole by Evan Zhou, generated from the public captions YouTube serves with the video. The transcript has 1,641 words across 251 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.