1
Add sign in
Let users connect their ChatGPT account.
"use client";
import { SignInWithChatGPT } from "@openai-oauth/react";
export default function App() {
return <SignInWithChatGPT />;
}Try it out
Works across free and paid plans.
Credentials are encrypted and
stored locally in this browser.
2
Use the AI SDK with the signed-in account.
"use client";
import { useCompletion } from "@ai-sdk/react";
import { openaiAuthHeaders } from "@openai-oauth/react";
const { completion, complete } = useCompletion({
api: "/api/chat",
streamProtocol: "text",
});
await complete("Hello!", {
headers: await openaiAuthHeaders(),
});Build with OpenAI OAuth
Add Sign in with ChatGPT to your product, start a
dev proxy, or connect through the TypeScript SDK.