Intel·ligència artificial Codex OpenAI OAuth Seguretat

El suposat forat de 3.000 milions d’OpenAI: què fa realment OpenAI OAuth

OpenAI OAuth converteix l’accés de Codex en una interfície semblant a l’API. Expliquem com funciona, per què no és una API gratuïta oficial i quins riscos comporta.

El vídeo d’Evan Zhou presenta OpenAI OAuth, un projecte no oficial que reutilitza l’inici de sessió de Codex per oferir una interfície semblant a l’API d’OpenAI. El titular parla d’un “forat de 3.000 milions de dòlars” i d’una API gratuïta que OpenAI no podria bloquejar.

La demostració és tècnicament interessant, però aquestes dues conclusions van molt més enllà del que prova. El projecte no crea una API oficial gratuïta: construeix un pont sobre credencials de ChatGPT i un servei intern destinat a Codex. L’ús continua limitat pel pla, exposa credencials molt sensibles i pot entrar en conflicte amb les condicions d’OpenAI.

Dues formes oficials d’autenticar Codex

La documentació oficial separa clarament dues vies:

  • Iniciar sessió amb ChatGPT, perquè Codex utilitzi l’accés i els límits inclosos en el pla o espai de treball.
  • Iniciar sessió amb una clau d’API, amb facturació per ús a l’organització de l’OpenAI Platform.

La primera via està pensada per a les superfícies de Codex: l’aplicació d’escriptori, el CLI i l’extensió de l’IDE. La segona és la ruta estàndard per a automatitzacions i integracions que fan crides generals a l’API.

Quan una persona inicia sessió amb ChatGPT al CLI, el navegador retorna unes credencials OAuth al client local. Codex les renova automàticament i les utilitza per accedir als models permesos pel seu pla. Això no converteix les credencials en una clau d’API transferible.

Què fa el projecte openai-oauth

El creador observa que Codex és de codi obert i identifica com autentica les peticions al servei de Codex. A partir d’aquí construeix una capa de compatibilitat que:

  1. llegeix o obté una sessió OAuth de ChatGPT;
  2. envia les peticions al servei utilitzat per Codex;
  3. afegeix els identificadors i capçaleres que aquest servei espera;
  4. tradueix la resposta a rutes amb una forma semblant a les API de Responses i Chat Completions;
  5. adapta la transmissió en temps real quan un client espera una resposta no transmesa.

En local, el pont pot reutilitzar la sessió que ja té el CLI. Per a aplicacions web, el projecte afegeix una extensió de navegador que intervé en el retorn OAuth i entrega credencials vinculades a la petició de l’usuari.

Aquesta arquitectura és el nucli real de la demostració. No elimina el cost de computació ni concedeix crèdits de l’OpenAI Platform. Converteix temporalment un dret d’ús de Codex en una interfície que altres clients poden entendre.

No és una clau d’API oficial

La diferència és important per a qualsevol desenvolupador:

  • només hi ha els models i capacitats que el compte pot utilitzar a Codex;
  • continuen aplicant-se els límits del pla de ChatGPT;
  • el servei intern pot tenir una semàntica diferent de l’API pública;
  • la compatibilitat depèn d’un pont comunitari;
  • no hi ha el mateix contracte d’estabilitat, facturació ni suport que amb l’OpenAI Platform.

El mateix repositori reconeix que és un projecte comunitari, no afiliat ni avalat per OpenAI. També enumera limitacions: l’accés varia segons el pla i la seva implementació de Responses és sense estat, de manera que el client ha de reenviar l’historial.

OpenAI realment “no ho pot aturar”?

No. El fet que Codex necessiti autenticar-se no impedeix que OpenAI modifiqui el protocol, els àmbits OAuth, les comprovacions del servidor o les polítiques d’accés. Podria fer aquests canvis alhora que actualitza els seus clients oficials.

També pot aplicar límits, detectar patrons abusius i suspendre comptes quan considera que s’han incomplert les condicions. Una eina pot funcionar avui i deixar de fer-ho després d’un canvi tècnic o contractual.

L’afirmació del vídeo s’ha d’interpretar de manera més estreta: bloquejar cegament totes les peticions al servei intern trencaria el Codex oficial. Això no equival a dir que OpenAI sigui incapaç de distingir clients, restringir usos o redissenyar l’autenticació.

