config-advanced.md +39 −11
2 2
3Use these options when you need more control over providers, policies, and integrations. For a quick start, see [Config basics](https://developers.openai.com/codex/config-basic).3Use these options when you need more control over providers, policies, and integrations. For a quick start, see [Config basics](https://developers.openai.com/codex/config-basic).
4 4
55For background on project guidance, reusable capabilities, custom slash commands, multi-agent workflows, and integrations, see [Customization](https://developers.openai.com/codex/concepts/customization). For configuration keys, see [Configuration Reference](https://developers.openai.com/codex/config-reference).For background on project guidance, reusable capabilities, custom slash commands, subagent workflows, and integrations, see [Customization](https://developers.openai.com/codex/concepts/customization). For configuration keys, see [Configuration Reference](https://developers.openai.com/codex/config-reference).
6 6
7## Profiles7## Profiles
8 8
15Define profiles under `[profiles.<name>]` in `config.toml`, then run `codex --profile <name>`:15Define profiles under `[profiles.<name>]` in `config.toml`, then run `codex --profile <name>`:
16 16
17```toml17```toml
1818model = "gpt-5-codex"model = "gpt-5.4"
19approval_policy = "on-request"19approval_policy = "on-request"
20model_catalog_json = "/Users/me/.codex/model-catalogs/default.json"20model_catalog_json = "/Users/me/.codex/model-catalogs/default.json"
21 21
74 74
75For shared defaults, rules, and skills checked into repos or system paths, see [Team Config](https://developers.openai.com/codex/enterprise/admin-setup#team-config).75For shared defaults, rules, and skills checked into repos or system paths, see [Team Config](https://developers.openai.com/codex/enterprise/admin-setup#team-config).
76 76
7777If you just need to point the built-in OpenAI provider at an LLM proxy, router, or data-residency enabled project, set environment variable `OPENAI_BASE_URL` instead of defining a new provider. This overrides the default OpenAI endpoint without a `config.toml` change.If you just need to point the built-in OpenAI provider at an LLM proxy, router, or data-residency enabled project, set `openai_base_url` in `config.toml` instead of defining a new provider. This changes the base URL for the built-in `openai` provider without requiring a separate `model_providers.<id>` entry.
78 78
79```toml79```toml
8080export OPENAI_BASE_URL="https://api.openai.com/v1"openai_base_url = "https://us.api.openai.com/v1"
81codex
82```81```
83 82
84## Project config files (`.codex/config.toml`)83## Project config files (`.codex/config.toml`)
87 86
88For security, Codex loads project-scoped config files only when the project is trusted. If the project is untrusted, Codex ignores `.codex/config.toml` files in the project.87For security, Codex loads project-scoped config files only when the project is trusted. If the project is untrusted, Codex ignores `.codex/config.toml` files in the project.
89 88
9089Relative paths inside a project config (for example, `experimental_instructions_file`) are resolved relative to the `.codex/` folder that contains the `config.toml`.Relative paths inside a project config (for example, `model_instructions_file`) are resolved relative to the `.codex/` folder that contains the `config.toml`.
90
91## Hooks (experimental)
92
93Codex can also load lifecycle hooks from `hooks.json` files that sit next to
94active config layers.
95
96In practice, the two most useful locations are:
97
98- `~/.codex/hooks.json`
99- `<repo>/.codex/hooks.json`
100
101Turn hooks on with:
102
103```toml
104[features]
105codex_hooks = true
106```
107
108For the current event list, input fields, output behavior, and limitations, see
109[Hooks](https://developers.openai.com/codex/hooks).
91 110
92## Agent roles (`[agents]` in `config.toml`)111## Agent roles (`[agents]` in `config.toml`)
93 112
94113For multi-agent role configuration (`[agents]` in `config.toml`), see [Multi-agents](https://developers.openai.com/codex/multi-agent).For subagent role configuration (`[agents]` in `config.toml`), see [Subagents](https://developers.openai.com/codex/subagents).
95 114
96## Project root detection115## Project root detection
97 116
113Define additional providers and point `model_provider` at them:132Define additional providers and point `model_provider` at them:
114 133
115```toml134```toml
116135model = "gpt-5.1"model = "gpt-5.4"
117model_provider = "proxy"136model_provider = "proxy"
118 137
119[model_providers.proxy]138[model_providers.proxy]
190 209
191Pick approval strictness (affects when Codex pauses) and sandbox level (affects file/network access).210Pick approval strictness (affects when Codex pauses) and sandbox level (affects file/network access).
192 211
193212For operational details that are easy to miss while editing `config.toml`, see [Common sandbox and approval combinations](https://developers.openai.com/codex/agent-approvals-security#common-sandbox-and-approval-combinations), [Protected paths in writable roots](https://developers.openai.com/codex/agent-approvals-security#protected-paths-in-writable-roots), and [Network access](https://developers.openai.com/codex/agent-approvals-security#network-access).For operational details to keep in mind while editing `config.toml`, see [Common sandbox and approval combinations](https://developers.openai.com/codex/agent-approvals-security#common-sandbox-and-approval-combinations), [Protected paths in writable roots](https://developers.openai.com/codex/agent-approvals-security#protected-paths-in-writable-roots), and [Network access](https://developers.openai.com/codex/agent-approvals-security#network-access).
194 213
195214You can also use a granular reject policy (`approval_policy = { reject = { ... } }`) to auto-reject only selected prompt categories, such as sandbox approvals, `execpolicy` rule prompts, or MCP input requests (`mcp_elicitations`), while keeping other prompts interactive.You can also use a granular approval policy (`approval_policy = { granular = { ... } }`) to allow or auto-reject individual prompt categories. This is useful when you want normal interactive approvals for some cases but want others, such as `request_permissions` or skill-script prompts, to fail closed automatically.
196 215
197```216```
198217approval_policy = "untrusted" # Other options: on-request, never, or { reject = { ... } }approval_policy = "untrusted" # Other options: on-request, never, or { granular = { ... } }
199sandbox_mode = "workspace-write"218sandbox_mode = "workspace-write"
200allow_login_shell = false # Optional hardening: disallow login shells for shell tools219allow_login_shell = false # Optional hardening: disallow login shells for shell tools
201 220
221# Example granular approval policy:
222# approval_policy = { granular = {
223# sandbox_approval = true,
224# rules = true,
225# mcp_elicitations = true,
226# request_permissions = false,
227# skill_approval = false
228# } }
229
202[sandbox_workspace_write]230[sandbox_workspace_write]
203exclude_tmpdir_env_var = false # Allow $TMPDIR231exclude_tmpdir_env_var = false # Allow $TMPDIR
204exclude_slash_tmp = false # Allow /tmp232exclude_slash_tmp = false # Allow /tmp