docs/providers/codex-cli.md
The codex-cli provider integrates Task Master with OpenAI's Codex CLI via the community AI SDK provider ai-sdk-provider-codex-cli. It uses your ChatGPT subscription (OAuth) via codex login, with optional OPENAI_CODEX_API_KEY support.
The primary benefits of using the codex-cli provider include:
codex loginGet up and running with Codex CLI in 3 steps:
# 1. Install Codex CLI globally
npm install -g @openai/codex
# 2. Authenticate with your ChatGPT account
codex login
# 3. Configure Task Master to use Codex CLI
task-master models --set-main gpt-5-codex --codex-cli
# Check Node.js version
node --version
# Check Codex CLI version
codex --version
# Check Task Master version
task-master --version
# Install globally via npm
npm install -g @openai/codex
# Verify installation
codex --version
Expected output: v0.44.0 or higher
# Install globally
npm install -g task-master-ai
# Or install in your project
npm install --save-dev task-master-ai
The Codex CLI provider is designed to use OAuth authentication with your ChatGPT subscription:
# Launch Codex CLI and authenticate
codex login
This will:
To verify your authentication:
# Open interactive Codex CLI
codex
# Use /about command to see auth status
/about
While OAuth is the primary and recommended method, you can optionally use an OpenAI API key:
# In your .env file
OPENAI_CODEX_API_KEY=sk-your-openai-api-key-here
Important Notes:
openai provider insteadOPENAI_CODEX_API_KEY is specific to the codex-cli provider to avoid conflicts with the openai provider's OPENAI_API_KEYThe Codex CLI provider supports only models available through ChatGPT subscription:
| Model ID | Description | Max Input Tokens | Max Output Tokens | Reasoning Efforts |
|---|---|---|---|---|
gpt-5 | Latest GPT-5 model | 272K | 128K | - |
gpt-5-codex | GPT-5 optimized for agentic software engineering | 272K | 128K | - |
gpt-5.1 | GPT-5.1 with optional reasoning | 272K | 128K | none, low, medium, high |
gpt-5.1-codex-max | GPT-5.1 Codex Max with enhanced reasoning | 272K | 128K | none, low, medium, high, xhigh |
gpt-5.2 | Latest flagship model for coding and agentic tasks | 272K | 128K | none, low, medium, high, xhigh |
Note: These models are only available via OAuth subscription through Codex CLI (ChatGPT Plus, Pro, Business, Edu, or Enterprise plans). For other OpenAI models, use the standard openai provider with an API key.
Research Capabilities: All GPT-5 models support web search tools, making them suitable for the research role in addition to main and fallback roles.
Reasoning Effort: The gpt-5.1-codex-max and gpt-5.2 models support the xhigh reasoning effort level, which provides maximum reasoning capability for complex tasks. Configure via reasoningEffort in your codexCli settings.
Add Codex CLI to your .taskmaster/config.json:
{
"models": {
"main": {
"provider": "codex-cli",
"modelId": "gpt-5-codex",
"maxTokens": 128000,
"temperature": 0.2
},
"fallback": {
"provider": "codex-cli",
"modelId": "gpt-5",
"maxTokens": 128000,
"temperature": 0.2
}
}
}
The codexCli section allows you to customize Codex CLI behavior:
{
"models": {
"main": {
"provider": "codex-cli",
"modelId": "gpt-5-codex",
"maxTokens": 128000,
"temperature": 0.2
}
},
"codexCli": {
"allowNpx": true,
"skipGitRepoCheck": true,
"approvalMode": "on-failure",
"sandboxMode": "workspace-write",
"verbose": false
}
}
allowNpx (boolean, default: false)
npx @openai/codex if the CLI is not found on PATH"allowNpx": trueskipGitRepoCheck (boolean, default: false)
"skipGitRepoCheck": trueapprovalMode (string)
"untrusted": Require approval for all commands"on-failure": Only require approval after a command fails (default)"on-request": Approve only when explicitly requested"never": Never require approval (use with caution)"approvalMode": "on-failure"sandboxMode (string)
"read-only": Read-only access to filesystem"workspace-write": Allow writes to workspace directory (default)"danger-full-access": Full filesystem access (use with extreme caution)"sandboxMode": "workspace-write"codexPath (string, optional)
"codexPath": "/usr/local/bin/codex"cwd (string, optional)
"cwd": "/path/to/project"env (object, optional)
"env": { "DEBUG": "true" }fullAuto (boolean, optional)
--full-auto flag)"fullAuto": truedangerouslyBypassApprovalsAndSandbox (boolean, optional)
"dangerouslyBypassApprovalsAndSandbox": falsecolor (string, optional)
"always", "never", "auto""color": "auto"outputLastMessageFile (string, optional)
"outputLastMessageFile": "./last-message.txt"verbose (boolean, optional)
"verbose": trueOverride settings for specific Task Master commands:
{
"codexCli": {
"allowNpx": true,
"approvalMode": "on-failure",
"commandSpecific": {
"parse-prd": {
"approvalMode": "never",
"verbose": true
},
"expand": {
"sandboxMode": "read-only"
},
"add-task": {
"approvalMode": "untrusted"
}
}
}
}
# Set Codex CLI for main role
task-master models --set-main gpt-5-codex --codex-cli
# Set Codex CLI for fallback role
task-master models --set-fallback gpt-5 --codex-cli
# Set Codex CLI for research role
task-master models --set-research gpt-5 --codex-cli
# Verify configuration
task-master models
Once configured, use Task Master commands as normal:
# Parse a PRD with Codex CLI
task-master parse-prd my-requirements.txt
# Analyze project complexity
task-master analyze-complexity --research
# Expand a task into subtasks
task-master expand --id=1.2
# Add a new task with AI assistance
task-master add-task --prompt="Implement user authentication" --research
The provider will automatically use your OAuth credentials when Codex CLI is configured.
The Codex CLI provider is codebase-capable, meaning it can analyze and interact with your project files. This enables advanced features like:
Codebase analysis is automatically enabled when:
codex-clienableCodebaseAnalysis is true in your global configuration (default)To verify or configure:
{
"global": {
"enableCodebaseAnalysis": true
}
}
Symptoms: Task Master reports that the Codex CLI is not found.
Solutions:
Install Codex CLI globally:
npm install -g @openai/codex
Verify installation:
codex --version
Alternative: Enable npx fallback:
{
"codexCli": {
"allowNpx": true
}
}
Symptoms: Authentication errors when trying to use Codex CLI.
Solutions:
Authenticate with OAuth:
codex login
Verify authentication status:
codex
# Then use /about command
Re-authenticate if needed:
# Logout first
codex
# Use /auth command to change auth method
# Then login again
codex login
Symptoms: Warnings about Codex CLI version being outdated.
Solutions:
Check current version:
codex --version
Upgrade to latest version:
npm install -g @openai/codex@latest
Verify upgrade:
codex --version
Should show >= 0.44.0
Symptoms: Error indicating the requested model is not available.
Causes and Solutions:
Using unsupported model:
gpt-5, gpt-5-codex, gpt-5.1, gpt-5.1-codex-max, gpt-5.2) are available via Codex CLIgpt-5.2-pro, use the standard openai providerSubscription not active:
Wrong provider selected:
--codex-cli flag when setting models.taskmaster/config.json shows "provider": "codex-cli"Symptoms: You've set OPENAI_CODEX_API_KEY but it's not being used.
Expected Behavior:
Solutions:
Verify OAuth is working:
codex
# Check /about for auth status
If you want to force API key usage:
openai provider insteadVerify .env file is being loaded:
# Check if .env exists in project root
ls -la .env
# Verify OPENAI_CODEX_API_KEY is set
grep OPENAI_CODEX_API_KEY .env
Symptoms: Commands are blocked or filesystem access is denied.
Solutions:
Adjust approval mode:
{
"codexCli": {
"approvalMode": "on-request"
}
}
Adjust sandbox mode:
{
"codexCli": {
"sandboxMode": "workspace-write"
}
}
For fully automated workflows (use cautiously):
{
"codexCli": {
"fullAuto": true
}
}
gpt-5, gpt-5-codex, gpt-5.1, gpt-5.1-codex-max, gpt-5.2)@openai/codex package is not added to Task Master's dependencies - install it globally or enable allowNpxcodex-cli providerapprovalMode: "on-failure" and sandboxMode: "workspace-write"--codex-cli flag with commands