@yan06/openai-oauth-local
v2.0.2
Published
Local Codex auth-file auth handle for openai-oauth.
Maintainers
Readme
@yan06/openai-oauth-local
Access your ChatGPT account directly from TypeScript on your machine.
npm i @yan06/openai-oauth-localQuickstart:
import { openaiCredentials } from "@yan06/openai-oauth-local";
const credentials = openaiCredentials();Use it with a client adapter:
import { createOpenAIOAuth } from "@yan06/openai-oauth-ai-sdk";
import { openaiCredentials } from "@yan06/openai-oauth-local";
import { generateText } from "ai";
const openai = createOpenAIOAuth(openaiCredentials());
const result = await generateText({
model: openai("gpt-5.4-mini"),
prompt: "Hello!",
});Package Notes
@yan06/openai-oauth-local reads local Codex credentials from your machine.
By default, it checks the same auth locations used by the CLI, including ~/.codex/auth.json.
If you are not signed in locally, run:
npx @yan06/openai-oauth loginYou can also point to a specific auth file:
const credentials = openaiCredentials({
authFilePath: "/path/to/auth.json",
});Useful options:
type LocalOpenAIOAuthOptions = {
authFilePath?: string;
clientId?: string;
issuer?: string;
tokenUrl?: string;
ensureFresh?: boolean;
fetch?: typeof fetch;
now?: () => Date;
baseURL?: string;
headers?: Record<string, string>;
instructions?: string;
openAIBaseURL?: string;
};openaiCredentials() returns an OpenAIOAuth credential source that can be passed to any OpenAI OAuth client adapter.
