Openai-oauth
lastmod 2026-04-16created 2026-04-161 edits
Use the OpenAI API for free with a ChatGPT account
About
- Open source that uses the OAuth token of a ChatGPT account to let you use the OpenAI API without buying separate API credits
- A single line, npx openai-oauth, starts a local proxy server and immediately creates an OpenAI-compatible endpoint at http://127.0.0.1:10531/v1; usable right away without an API key
- Uses the same special endpoint that the OpenAI Codex CLI uses internally
- Supports the /v1/responses, /v1/chat/completions, and /v1/models endpoints; streaming, tool calls, and reasoning traces all work
- Also provided as a Vercel AI SDK Provider, so models can be called directly from TypeScript with createOpenAIOAuth()
- Only LLMs supported by Codex can be used. The model list is discovered automatically based on the account's Codex plan, and can also be specified manually with the --models option
- The CLI proxy is stateless, so the full conversation history must be sent with each call
- The login flow is intentionally not included in the bundle; you must run npx @openai/codex login to create the auth file
- Running it saves the token to ~/.codex/auth.json, and it is refreshed automatically afterward (ensureFresh defaults to true), so no need to worry about token expiry