Overview
Global options can be used with any Codex CLI command. They are processed before subcommands and affect the behavior of the entire CLI session.Configuration Override
Override configuration values using key=value pairs. Can be specified multiple times.Examples:Common configuration keys:
model- Override the AI modelsandbox_mode- Control sandbox restrictionsapproval_policy- Set approval modefeatures.<name>- Toggle feature flags
Profile Selection
Select a configuration profile from config.tomlExample:Profiles allow you to maintain different sets of configuration for different use cases (development, production, experimental, etc.).
Working Directory
Change the working directory before executing the commandExample:
Model Selection
Specify the AI model to use for the sessionExample:Common models:
o4-mini- Fast, efficient reasoning model (default)gpt-4.1- Advanced reasoning and codingo3- Advanced reasoning model with extended thinking
Open Source Models
Use open-source models instead of proprietary modelsExample:
Sandbox Control
Control the sandbox mode for command executionOptions:
workspace-write- Allow writes within the workspace directoryfull-access- Allow full filesystem access (use with caution)
Approval Policy
Set when the agent should ask for approval before executing commandsOptions:
on-request- Ask for approval when the agent requests italways- Always ask before executing any commandnever- Never ask (use with caution)
Enable fully automatic mode (equivalent to
--ask-for-approval never)Example:Bypass both approval prompts and sandbox restrictions
Web Search
Enable web search capabilities for the agentExample:
Image Input
Provide image files as input (comma-separated paths)Example:
Directory Context
Add directories to the agent’s context (can be specified multiple times)Example:
Version Information
Display the Codex CLI versionExample:
Display help informationExample:
Combining Options
Global options can be combined to create powerful workflows:Order of Precedence
When the same option is specified in multiple places, Codex uses this priority:- Command-line flags (highest priority)
-cconfig overrides- Environment variables
- Profile settings (from
--profile) config.tomlbase configuration- Built-in defaults (lowest priority)
Related
Feature Flags
Enable experimental features
Configuration
Learn about config.toml