The `ai-sdk-provider-codex-cli` package offers a community-maintained integration for Vercel's AI SDK v6, enabling access to OpenAI's Codex CLI and its GPT-5 class models (e.g., `gpt-5.1`, `gpt-5.2`, `gpt-5.3-codex`, `gpt-5.2-codex-max`) using an existing ChatGPT Plus/Pro subscription. Currently at version 1.1.0, the library is actively developed, with recent releases focusing on AI SDK v6 compatibility and new features like the `createCodexAppServer` persistent JSON-RPC client. It provides two primary modes: `codexExec` for a new process per call, and `createCodexAppServer` for a long-lived process with advanced session controls like `injectMessage` and `interrupt`. This Node-only provider works with `generateText`, `streamText`, and `generateObject` functions, and authenticates via `codex login` or `OPENAI_API_KEY`. Its key differentiator is leveraging the local Codex CLI for direct, granular control over model execution and sandboxing, providing an alternative to direct API integrations for users with existing ChatGPT subscriptions.
npm install ai-sdk-provider-codex-cliVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the `codexExec` provider with `generateText` to get a simple text response from a GPT-5 class model, showing basic configuration and token usage.
Review the AI SDK v6 migration guide. Update your code to conform to the new `LanguageModelV3` interface, adapt `finishReason` checks from `'stop'` to `{ unified: 'stop', raw: undefined }`, and adjust usage metrics parsing for the new nested structure (e.g., `inputTokens.total`, `outputTokens.total`).Remove any `includePlanTool: true` or `false` settings from your provider configuration. The functionality is now implicit.
Ensure your global Codex CLI installation is up to date by running `npm i -g @openai/codex@latest` and verifying with `codex --version`. The optional `@openai/codex` dependency pulls a compatible version automatically, but a global install may need manual update.
For AI SDK v6 (default), install `ai-sdk-provider-codex-cli` with `npm i ai ai-sdk-provider-codex-cli`. For AI SDK v5, install `ai-sdk-provider-codex-cli@ai-sdk-v5 ai@^5.0.0`.
Upgrade to `ai-sdk-provider-codex-cli@1.0.5` or later. This version fixes the issue by passing prompts via stdin instead of command line arguments.
Upgrade to `ai-sdk-provider-codex-cli@1.0.4` or later (or `v0.7.3` for AI SDK v5). These versions add an explicit `'--'` separator before the prompt when images are present.
Upgrade to `ai-sdk-provider-codex-cli@1.0.3` or later (or `v0.7.2` for AI SDK v5). These versions correctly distinguish between JS entrypoints and native executables.