Introducing OpenAI OAuth v2. Free AI with your ChatGPT account, from localhost to production.
What's new in v2?
- Sign in with ChatGPT: Let your users bring their own free or paid ChatGPT accounts for AI. Try it out on Vercel.
- Image Generation: Generate and edit images with GPT Image 2 with OpenAI OAuth (Paid ChatGPT plans only)
- GPT-5.6: OpenAI OAuth now automatically gets the latest models the second they're available
- Detached Mode in CLI: Let
npx openai-oauthrun in the background with--detach
Other Improvements
- CLI Login: Run
npx openai-oauth loginto log in right from the terminal - Credential Sources: Source credentials from user sign-in, your local machine, or your own implementation
- Client Adapters: Use OpenAI OAuth with Vercel AI SDK, the OpenAI client, or any OpenAI-compatible client
- Apache-2.0 License: Use OpenAI OAuth in both open-source and proprietary applications
And more!
Quickstart
If you're only using the CLI, updating is as easy as putting @latest at the end of npx openai-oauth.
$ npx openai-oauth@latest
OpenAI-compatible endpoint ready at http://127.0.0.1:10531/v1
Use this as your OpenAI base URL. No API key is required.
Available Models: gpt-5.6-sol, gpt-5.6-terra, ...
Simply press d to detach and keep it running in the background. Or start in detached mode with the --detach flag.
TypeScript SDK
But now, there's more to OpenAI OAuth. Here's how you can easily use your local credentials to run the Vercel AI SDK:
npm i @openai-oauth/local @openai-oauth/ai-sdk aiimport { createOpenAIOAuth } from "@openai-oauth/ai-sdk";
import { openaiCredentials } from "@openai-oauth/local";
import { generateText } from "ai";
const openai = createOpenAIOAuth(openaiCredentials());
const result = await generateText({
model: openai("gpt-5.4-mini"),
prompt: "Hello!",
});And now, you can even generate images through the same provider:
import { generateImage } from "ai";
const result = await generateImage({
model: openai.image("gpt-image-2"),
prompt: "A tiny house in a forest",
});Migrating from openai-oauth-provider
Vercel AI SDK integration is now independent of your credential source. openai-oauth-provider will soon be deprecated, and the preferred route for using local credentials with the Vercel AI SDK is shown in the example above.
You now import and provide an extra openaiCredentials, either from @openai-oauth/local for local credentials as before or from another credential source.
Sign in with ChatGPT
OpenAI OAuth also now includes Sign in with ChatGPT, allowing your users to bring their own ChatGPT accounts to power AI experiences on your app. Getting started is as simple as one React component.
npm i @openai-oauth/react"use client";
import { SignInWithChatGPT } from "@openai-oauth/react";
export default function Page() {
return <SignInWithChatGPT />;
}See the complete web setup to make authenticated AI requests.
Learn More
Get started with OpenAI OAuth v2 today with documentation and more on GitHub.