El risc contractual no és secundari

Les condicions d’ús d’OpenAI prohibeixen, entre altres coses, intentar fer enginyeria inversa dels serveis, extreure dades o resultats automàticament i eludir límits o mesures de protecció. També impedeixen compartir credencials o posar el compte a disposició d’una altra persona.

L’acord de serveis per a empreses conté restriccions semblants: no permet eludir límits d’ús, configurar els serveis per evitar-los ni transferir claus a tercers.

No tota integració alternativa és necessàriament el mateix que eludir un límit, i la interpretació concreta correspondria a les parts i, si cal, a assessorament legal. Però descriure el projecte com una “API gratuïta” sense aquest context és imprudent. El mateix autor afegeix al repositori que cada usuari ha de complir les condicions aplicables, mantenir les credencials privades i no compartir ni redistribuir tokens.

Les credencials són equivalents a una contrasenya

El projecte afirma que les credencials web queden xifrades al dispositiu i que el flux inicial és local. Tot i així, una extensió de navegador capaç d’interceptar el retorn OAuth ocupa una posició de confiança molt elevada.

Abans d’usar una eina així caldria auditar:

  • el codi exacte de l’extensió i la versió instal·lada;
  • els permisos del navegador i els dominis que pot llegir;
  • on es desen i com es renoven els tokens;
  • si les credencials arriben al servidor de l’aplicació en fer una petició;
  • com es poden revocar i quins registres en conserva el servidor;
  • el risc que una dependència o actualització futura canviï el comportament.

No s’hauria d’exposar el pont local a Internet ni reutilitzar una sessió personal en una aplicació pública. Un token robat podria consumir els límits del compte, accedir a capacitats vinculades a l’espai de treball o provocar-ne la suspensió.

D’on surt la xifra dels 3.000 milions

El vídeo afirma que OpenAI ingressa gairebé 3.000 milions de dòlars anuals amb l’API, però no n’identifica la font. OpenAI és una empresa privada i les xifres públiques acostumen a agrupar ChatGPT, productes empresarials i API.

OpenAI va informar que havia superat els 20.000 milions de dòlars d’ingressos anualitzats el 2025 i que, el 2026, l’activitat empresarial representava més del 40% dels ingressos. Cap d’aquestes publicacions ofereix un desglossament auditat que permeti atribuir exactament 3.000 milions a l’API.

Encara menys es pot concloure que el projecte costaria aquesta quantitat. La demanda que passaria d’una API de pagament a una subscripció no és coneguda; hi ha límits d’ús, models diferents i molts clients necessiten garanties que un servei intern no ofereix.

Subscripció i API no tenen el mateix producte econòmic

El vídeo diu que una inferència dins de ChatGPT i una crida d’API tenen “exactament el mateix cost”. Això tampoc està demostrat. Poden utilitzar models, rutes, memòria cau, límits, prioritats i controls diferents. A més del càlcul, el preu de l’API cobreix estabilitat contractual, eines, administració, observabilitat i un model de servei pensat per integrar-se en productes.

Una subscripció reparteix el cost entre usuaris i imposa límits; una API factura el consum d’una aplicació que pot créixer de manera molt diferent. Comparar només la quota mensual amb els tokens consumits omet aquesta estructura.

Quines vies sí estan documentades

Per a una aplicació general, la recomanació oficial continua sent utilitzar una clau de l’OpenAI Platform i les API públiques. Per automatitzar Codex, OpenAI documenta el seu SDK i l’app-server; en entorns Enterprise també existeixen tokens d’accés de Codex per a scripts i executors privats de confiança.

Aquestes opcions no són gratuïtes, però tenen un àmbit, permisos i suport definits. També permeten revocar credencials sense dependre d’un pont que imita una interfície diferent.

Una prova interessant, no un “forat” quantificat

OpenAI OAuth demostra que un client obert permet entendre i adaptar la comunicació entre Codex i el seu servei. És un bon exemple de com una capa de compatibilitat pot transformar una interfície.

