openai-oauth-provider
v1.0.3
Published
Vercel AI SDK Provider for Free OpenAI API access with your ChatGPT account.
Readme
openai-oauth-provider
Vercel AI SDK provider that uses your ChatGPT account.
Usage
import { generateText } from "ai"
import { createOpenAIOAuth } from "openai-oauth-provider"
const openai = createOpenAIOAuth({
authFilePath: "/path/to/auth.json",
})
const result = await generateText({
model: openai("gpt-5.4"),
prompt: "Reply with exactly: hello",
})
console.log(result.text)Configuration
createOpenAIOAuth(...) accepts:
| Config | Provider | Default | Description |
| --- | --- | --- | --- |
| Upstream base URL | baseURL | https://chatgpt.com/backend-api/codex | Override the upstream Codex base URL. |
| Codex API version | codexVersion | Local codex --version, then @openai/codex latest from npm, then 0.111.0 | Override the Codex API client version used for model discovery. This mainly matters for CLI-style model catalog lookups, but the provider accepts it for config parity. |
| OAuth client id | clientId | app_EMoamEEZ73f0CkXaXp7hrann | Override the OAuth client id used for refresh. |
| OAuth token URL | tokenUrl | https://auth.openai.com/oauth/token | Override the OAuth token URL used for refresh. |
| Auth file path | authFilePath | authFilePath if provided, otherwise $CHATGPT_LOCAL_HOME/auth.json, $CODEX_HOME/auth.json, ~/.chatgpt-local/auth.json, ~/.codex/auth.json | Override where the local OAuth auth file is discovered. |
| Ensure fresh tokens | ensureFresh | true | Control whether access tokens are refreshed automatically. |
| Provider name | name | openai | Override the provider name exposed to Vercel AI SDK internals. |
Features
- Direct Codex-backed Vercel AI SDK provider
- No localhost proxy hop
- Shared OAuth token loading and refresh
- Streaming text
- Tool calls
- Responses-style models such as
gpt-5.4
Known Missing
- Built-in login flow
You still need local auth generated by
npx @openai/codex login. - Hosted Vercel usage with local auth discovery This provider is designed for environments where your auth file is actually available.
- Embedding models
- Image models
Legal
This is an unofficial, community-maintained project and is not affiliated with, endorsed by, or sponsored by OpenAI, Inc.
It uses your local Codex/ChatGPT authentication cache (auth.json, e.g. ~/.codex/auth.json) and should be treated like password-equivalent credentials.
Use only for personal, local experimentation on trusted machines; do not run as a hosted service, do not share access, and do not pool or redistribute tokens.
You are solely responsible for complying with OpenAI’s Terms, policies, and any applicable agreements; misuse may result in rate limits, suspension, or termination.
Provided “as is” with no warranties; you assume all risk for data exposure, costs, and account actions.
