What gets written
The binary writes a
truefoundry model provider that points at your gateway with wire_api = "responses", the employee’s sign-in, your default model, and gateway MCP servers, and locks each file. For the Windows file permissions, see Windows enforcement. Sign-in depends on the method you chose:
Example: managed_config.toml on macOS and Linux
Example: managed_config.toml on macOS and Linux
With
model = "gpt-5.4" and mcp_servers = ["github"]:- Device login
- OIDC
Example: requirements.toml and config.toml on Windows
Example: requirements.toml and config.toml on Windows
requirements.toml has no top-level model key, so the default model is under [models.new_thread]. With device login:requirements.toml
config.toml holds the same provider block with a top-level model, and the [mcp_servers.<name>] tables. With OIDC, both files have the [model_providers.truefoundry.auth] table instead of http_headers, with command set to C:\Program Files\TrueFoundry\tfy-local-ai-setup.exe.Choose a model
Codex needs a Virtual Model whose slug is a bare OpenAI model ID, such asgpt-5.4, rather than a provider-prefixed ID:
model is required in an [agents.codex] table. Because the model is a Virtual Model, you can change its routing or add fallbacks in TrueFoundry without redeploying the script.
Use a ChatGPT Business or Enterprise subscription
Use this when your organization pays for Codex through ChatGPT seats instead of an OpenAI API key. Codex sends each employee’s own ChatGPT credential to OpenAI, and the gateway authenticates the employee separately, so usage is attributed to the employee on both sides.1
Create the OpenAI model account
In TrueFoundry, add an OpenAI model account with the base URL
https://chatgpt.com/backend-api/codex and an empty API key, as described in the ChatGPT tab of Configure Codex. Create a Virtual Model for it or copy its model ID.2
Update the Codex table
model with the Virtual Model or model ID from the previous step. This mode needs device login; it does not work with OIDC.3
Tell employees about the two sign-ins
Employees complete the TrueFoundry sign-in from the MDM run, and sign in to their ChatGPT account the first time they open Codex.
- Why two headers:
requires_openai_auth = truemakes Codex send the employee’s ChatGPT credential inAuthorization, so the TrueFoundry credential moves tox-tfy-api-key. The gateway reads them separately:x-tfy-api-keyidentifies the employee to TrueFoundry, and theAuthorizationtoken authenticates the request to OpenAI. - A Virtual Model can have only one ChatGPT subscription target, because each employee’s credential is valid for one ChatGPT account. Targets backed by an OpenAI API key can sit alongside it.
- One employee reaching their ChatGPT limit does not affect anyone else’s routing.
Restrict MCP servers
Gateway MCP servers frommcp_servers are added alongside servers the employee configures. To allow only approved servers, Codex uses an MCP allowlist in requirements.toml, which the binary does not write:
- macOS and Linux: deploy
/etc/codex/requirements.tomlwith your MDM alongside the script. See OpenAI’s managed configuration for the format, and the MCP example. - Windows: the binary rewrites
requirements.tomlon every run to enforce the gateway, so a separately deployed allowlist in that file is replaced.
Windows enforcement
On Windows, the binary enforces the gateway throughC:\ProgramData\OpenAI\Codex\requirements.toml, which overrides the employee’s configuration, and writes machine defaults, including MCP servers, to config.toml in the same directory. Codex applies them in this order:
requirements.tomlandconfig.tomlgive SYSTEM full control and Administrators and Users read-only access. Inherited permissions are removed.- The
C:\ProgramData\OpenAI\Codexdirectory is owned by Administrators, with inherited permissions removed. SYSTEM and Administrators have full control, and Users can read and run but not create, replace, or delete files in it. Codex loads any configuration it finds in that directory, so do not relax this permission.
managed_config.toml. A copy left in %USERPROFILE%\.codex by an older setup only produces a warning; delete it.
Windows Subsystem for Linux
To configure Codex inside WSL, see Windows Subsystem for Linux in the overview.Data retention
For OpenAI-side retention and what the gateway logs, see Data retention in the overview.Verify the deployment
After the lock check and test request on the pilot device:- Check the sign-in block. With device login, look for
Authorization = "Bearer ...under[model_providers.truefoundry.http_headers]. With OIDC, look for[model_providers.truefoundry.auth]with--_print-oidc-tokenand no token. On Windows, the default model is under[models.new_thread]. - Check the version on Windows.
codex --versionmust be 0.156.0 or later for enforcement.
Troubleshooting
For issues that affect every agent, see Troubleshooting in the overview.
Related
- Codex integration: manual configuration, Virtual Models, and web search
- Set up OIDC sign-in: the public OIDC client that Claude Code, Codex, and Claude Desktop share
- Claude Code and Claude Desktop with MDM: policy, MCP allowlist, models, and Desktop preferences
- Configuration reference: every
mdm.tomlfield, CLI flag, and file path