Codex CLI reads almost every setting from one file: config.toml. Recent releases changed how profiles, local providers and approval policies work, so many older examples online now break on startup.
This guide walks through the file location, every key most people need, a full sample config and the mistakes that cause errors. Everything was checked against the official docs and the Codex repo on 4 December 2026 (CLI 0.174.0).
- Location:
~/.codex/config.tomlfor personal defaults, plus optional.codex/config.tomlfiles inside trusted projects. - Core keys:
model,model_reasoning_effort,approval_policy,sandbox_mode,web_search. - Profiles changed: since 0.134.0 each profile is its own file,
~/.codex/NAME.config.toml. The old[profiles.NAME]tables no longer work with--profile. - Retired values:
approval_policy = "untrusted"andwire_api = "chat"now stop Codex with an error. - Local models: Ollama and LM Studio are built in. Use
codex --osswithoss_provider.
Where config.toml Lives
Codex keeps its local state in CODEX_HOME, which defaults to ~/.codex. Your personal config is ~/.codex/config.toml. On Windows that is %USERPROFILE%\.codex\config.toml.
Yes, project-level config is supported. Add a .codex/config.toml file inside a repo and Codex loads it, but only when you trust the project. The CLI, the IDE extension and the desktop app share the same layers.

Which file wins
Codex merges several layers. The official docs list them from highest to lowest priority:
- CLI flags and
--configoverrides. - Project files: every
.codex/config.tomlfrom the project root down to your current folder. The closest one wins. - Profile file picked with
--profile NAME, at~/.codex/NAME.config.toml. - User config:
~/.codex/config.toml. - Cloud-managed defaults for a signed-in workspace.
- System config:
/etc/codex/config.tomlon Unix. - Built-in defaults.
Note: Project files cannot change where credentials go or run local commands. Codex ignores model_provider, model_providers, notify, profile, profiles, openai_base_url, otel and a few others in a project file, and prints a startup warning.
Other files you will see in ~/.codex include auth.json (if you use file-based login storage) and history.jsonl. For instruction files, see our AGENTS.md guide.
How to Create Your First config.toml
Codex works without a config file, so you only add what you want to change. Here is the quickest safe setup.
- Install or update Codex. Run
npm install -g @openai/codex, then checkcodex --version. Our Codex CLI, app and pricing guide covers sign-in and plans. - Create the folder. Run
mkdir -p ~/.codexon macOS or Linux. Codex creates it on first run anyway. - Create the file. Open
~/.codex/config.tomlin any editor. In the IDE extension, use the gear icon, then Codex Settings, then Open config.toml. - Add a few top-level keys. Start with
model,approval_policyandsandbox_modefrom the examples below. - Put tables last. Keep plain keys at the top, then sections like
[mcp_servers.NAME]below them. - Restart Codex. Start a new session and run
/statusto see the active model and permissions. - Check for problems. If anything looks wrong, run
codex doctor, which checks your install, config, auth and runtime health.
Model and Reasoning Keys
These keys decide which model runs and how hard it thinks. They are the settings people change most often.
model = "gpt-6.2-sol"
model_reasoning_effort = "medium"
model_reasoning_summary = "auto"
model_verbosity = "medium"
plan_mode_reasoning_effort = "high"
review_model = "gpt-6.2-astra"
web_search = "cached"
- model: the default model. The bundled catalog in the current repo lists gpt-6.2-sol first, then gpt-6.2-astra, gpt-6.1-terra, gpt-6.1-sol and older ones. Use a model your plan can access.
- model_reasoning_effort: the values depend on the model. Current GPT-6.x models in the catalog accept
low,medium,high,xhigh,maxand, on most,ultra. - model_reasoning_summary:
auto,concise,detailedornone. Release 0.174.0 made Auto the terminal default for OpenAI models. - model_verbosity:
low,mediumorhigh, for Responses API providers. - plan_mode_reasoning_effort: a separate effort level for plan mode.
- review_model: the model used by
/review. - web_search:
cached(default),indexed,liveordisabled.
Tip: Higher effort costs more of your usage limit. If you hit caps often, read our Codex usage limits guide before setting xhigh or above as your default.
Approval Policy and Sandbox Mode
These two keys control safety. approval_policy decides when Codex stops to ask you. sandbox_mode decides what commands can touch.
| Key | Value | What it does |
|---|---|---|
| approval_policy | on-request |
The model decides when to ask. This is the default. |
| approval_policy | never |
Never asks. Failures go straight back to the model. |
| approval_policy | { granular = { ... } } |
Allow or auto-reject each prompt type separately. |
| sandbox_mode | read-only |
Commands can read files but not change them. |
| sandbox_mode | workspace-write |
Writes allowed inside the workspace. Network off by default. |
| sandbox_mode | danger-full-access |
No sandbox. Only for machines that are already isolated. |
approval_policy = "on-request"
approvals_reviewer = "user" # or "auto_review"
sandbox_mode = "workspace-write"
[sandbox_workspace_write]
network_access = false
writable_roots = ["/Users/you/.pyenv/shims"]
exclude_tmpdir_env_var = false
exclude_slash_tmp = false
The granular form takes these switches: sandbox_approval, rules, mcp_elicitations, request_permissions and skill_approval. A false value auto-rejects that kind of request instead of showing it.
Warning: approval_policy = "untrusted" is retired. Codex now refuses to start with it and says to remove the setting. The old on-failure value is still accepted, but it is read as on-request.
Even in workspace-write mode, paths like .git, .codex, .agents and .aws can stay read-only. That is why git commit may still ask for approval.
Profiles: The New File-Based Way
This is the biggest recent change. From Codex 0.134.0, a profile is a separate file named ~/.codex/NAME.config.toml. Codex loads your main config first, then lays the profile on top.
# ~/.codex/deep-review.config.toml
model = "gpt-6.1-sol"
model_reasoning_effort = "high"
approval_policy = "on-request"
Run it with codex --profile deep-review or the short form codex -p deep-review. It also works with codex exec. Profile names can use letters, numbers, hyphens and underscores.
- Use top-level keys in the profile file. Do not nest them under
[profiles.NAME]. - Keep it short. The profile only needs values that differ from your main file.
- Remove old tables. If
config.tomlstill has[profiles.deep-review]orprofile = "deep-review", Codex stops with an error when you pass that profile.
MCP Servers
MCP servers give Codex extra tools, like docs search or a browser. Each server is a table under [mcp_servers.NAME]. There are two kinds.
# Local (stdio) server
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
env = { "EXAMPLE_FLAG" = "1" }
startup_timeout_sec = 20
tool_timeout_sec = 60
# Remote (streamable HTTP) server
[mcp_servers.docs]
url = "https://mcp.example.com/mcp"
bearer_token_env_var = "DOCS_MCP_TOKEN"
enabled = true
disabled_tools = ["delete_page"]
- command and args: start a local server process.
- url: connect to a remote streamable HTTP server instead.
- bearer_token_env_var: the name of an environment variable holding the token, so the secret stays out of the file.
- enabled_tools / disabled_tools: allow-list or block-list single tools.
- required: set
trueto make startup fail if the server cannot start.
You can also skip hand-editing. codex mcp add writes a server entry into ~/.codex/config.toml, and codex mcp list, get, remove, login and logout manage it. For ideas, see our best MCP servers list.
Model Providers: Ollama, OpenRouter and Proxies
A provider tells Codex where to send requests. Codex reserves these IDs for built-in providers: openai, ollama, lmstudio, amazon-bedrock, amazon-bedrock-runtime and gcp. Custom providers need a different, unique ID.
Warning: wire_api = "chat" (Chat Completions) is no longer supported. Codex now speaks only the Responses API, so any provider you add must offer a /v1/responses endpoint.
Ollama (local models)
Ollama added a /v1/responses endpoint in v0.13.3, so update Ollama first. The simplest route needs no provider table at all.
oss_provider = "ollama" # or "lmstudio"
Then run codex --oss -m gpt-oss:20b. Codex talks to http://localhost:11434/v1 by default. Ollama’s own docs also offer ollama launch codex, which writes a profile file for you, and recommend a context window of at least 64k tokens.
For Ollama on another machine, add a provider with a new ID, since ollama itself is reserved:
[model_providers.ollama-remote]
name = "Ollama on my server"
base_url = "http://192.168.1.50:11434/v1"
wire_api = "responses"
Need a model? Our best Ollama models guide lists good coding picks.
OpenRouter
OpenRouter offers a stateless Responses endpoint at https://openrouter.ai/api/v1/responses. Put your key in an environment variable, then point a custom provider at it.
model = "openai/gpt-oss-120b"
model_provider = "openrouter"
[model_providers.openrouter]
name = "OpenRouter"
base_url = "https://openrouter.ai/api/v1"
env_key = "OPENROUTER_API_KEY"
wire_api = "responses"
Copy the exact model slug from OpenRouter’s model list. Our OpenRouter guide explains keys and free models.
Proxies, Azure and data residency
- Just a proxy: set
openai_base_url = "https://proxy.example.com/v1". Do not create[model_providers.openai], because built-in IDs cannot be overridden. - Azure: use a custom provider with
base_url,env_key = "AZURE_OPENAI_API_KEY",query_params = { api-version = "..." }andwire_api = "responses". - Tuning: any provider can set
request_max_retries,stream_max_retriesandstream_idle_timeout_ms. - Headers:
http_headersfor fixed values andenv_http_headersto read values from environment variables.
Notify, History and Shell Environment
notify
notify runs a program after each finished turn. It must be an array of arguments, not one string. Codex adds one extra argument: a JSON payload with fields such as type, thread-id, cwd and last-assistant-message.
notify = ["notify-send", "Codex"]
# or a script
# notify = ["python3", "/Users/you/.codex/notify.py"]
The only event today is agent-turn-complete. For simple terminal alerts, the built-in [tui] settings such as notifications and notification_method may be enough.
history
Codex saves transcripts to ~/.codex/history.jsonl by default. You can turn that off or cap its size.
[history]
persistence = "save-all" # or "none"
max_bytes = 104857600 # 100 MiB, oldest entries dropped first
shell_environment_policy
This table controls which environment variables reach the commands Codex runs. It matters because your shell may hold API keys.
[shell_environment_policy]
inherit = "core" # "all", "core" or "none"
ignore_default_excludes = false
set = { MY_FLAG = "1" }
[shell_environment_policy.filters]
"AWS_*" = "exclude"
"AZURE_*" = "exclude"
Note: ignore_default_excludes defaults to true. That means names containing KEY, SECRET or TOKEN are passed through unless you set it to false.
The older exclude and include_only arrays still work. Do not mix them with the filters table in the same file, because Codex rejects that combination.
One-Off Overrides With -c
Use -c (long form --config) to change a key for one run without editing the file. Dedicated flags are better when they exist.
# Dedicated flags
codex -m gpt-6.2-astra
codex -s read-only -a on-request
codex -p deep-review
# Generic overrides (values are TOML)
codex -c model='"gpt-6.2-astra"'
codex -c model_reasoning_effort='"high"'
codex -c sandbox_workspace_write.network_access=true
codex -c 'shell_environment_policy.include_only=["PATH","HOME"]'
codex -c mcp_servers.context7.enabled=false
- Dot notation reaches nested keys.
- Values are TOML, not JSON. If parsing fails, Codex treats the value as a plain string.
- Quote for your shell so spaces and brackets are not split.
Recent source on the main branch labels -c as a legacy option and points to dedicated flags. It still works in 0.174.0, but expect more flags to replace it over time.
Full Sample config.toml
Copy this, delete what you do not need, and keep the order: plain keys first, tables after.
# ~/.codex/config.toml
model = "gpt-6.2-sol"
model_reasoning_effort = "medium"
model_reasoning_summary = "auto"
plan_mode_reasoning_effort = "high"
review_model = "gpt-6.2-astra"
approval_policy = "on-request"
approvals_reviewer = "user"
sandbox_mode = "workspace-write"
web_search = "cached"
oss_provider = "ollama"
file_opener = "vscode"
project_doc_max_bytes = 65536
notify = ["notify-send", "Codex"]
[sandbox_workspace_write]
network_access = false
writable_roots = []
[history]
persistence = "save-all"
max_bytes = 104857600
[shell_environment_policy]
inherit = "core"
ignore_default_excludes = false
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
startup_timeout_sec = 20
[model_providers.openrouter]
name = "OpenRouter"
base_url = "https://openrouter.ai/api/v1"
env_key = "OPENROUTER_API_KEY"
wire_api = "responses"
[projects."/Users/you/code/my-app"]
trust_level = "trusted"
[features]
memories = false
[tui]
notifications = true
The [projects] entry is how Codex remembers trust. Codex usually writes it for you when you accept the trust prompt. Set it to "untrusted" to block project config, hooks and rules in that folder.

