---
title: Configure Codex
description: Configure Codex requirements and defaults for the CLI and desktop app, and see how Unity Gateway builds the TOML files.
canonical_url: https://docs.databricks.com/gcp/en/ai-gateway/coding-agent-codex-settings
---

# Configure Codex

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/gcp/en/release-notes/release-types.md). To use it, a workspace admin must turn on ****Unity Gateway Managed Configuration**** from the **Previews** page. See [Manage Databricks previews](https://docs.databricks.com/gcp/en/admin/workspace-settings/manage-previews.md).

Use `agent_native_config.codex` to set Codex requirements and defaults in your workspace's coding agent configuration. Codex CLI and the Codex agent in ChatGPT desktop read the same files on a device. Each setting takes effect where the client supports its feature.

After `ug` writes the system files, Codex applies its own [configuration precedence](https://learn.chatgpt.com/docs/config-file/config-basic) to `config.toml` and its [managed requirements](https://learn.chatgpt.com/docs/enterprise/managed-configuration) to `requirements.toml`. The ownership table on this page describes how `ug` builds those files.

Choose the field that matches how you want a setting to apply:

| Field                | Generated file and effect                                                                                             | Official reference                                                                                                   |
| -------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| `codex.config`       | `/etc/codex/config.toml`. Sets defaults that developers can override in their own Codex configuration.                | [Codex `config.toml` reference](https://learn.chatgpt.com/docs/config-file/config-reference#configtoml).             |
| `codex.requirements` | `/etc/codex/requirements.toml`. Restricts the settings developers can use. Codex enforces supported requirement keys. | [Codex `requirements.toml` reference](https://learn.chatgpt.com/docs/config-file/config-reference#requirementstoml). |

## <a id="requirements" />Requirements

Use Codex 0.156.0 or above to enforce the gateway provider in `requirements.toml`.

The native-file rebuild described on this page applies to macOS and Linux. For Windows machine-wide configuration, see [Roll out coding agents with mobile device management (MDM)](https://docs.databricks.com/gcp/en/ai-gateway/coding-agent-rollout.md).

## Add Codex settings

1. Open the [coding agent configuration](https://docs.databricks.com/gcp/en/ai-gateway/coding-agent-configure-govern.md#publish-a-configuration) in your workspace.

2. Find the `CODING_AGENT_CODEX` entry in `enabled_agents`. Add `agent_native_config` inside that entry's `config` object. For example, this entry enables fast mode, limits concurrent agent threads, and restricts locked computer use and browser history access:

   ```json
   {
     "agent": "CODING_AGENT_CODEX",
     "config": {
       "models": { "sources": ["system.ai.gpt-5-5"] },
       "default_models": { "default_model": "system.ai.gpt-5-5" },
       "agent_native_config": {
         "codex": {
           "requirements": {
             "computer_use": { "allow_locked_computer_use": false },
             "browser_use": { "allow_history_access": false }
           },
           "config": {
             "features": { "fast_mode": true },
             "agents": { "max_concurrent_threads_per_session": 4 }
           }
         }
       }
     }
   }
   ```

   Merge these fields into the existing entry. Keep the model settings, Model Context Protocol (MCP) servers, and any other settings your team needs.

3. Save the configuration. Run `ug configure --global` on each managed device to apply the published settings. See [Roll out coding agents with mobile device management (MDM)](https://docs.databricks.com/gcp/en/ai-gateway/coding-agent-rollout.md).

Codex reads these files when it starts, including when a developer starts the CLI or Codex in ChatGPT desktop directly.

In the workspace configuration, represent the contents of each TOML file as a JSON object. `ug` converts nested JSON objects to TOML tables. It drops JSON `null` values because TOML has no null value and lists each dropped key in its report.

Use the coding agent configuration's `models`, `default_models`, and `http_headers` fields for gateway models, default models, and request headers. See the [configuration schema](https://docs.databricks.com/gcp/en/ai-gateway/coding-agent-config-schema.md#agent-native-config) for field paths.

## Represent TOML settings as JSON

The `config.toml` defaults in the preceding example correspond to these TOML settings:

```toml
[features]
fast_mode = true

[agents]
max_concurrent_threads_per_session = 4
```

The `requirements.toml` restrictions correspond to these TOML settings:

```toml
[computer_use]
allow_locked_computer_use = false

[browser_use]
allow_history_access = false
```

Represent both files with this JSON object inside the `CODING_AGENT_CODEX` entry's `config`:

```json
{
  "agent_native_config": {
    "codex": {
      "requirements": {
        "computer_use": { "allow_locked_computer_use": false },
        "browser_use": { "allow_history_access": false }
      },
      "config": {
        "features": { "fast_mode": true },
        "agents": { "max_concurrent_threads_per_session": 4 }
      }
    }
  }
}
```

## <a id="how-unity-gateway-builds-codex-files" />How Unity Gateway builds Codex files

On each `ug configure --global` run, `ug` builds `requirements.toml` from your `codex.requirements` object, then adds the gateway provider lock. It builds `config.toml` from your `codex.config` object, then adds the model from `default_models.default_model`. For a static model list, it also writes `/etc/codex/ug-model-catalog.json` and `/etc/codex/managed_config.toml`. Run [`ug configure --global --dry-run`](https://docs.databricks.com/gcp/en/ai-gateway/coding-agent-rollout.md#configure-coding-agents) to inspect the generated files and skipped keys.

Keys absent from the following table pass through as given. A reserved key in your JSON is skipped. A conditionally reserved key is skipped only while its feature is active. A shared table keeps your named entries except those that `ug` also registers.

### Keys controlled by `ug`

Keys in `config.toml` come from `codex.config`. Keys in `requirements.toml` come from `codex.requirements`.

| File                | Key                          | What `ug` does                                                                                                                                                           |
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `config.toml`       | `mcp_servers`                | **Shared table:** `ug` keeps your servers with distinct names and registers gateway MCP servers for each developer. The gateway definition wins on a name collision.     |
| `config.toml`       | `model`                      | **Reserved:** `ug` skips your value and writes `default_models.default_model` when set.                                                                                  |
| `config.toml`       | `model_catalog_json`         | **Reserved:** `ug` skips your value and leaves this key out of `config.toml`. For a static model list, `ug` names its catalog in `managed_config.toml`.                  |
| `config.toml`       | `model_provider`             | **Reserved:** `ug` skips your value and leaves this key out of `config.toml`. `requirements.toml` sets the gateway provider.                                             |
| `config.toml`       | `model_providers.Databricks` | **Reserved:** `ug` skips your value and leaves this key out of `config.toml`. `requirements.toml` defines the gateway provider.                                          |
| `requirements.toml` | `allow_managed_hooks_only`   | **Conditionally reserved:** When Smart Routing is enabled, `ug` skips your value and leaves this key out of `requirements.toml` so routing hooks can run.                |
| `requirements.toml` | `config_server`              | **Reserved:** `ug` skips your value and leaves this key out of `requirements.toml` so another server cannot override gateway requirements.                               |
| `requirements.toml` | `features.hooks`             | **Conditionally reserved:** When Smart Routing is enabled, `ug` skips your value and leaves this key out of `requirements.toml` so routing hooks can run.                |
| `requirements.toml` | `mcp_servers`                | **Shared table:** If you set an allowlist, `ug` adds gateway MCP servers to it. The gateway definition wins on a name collision.                                         |
| `requirements.toml` | `model_catalog_json`         | **Reserved:** `ug` skips your value and leaves this key out of `requirements.toml`. For a static model list, `ug` names its catalog in `managed_config.toml`.            |
| `requirements.toml` | `model_provider`             | **Reserved:** `ug` skips your value and locks the provider to the gateway.                                                                                               |
| `requirements.toml` | `model_providers`            | **Reserved:** `ug` skips your value and defines the gateway provider.                                                                                                    |
| `requirements.toml` | `models.new_thread`          | **Reserved:** `ug` skips your value and leaves this key out of `requirements.toml`. Set `default_models.default_model` for the default model.                            |
| `requirements.toml` | `otel.trace_exporter`        | **Conditionally reserved:** When tracing is enabled, `ug` skips your value and leaves this key out of `requirements.toml`. `ug codex` configures the exporter at launch. |
