import { createOpenAI } from '@ai-sdk/openai'; import { A as Auth } from './types-BhMPRYcJ.js'; export { a as AuthState, D as DeviceAuthResult, T as TokenResponse, b as TokenStorage } from './types-BhMPRYcJ.js'; export { AuthenticateOptions, PollDeviceAuthOptions, authenticate, buildAuthState, decodeJwtPayload, exchangeCodeForTokens, extractAccountId, initiateDeviceAuth, pollDeviceAuth, refreshAccessToken, refreshAuthState } from './oauth/index.js'; export { FileStorage, LocalStorageTokenStorage, MemoryStorage } from './storage/index.js'; interface CodexOAuthSettings { /** * Authentication object returned by `authenticate()`. * Bundles the token state with optional persistent storage * so the provider can refresh and save tokens automatically. */ auth: Auth; /** App identifier sent in the `originator` header (default: "ai-sdk-codex-oauth") */ originator?: string; } /** * Provider function type — callable to get a language model, * with an explicit languageModel method. */ interface CodexOAuthProvider { /** * Create a language model for the given Codex model ID. * Throws if the model ID is not valid for the Codex backend. */ (modelId: string): ReturnType["responses"]>; /** * Explicit languageModel method (same as calling the provider directly). */ languageModel: CodexOAuthProvider; } /** * Create an AI SDK provider that authenticates with the ChatGPT Codex backend * using OAuth tokens. * * This wraps `@ai-sdk/openai`'s provider with a custom fetch middleware that * handles token injection, refresh, and Codex backend constraints. * * @example * ```ts * import { authenticate, createCodexOAuth } from "ai-sdk-codex-oauth"; * import { generateText } from "ai"; * * const auth = await authenticate({ * onUserCode: ({ userCode, verifyUrl }) => { * console.log(`Go to ${verifyUrl} and enter: ${userCode}`); * }, * }); * const codex = createCodexOAuth({ auth }); * * const { text } = await generateText({ * model: codex("gpt-5.3-codex"), * prompt: "Hello!", * }); * ``` */ declare function createCodexOAuth(settings: CodexOAuthSettings): CodexOAuthProvider; /** Models shown in documentation and UI */ declare const CODEX_MODELS: readonly ["gpt-5.3-codex", "gpt-5.2-codex", "gpt-5.1-codex-max", "gpt-5.1-codex-mini", "gpt-5.2"]; /** Hidden/legacy models that still work on the Codex backend */ declare const CODEX_LEGACY_MODELS: readonly ["gpt-5.1-codex", "gpt-5.1", "gpt-5-codex", "gpt-5", "gpt-5-codex-mini"]; type CodexModelId = (typeof CODEX_MODELS)[number] | (typeof CODEX_LEGACY_MODELS)[number]; /** * Validate that a model ID is available on the Codex backend. * Throws a descriptive error for invalid model IDs. */ declare function validateModelId(modelId: string): asserts modelId is CodexModelId; /** Codex backend base URL (append /responses for the Responses API) */ declare const CODEX_BASE_URL = "https://chatgpt.com/backend-api/codex"; /** Default model */ declare const DEFAULT_MODEL = "gpt-5.3-codex"; export { Auth, CODEX_BASE_URL, CODEX_LEGACY_MODELS, CODEX_MODELS, type CodexModelId, type CodexOAuthProvider, type CodexOAuthSettings, DEFAULT_MODEL, createCodexOAuth, validateModelId };