Quick Key Reference Table
| Key | Example value | Purpose |
|---|---|---|
| model | "gpt-6.2-sol" |
Default model |
| model_reasoning_effort | "medium" |
How hard the model thinks |
| approval_policy | "on-request" |
When Codex asks you |
| sandbox_mode | "workspace-write" |
What commands may change |
| web_search | "cached" |
Web search mode |
| model_provider | "openrouter" |
Which provider table to use |
| oss_provider | "ollama" |
Default for --oss |
| openai_base_url | "https://proxy/v1" |
Point built-in OpenAI at a proxy |
| notify | ["notify-send","Codex"] |
Run a program after each turn |
| project_doc_max_bytes | 65536 |
How much AGENTS.md text to load |
| project_root_markers | [".git", ".hg"] |
How the project root is found |
| file_opener | "vscode" |
Clickable file citations |
| hide_agent_reasoning | true |
Quieter output, handy in CI |
| log_dir | "/abs/path/logs" |
Where logs are written |
Troubleshooting: Common Problems and Fixes
Most config errors come from a handful of mistakes. If Codex will not start at all, our Codex not working fix guide covers login and network problems too.
| Problem | Cause | Fix |
|---|---|---|
| “approval_policy = “untrusted” is no longer supported” | Retired value | Remove it or use on-request |
| “wire_api = “chat” is no longer supported” | Chat Completions removed | Set wire_api = "responses" |
| “ollama-chat is no longer supported” | Old provider ID | Replace it with ollama |
--profile X cannot be used while ... contains legacy |
Old [profiles.X] table |
Move settings into ~/.codex/X.config.toml |
| Project settings ignored | Project not trusted, or key is on the deny list | Trust the project; move provider and notify keys to the user file |
Custom [model_providers.ollama] has no effect |
Built-in IDs cannot be overridden | Use a new ID such as ollama-remote |
| A key seems to do nothing | It sits below a [table] header |
Move top-level keys above all tables |
| Model not found | Your plan lacks that model | Pick one from /model |
Other common mistakes
- notify as a string: write
["notify-send", "Codex"], not"notify-send Codex". - Unquoted -c strings:
-c model=gpt-6.2-astraworks only because of the string fallback. Quote values that contain spaces. - Secrets in the file: use
env_keyandbearer_token_env_var, never paste a token into config.toml. - Leaky environment: set
ignore_default_excludes = falseif commands should not see your API keys. - Tiny local context: Codex struggles with small context windows. Raise Ollama’s context to 64k or more.
Frequently Asked Questions
Where is the Codex CLI config file?
It lives at ~/.codex/config.toml, or inside the folder set by the CODEX_HOME environment variable. On Windows it is under your user profile in .codex.
Does Codex support a project-level config.toml?
Yes. Put a .codex/config.toml file in your repo. Codex loads it only for trusted projects, and the closest file to your working folder wins.
Why does my [profiles] section not work anymore?
Since Codex 0.134.0, --profile NAME reads ~/.codex/NAME.config.toml instead. Move the settings into that file and delete the old table and any profile = "NAME" line.
Can I use Codex with Ollama?
Yes. Update Ollama to 0.13.3 or newer, set oss_provider = "ollama" and run codex --oss with a model you have pulled. Use a context window of 64k tokens or more.
Can I use OpenRouter with Codex CLI?
Yes, through a custom provider with base_url = "https://openrouter.ai/api/v1", env_key = "OPENROUTER_API_KEY" and wire_api = "responses". Use OpenRouter’s exact model slug.
What reasoning effort values can I use?
It depends on the model. Current GPT-6.x models in the Codex catalog accept low, medium, high, xhigh, max and, on most, ultra.
How do I check which settings are active?
Run /status inside a session to see the model, limits and permissions. Run codex doctor to check your config and install.