No demostra que hi hagi 3.000 milions en risc, que la subscripció autoritzi qualsevol ús com si fos l’API ni que OpenAI no pugui intervenir. La conclusió més precisa és aquesta: el projecte funciona aprofitant credencials i serveis destinats a Codex, però la seva estabilitat, seguretat i legitimitat contractual no equivalen a les d’una API oficial.

Contrast i context

Fonts consultades

7 fonts
  1. 01
  2. 02
  3. 03
  4. 04
  5. 05
  6. 06
  7. 07

Font de treball

Transcripció amb marques de temps

10 fragments
Consulta la transcripció
  1. 0:00 , obre el vídeo en una pestanya nova

    This button gives you free AI from OpenAI in any app, and it can literally cost OpenAI billions of dollars per year, which is exactly why I open-sourced it so that by the end of this video, you too will be able to instantly get free OpenAI API, and not only that, due to the way it works, OpenAI can do nothing to stop me. Let me explain. If you want to use OpenAI's AI in any app, you need an API key with every request costing [music] money. In fact, OpenAI makes nearly $3 billion off their API each year. But, there's an obvious exception. You can use ChatGPT and other products by OpenAI themselves for free. And with a subscription, you can use far more AI than you can with the same cost in API. The reason, of course, is that they lure you in and trap you into using their product. But, ironically, this pricing difference between a ChatGPT account and API isn't quite so open, especially given the fact that it's the same [music] compute and

  2. 0:50 , obre el vídeo en una pestanya nova

    exact same cost for OpenAI to run a model in their product or with an API key. So, I always wondered, what [music] if we could turn your ChatGPT account into an API that you can use anywhere? A single sign-in with ChatGPT button [music] that would become OpenAI's billion-dollar button that they definitely don't want you to have. Now, the obvious solution to achieve this is to reverse engineer chat.openai.com, where you can essentially access free AI with your account. You would have to figure out how they store your login credentials and then intercept network requests to see how those credentials are used to authenticate the internal ChatGPT endpoint that the website uses. I would know this because over 3 years ago, I had to reverse-engineer Google AI SDK that used this path before Google even had an API. But, from that, I learned that not only are those [music] credentials unstable, meaning that you would have to constantly update them

  3. 1:35 , obre el vídeo en una pestanya nova

    manually, the internal ChatGPT endpoint is also highly abstracted, meaning that you can't do things like add custom tools or get direct access to the transcript. But, ChatGPT is just one of OpenAI's products. Looking at the selection of all the other products that we can approach and try to reverse-engineer to achieve our goal, the choice becomes obvious: Codex CLI. Like other products, it allows you to log in with your ChatGPT account to use AI. But, unlike other products, it's open source, which means that not only could we easily reverse engineer and replicate their authentication pattern, their API also has to be stable, documented, and feature-rich because the same maintain shipping product OpenAI is constantly updating. Exactly the type of API that we would want to reverse engineer. But, the best part about this is that OpenAI can't block access on this Codex API without breaking Codex itself, meaning that they can't stop you

  4. 2:23 , obre el vídeo en una pestanya nova

    on a technical level from using this endpoint. And even on a practical level, OpenAI has essentially said multiple times that they are okay with using alternate harnesses with a Codex subscription. And this is simply a generalization of that. So, we're good to dig in. The way it works is simple. Codex stores a special set of OAuth-based credentials, which you use to authenticate your requests to an internal endpoint instead of an API key. Since we can simply look at the code, it's trivial to find the exact logic to use those credentials to make requests. We could then build a bridge from that internal endpoint to a standard OpenAI API interface. And while there were some limitations with the Codex internal API, we could hide many of these things within our bridge. For example, Codex's endpoint requires special headers and identifiers. Our bridge can inject those for you. Codex also only supports streaming requests. So, our bridge can

  5. 3:10 , obre el vídeo en una pestanya nova

    stream under the hood and return a non-streaming request if you need it. But, of course, there were other limitations that we simply couldn't work around, such as the fact that even though this works on a free plan, you are still subject to rate limits, or the fact that the models you have access to also varies based on your plan. Nonetheless, just like that, OpenAI themselves had essentially just handed us the ability to turn a ChatGPT account into a free API key. And believe it or not, you can literally try this out right now by typing NPX OpenAI-OAuth into your terminal. It'll take your free or paid ChatGPT account, and using my specially designed bridge, turn it into a free OpenAI API. But, even with that, we're only halfway done because so far, we've only handled using credentials we already have on the user's device. Where it gets really interesting is getting those credentials in the first place, which can enable users beyond developers

  6. 3:59 , obre el vídeo en una pestanya nova

    with Code X CLI to replace their API keys. But to understand why this is so difficult and significant, we have to start back at Code X CLI, reverse engineering how users sign in. It's a pretty standard OAuth flow. When a client device begins sign in, it starts listening at a special localhost port, 1455. Then it sends you to OpenAI's website, on which you can log in to your account. Most importantly, when you're done, sends those credentials back to the localhost [music] 1455 port from the beginning, so that the client device that initialized the request can use those credentials to make requests just like we have done. Since we have Code X's source, it's trivial to figure out the special OAuth URL needed to initialize the authentication and replicate it locally on the user's computer. We simply have to start a service at 1455, and the rest is straightforward. But now, let's take it a step further. How can we make the sign

  7. 4:45 , obre el vídeo en una pestanya nova

    in flow work in even a browser, so that any user, anywhere, can instantly log in with their ChatGPT account to any website? Something that would allow not only developers, but users all around the world to [music] ditch API keys altogether. The issue though is that OpenAI's OAuth flow only returns credentials to localhost 1455, and a normal browser tab can't read localhost, much less open a service on a port to read those credentials. So natural next step is to have a server on the cloud, which has access to its own localhost and can handle the OAuth flow there. But things quickly fall apart. First, the server doesn't have your OpenAI account. So you have to use OpenAI's device code authentication, which allows you to authenticate into a remote device using a one-time code. But this also requires you to turn on a setting in your ChatGPT account, which is rather annoying and feels like a loss of trust. And that aside, if you just think about it, this

  8. 5:35 , obre el vídeo en una pestanya nova

    is essentially giving away your ChatGPT account to some random third-party server, which I personally would never want to do. So, seems like we are at a dead end. [music] An external server is dangerous, and browser tabs can't interact with localhost unless we accept one trade-off. [music] Browser tabs can't interact with localhost. But, what about the browser itself? You see, browser extensions, which can tap into the capability of the browser itself, can open and thus read existing localhost websites. But, even an extension can't create a service that runs on a localhost 1455 to await credentials. However, what if we don't need to? You see, the purpose of that server is to capture credentials from a remote service locally. But, when OpenAI makes the request to localhost, that request itself already has the authentication data that we need. [music] So, all our extension has to do is to intercept that request and

  9. 6:22 , obre el vídeo en una pestanya nova

    redirect the credentials back to the website that is trying to sign in, instead of ever having to deal with localhost directly. And with a completely open source and local browser extension, we can do this directly between your browser and OpenAI. No credentials leave your system during the sign-in flow, and no need to change any ChatGPT settings. And to make it easy, [music] the first time you use the sign-in flow, it takes you directly to the Chrome Web Store so that there is no friction. Now, we can store these credentials locally, encrypted in browser storage at rest, only used to make [music] API requests through the same bridge that we talked about minutes ago, completing the circuit. And just like that, we've just managed to authenticate an OpenAI account to make requests as if it were an API key. This is OpenAI's [music] billion-dollar button, and I just made it open source. Getting started is simple. With the set

  10. 7:07 , obre el vídeo en una pestanya nova

    of OpenAI OAuth libraries, you can set up the sign-in button with just one React component and connect it to any OpenAI compatible SDK, like the Vercel AI SDK. My vision is that frontier intelligence is accessible to more people, [music] and not just in apps that the labs want you to use. With sign-in with ChatGPT, that is easier than ever. If you want to try it out, a demo sign-in with ChatGPT is available on Vercel at openai-oauth.vercel.app. [music] And you can always get started locally by just running MPX openai-oauth. Feel free to contribute or leave any feedback or issues at github.com/evanjodav/openai-oauth. If you integrate OpenAI OAuth into any apps, please share your creation on X and tag me @EvanJoeDev. I'd be happy to see what everyone is building. Usage of OpenAI OAuth is still subject to OpenAI's terms of use and other user agreements. I'll see you guys next time. Peace.