2 2
3> For the complete documentation index, see [llms.txt](https://learn.chatgpt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.3> For the complete documentation index, see [llms.txt](https://learn.chatgpt.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.
4 4
5Roll out native gateway OAuth, API keys, or credential helpers without ChatGPT5As the gateway administrator, configure the model routes and authorize a pilot user. Test the connection on each client you support before distributing settings to developers. Use native gateway OAuth, API keys, or credential helpers for gateway
6sign-in. Configure model routes, authorize users, and distribute a verified Codex6authentication. To combine gateway authentication with ChatGPT workspace sign-in, see
7configuration. For a gateway that forwards ChatGPT workspace requests, see
8[Sign in with ChatGPT through a gateway](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#enable-chatgpt-sign-in-recommended).7[Sign in with ChatGPT through a gateway](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#enable-chatgpt-sign-in-recommended).
9 8
10To configure Codex on your own machine with values you were given, see9To configure Codex on your own machine with values you were given, see
66 65
67### Use a model catalog for custom names66### Use a model catalog for custom names
68 67
68For a local catalog, start with the [models.json example](#start-with-a-local-modelsjson-file).
69
69Supply a model catalog when your gateway uses a model name Codex does not recognize. The catalog supplies the instructions, reasoning options, context limits, and tool capabilities Codex uses for that name. Without a matching entry, a request can reach the intended upstream model while Codex uses generic settings.70Supply a model catalog when your gateway uses a model name Codex does not recognize. The catalog supplies the instructions, reasoning options, context limits, and tool capabilities Codex uses for that name. Without a matching entry, a request can reach the intended upstream model while Codex uses generic settings.
70 71
71Host a remote catalog with `model_providers.<id>.model_catalog_url` to update model metadata centrally, or distribute a local file with `model_catalog_json`. Use a local catalog when native gateway OAuth is the only credential; OAuth alone doesn't enable remote catalog discovery. See the [configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference) for both settings.72Host a remote catalog with `model_providers.<id>.model_catalog_url` to update model metadata centrally, or distribute a local file with `model_catalog_json`. Use a local catalog when native gateway OAuth is the only credential; OAuth alone doesn't enable remote catalog discovery. See the [configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference) for both settings.
73Get a catalog endpoint or file compatible with your Codex version from your cloud74Get a catalog endpoint or file compatible with your Codex version from your cloud
74or gateway provider. Make sure it includes each approved alias and its model75or gateway provider. Make sure it includes each approved alias and its model
75metadata. For catalog implementation, see76metadata. For catalog implementation, see
76[Implementing model catalogs for gateways and clouds](https://learn.chatgpt.com/docs/model-catalogs).77[Implementing model catalogs for gateways and clouds](#model-catalog-reference).
77 78
78#### Serve a remote catalog79#### Serve a remote catalog
79 80
173 174
174Before distributing anything, follow [Configure the provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider) to configure one isolated test user with the provider block and authentication method you plan to distribute.175Before distributing anything, follow [Configure the provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider) to configure one isolated test user with the provider block and authentication method you plan to distribute.
175 176
176Run the checks below from the same CLI or desktop surface developers will use:177If the gateway serves the model catalog, confirm it returns a Codex-compatible `models` array. For OpenAI inference using the user's credential, confirm the gateway forwards the required ChatGPT headers to the Codex backend.
178
179Record the client version, operating system, provider ID, model alias, and authentication method for your pilot. Run the checks below from each CLI or desktop surface you plan to support. If you offer both gateway-only authentication and gateway authentication alongside ChatGPT sign-in, test each combination separately.
177 180
178| Check | Action | Passing evidence |181| Check | Action | Passing evidence |
179| ---------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |182| ----------------------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
183| Effective configuration | Inspect the configuration layers and confirm the intended provider, model, and requirements. | The pilot uses the distributed settings. User or profile defaults do not select a different route. |
180| Connection | Follow [Verify the connection](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#verify-the-connection). | The expected provider and alias are active, the test prompt succeeds, and gateway logs identify the test user. |184| Connection | Follow [Verify the connection](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#verify-the-connection). | The expected provider and alias are active, the test prompt succeeds, and gateway logs identify the test user. |
181| Streaming | Ask for a short multi-paragraph answer. | The gateway forwards SSE events without buffering, text arrives incrementally, and the stream ends with `response.completed`. |185| Streaming | Ask for a short multi-paragraph answer. | Text arrives incrementally and the active transport emits `response.completed`. Test HTTP separately to verify that the gateway forwards SSE events without buffering. |
182| Local tool loop | In a disposable folder with read-only permissions, ask Codex to list the top-level files and summarize them. | Codex issues a local tool call, returns the result, and produces a final answer without edits. |186| Local tool loop | In a disposable folder with read-only permissions, ask Codex to list the top-level files and summarize them. | Codex issues a local tool call, returns the result, and produces a final answer without edits. |
183| Follow-up | Ask a follow-up in the same thread. | The answer uses the prior turn; the gateway accepts replayed input. If WebSocket or incremental transport is enabled, it also preserves `previous_response_id`. |187| Follow-up | Ask a follow-up in the same thread. | The answer uses the prior turn; the gateway accepts replayed input. If WebSocket or incremental transport is enabled, it also preserves `previous_response_id`. |
184| Errors and attribution | Repeat with an intentionally invalid test alias or expired test credential. | The client receives a useful routing or authentication error, and valid requests remain attributed to the test user. |188| Errors and attribution | Repeat with an intentionally invalid test alias or expired test credential. | The client receives a useful routing or authentication error, and valid requests remain attributed to the test user. |
185 189
186After these checks succeed, direct developers to [Configure the provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider) to configure and verify their own machine.190If automatic approval is enabled, use a disposable test folder to trigger a tool action that requires review under your intended policy. Confirm that the gateway handles the review request and that the client applies the approval decision. A read-only tool call that needs no approval does not test this path. Record any unsupported workflow before expanding the pilot.
191
192If the rollout changes the provider for existing users, test a new conversation and a conversation created before the change on each supported client. Record whether users can view, continue, or branch the existing conversation, and give them a recovery procedure for any blocked workflow. Don't assume that changing the default provider migrates conversation history.
193
194After these checks succeed, prepare the [developer handoff](#hand-developers-the-configuration-values).
187 195
188## Distribute the configuration196## Distribute the configuration
189 197
269A CLI inside WSL reads Linux paths and Linux `CODEX_HOME`; it doesn't automatically277A CLI inside WSL reads Linux paths and Linux `CODEX_HOME`; it doesn't automatically
270inherit native Windows configuration.278inherit native Windows configuration.
271 279
280### Distribute routing headers
281
282If your gateway routes requests by configuration or tool, add the headers it expects to the provider in your managed `requirements.toml`. The following example supplies a routing configuration ID and identifies Codex as the client:
283
284```toml
285[model_providers.enterprise-gateway.http_headers]
286x-portkey-config = "<gateway-routing-config-id>"
287x-portkey-metadata = '{"tool_id":"codex"}'
288```
289
290Use `env_http_headers` for header values supplied by the client environment. Send a test request and confirm the selected route in gateway logs. See [Custom model providers](https://learn.chatgpt.com/docs/config-file/config-advanced#custom-model-providers) for header options.
291
272### Hand developers the configuration values292### Hand developers the configuration values
273 293
274If you do not have managed distribution, give each developer the gateway URL, provider ID, model alias, OAuth configuration or credential variable or resolver, and any catalog URL or local path. Send them to [Configure the provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider) to configure and verify their own machine.294Give developers one setup path that matches the pilot you tested. Include the following information even when you distribute configuration centrally:
295
296| Handoff item | What to provide |
297| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
298| Approved client | The client, version, operating system, and installation or update instructions used in the pilot. |
299| Configuration delivery | Whether settings are already managed or require local setup; identify any helper or catalog file installed separately. |
300| Expected connection | The provider ID, model alias, and gateway URL, including its API path. Explain which values users may change. |
301| Sign-in steps | Whether users must sign in to a ChatGPT workspace, authenticate to the gateway, or do both. Name the required workspace and gateway authentication method. |
302| Credentials and catalogs | The OAuth registration values, credential environment variable, or installed helper configuration, plus any catalog URL or resolved local path. Deliver secrets through your approved secret-distribution mechanism. |
303| Verification and support | The [connection test](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#verify-the-connection), expected result, gateway owner, and information to include when reporting a failure. |
304
305For managed machines, send developers to [Check for an existing configuration](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#check-for-an-existing-configuration). For manual setup, send them to [Configure the provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider).
306
307Include your tested instructions for existing conversations if this rollout changes the provider. Keep the previous working configuration available to the rollout owner in case the pilot exposes a problem.
275 308
276Manual setup is not an enforcement channel. Project-local `.codex/config.toml` cannot override sensitive provider or authentication routing keys.309Manual setup is not an enforcement channel. Project-local `.codex/config.toml` cannot override sensitive provider or authentication routing keys.
277 310
281 314
282To confirm that the distributed settings reached a developer machine:315To confirm that the distributed settings reached a developer machine:
283 316
2841. Restart Codex and confirm the expected provider and model.3171. Confirm that the approved client and any required helper or catalog files are installed. Restart Codex and complete the sign-ins in your handoff.
2852. Run the short test in [Connect to a gateway](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#verify-the-connection).3182. Confirm the expected provider and model. In the CLI, use `/status`. Use [`/debug-config`](https://learn.chatgpt.com/docs/developer-commands?surface=cli#cli-inspect-config-layers-with-debug-config) to inspect configuration layers when the effective settings differ from the handoff.
2863. Ask one follow-up to confirm continuation, then check the gateway logs for that3193. Run the short test in [Connect to a gateway](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#verify-the-connection).
3204. Ask one follow-up to confirm continuation, then check the gateway logs for that
287 developer's request.321 developer's request.
288 322
323Expand access after the pilot passes on the clients and authentication combinations you support. Keep the tested configuration and results with your rollout instructions so you can repeat the checks after client, gateway, or policy updates.
324
289### Troubleshoot rollout failures325### Troubleshoot rollout failures
290 326
291Use the issue to find the configuration, credential, or gateway layer that needs attention:327Use the issue to find the configuration, credential, or gateway layer that needs attention:
3211. Inventory the current Claude path: gateway URL, credential source, required headers, model aliases, Bedrock profile mappings, and managed delivery channel.3571. Inventory the current Claude path: gateway URL, credential source, required headers, model aliases, Bedrock profile mappings, and managed delivery channel.
3222. Add a parallel Codex-facing Responses route and Codex model aliases.3582. Add a parallel Codex-facing Responses route and Codex model aliases.
3233. Choose [native gateway OAuth, an API key, or a credential helper](#choose-authentication) and authorize one test user. For a static credential, expose it through `env_key`; for a helper, implement and test the Codex command-backed resolver contract.3593. Choose [native gateway OAuth, an API key, or a credential helper](#choose-authentication) and authorize one test user. For a static credential, expose it through `env_key`; for a helper, implement and test the Codex command-backed resolver contract.
3244. Configure that developer with the [provider block](#what-to-distribute). For a managed rollout, translate the payload into the Codex paths and precedence described in [Roll out a gateway](#distribute-the-configuration).3604. [Configure the provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider) for that developer using the authentication method you selected in step 3. For a managed rollout, translate the payload into the Codex paths and precedence described in [Roll out a gateway](#distribute-the-configuration).
3255. Run the short connection check on the developer's actual CLI or desktop surface, then run the full streaming, continuation, tool-call, error, logging, and alias-routing checks in [Test Codex through the gateway](#test-the-client-and-gateway).3615. Run the short connection check on the developer's actual CLI or desktop surface, then run the full streaming, continuation, tool-call, error, logging, and alias-routing checks in [Test Codex through the gateway](#test-the-client-and-gateway).
3266. After the pilot passes, [distribute the configuration](#distribute-the-configuration) to the remaining developers.3626. After the pilot passes, [distribute the configuration](#distribute-the-configuration) to the remaining developers.
327 363
364## Model catalog reference
365
366### Start with a local models.json file
367
368First, [configure and select your gateway provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider) on the machine where you run Codex.
369
370Save this catalog as `models.json` on the machine running Codex. Replace
371`gateway-model` with the exact model ID your gateway accepts. The display name
372is the label users see in the model picker.
373
374```json
375{
376 "models": [
377 {
378 "slug": "gateway-model",
379 "display_name": "Gateway model",
380 "base_instructions": "Help the user with their coding tasks.",
381 "supported_reasoning_levels": [],
382 "shell_type": "shell_command",
383 "visibility": "list",
384 "supported_in_api": true,
385 "priority": 0,
386 "support_verbosity": false,
387 "truncation_policy": { "mode": "tokens", "limit": 10000 },
388 "experimental_supported_tools": []
389 }
390 ]
391}
392```
393
394For a larger example, see [Codex's model catalog](https://github.com/openai/codex/blob/main/codex-rs/models-manager/models.json).
395
396Set `model_catalog_json` in `config.toml` to the absolute path of the file.
397Restart Codex, select **Gateway model**, and send a request. Check that the
398gateway received the model ID you set in `slug`.
399
400For an alias of a bundled model, copy its full catalog entry for your Codex
401version and change its `slug` and `display_name`. If the alias has no migration target, set `upgrade` to `null`. This preserves the model's
402context window, reasoning options, and tool settings.
403
404### Serve a catalog to clients
405
406This page is for developers implementing the Codex Models format, which defines
407the model catalog and powers the model picker. If you build an inference
408provider, such as a gateway or cloud service, use this specification to let the
409Codex desktop app and CLI discover your models and use their instructions and
410capability settings.
411
412If you administer an enterprise and want to control the model catalog, see the
413[`model_catalog_url` configuration guidance](https://learn.chatgpt.com/docs/enterprise/roll-out-a-gateway#serve-a-remote-catalog).
414
415To support the format, implement an authenticated catalog endpoint. Fetch your
416upstream provider's current defaults for the requesting Codex version, apply
417your overrides, and return the resulting catalog.
418
419
420
421> Illustration: Cloud providers fetch OpenAI model defaults for the requesting Codex version. Gateways read catalogs from their cloud or upstream providers, then apply caller filtering, aliases, and supported settings. Codex reads the gateway catalog to show available models and use compatible settings. Reads are authenticated at each step, and catalog responses return toward Codex. Optional enterprise or custom model definitions can feed the gateway and need not originate from OpenAI.
422
423
424
425### Implement the catalog endpoint
426
427The default catalog endpoint is `/models` under the provider's `base_url`.
428For example, with `base_url = "https://gateway.example.com/v1"`, Codex requests:
429
430```http
431GET /v1/models?client_version=0.162.1
432Authorization: Bearer <PROVIDER_ACCESS_TOKEN>
433```
434
435Default discovery supports command-backed authentication and Codex-backend
436authentication, such as ChatGPT. For a custom provider using API-key authentication
437without command-backed authentication, set `model_providers.<id>.model_catalog_url`
438explicitly to enable remote discovery. An API key alone doesn't trigger discovery
439at the default path.
440
441Use `model_catalog_url` to choose a full catalog URL, such as
442`https://gateway.example.com/codex/models`. It can also point to the default
443`/v1/models` endpoint. Codex uses this URL directly without appending `/models`.
444For API-key discovery, keep `features.api_key_model_discovery` enabled; it is on
445by default. Custom headers alone don't enable discovery.
446
447Codex sends the selected provider's authentication and configured headers, and
448appends `client_version` and any provider `query_params`. Host the catalog on a
449service authorized to receive those credentials.
450
451Authenticate the caller, fetch the corresponding upstream defaults, apply your
452overrides, and return the complete `ModelsResponse` JSON directly. Give every
453entry a unique, nonempty `slug`. For an explicit `model_catalog_url`, Codex rejects
454redirects and responses larger than 1 MiB. Continue enforcing model access on
455inference requests.
456
457Remove any effective `model_catalog_json` setting from clients using the endpoint:
458the local file takes precedence and prevents remote fetching.
459
460### Match the client's schema
461
462Read the `client_version` query parameter on the catalog request. Codex sends its
463CLI version as `major.minor.patch`, with any prerelease suffix removed. For desktop
464clients, this is the bundled CLI version.
465
466Use the matching `rust-v<version>` tag in the public Codex repository, or the
467exact source commit for a custom build. These links use `rust-v0.162.1`; select
468the revision matching your client:
469
470- Read the [`ModelsResponse` and `ModelInfo` response types](https://github.com/openai/codex/blob/rust-v0.162.1/codex-rs/protocol/src/openai_models.rs) for the schema.
471- Inspect the [bundled `models.json`](https://github.com/openai/codex/blob/rust-v0.162.1/codex-rs/models-manager/models.json) for a complete example. This is catalog data, not a JSON Schema document.
472
473The bundled file is a release snapshot. Fetch current defaults before producing
474your catalog.
475
476### Fetch current upstream defaults
477
478Cloud providers serving OpenAI models fetch defaults from OpenAI. Gateways read
479their cloud or upstream provider's catalog so they retain the deployed model's
480settings and account and region availability. Pass the requesting Codex version
481at each step, and authenticate separately to each endpoint.
482
483To fetch defaults directly from OpenAI, call the Codex models endpoint with the
484same `client_version`. For example, with an OpenAI API key:
485
486```bash
487curl --fail --silent --show-error \
488 'https://chatgpt.com/backend-api/codex/models?client_version=0.162.1' \
489 -H "Authorization: Bearer $OPENAI_API_KEY"
490```
491
492For a ChatGPT integration, use the caller's ChatGPT access token and
493`ChatGPT-Account-ID` header when applicable. Use credentials authorized for the
494upstream endpoint; your gateway's own API key doesn't authenticate to OpenAI.
495
496Parse the full response, including its top-level `models` array. This endpoint
497returns Codex metadata such as instructions, reasoning defaults, tool settings,
498context limits, and service tiers. The public `/v1/models` endpoint doesn't
499supply this catalog.
500
501Refresh these defaults even when the Codex version hasn't changed. Keep requests
502scoped to the intended upstream identity and honor response cache controls:
503catalogs can depend on the caller's access. Keep your overrides separate so you
504can reapply them to fresh defaults.
505
506### Apply provider overrides
507
508Change field values while preserving the version's response structure:
509
510- Filter models to those the caller can use. Map each `slug` to a supported
511 inference route, and adjust `display_name`, `description`, or `priority`.
512 For an alias without a model migration, set `upgrade` to `null`.
513- Set reasoning options, context limits, input modalities, and service tiers to
514 values your model and route support. Keep defaults within the supported
515 choices. For a route without service tiers, clear `service_tiers` and
516 `additional_speed_tiers`, and set `default_service_tier` to `null`.
517- Preserve upstream instructions and tool settings unless you have tested a
518 replacement. Metadata doesn't add model capabilities or grant inference access.
519
520For a gateway model alias, see how to
521[supply model metadata](https://learn.chatgpt.com/docs/enterprise/roll-out-a-gateway#use-a-model-catalog-for-custom-names).
522Test the resulting catalog with each supported Codex version.
523
524### Use the public Rust types
525
526Use crates from the same public Git tag or commit as the client's schema:
527
528- Use [`codex-protocol`](https://github.com/openai/codex/tree/rust-v0.162.1/codex-rs/protocol) for `codex_protocol::openai_models::{ModelsResponse, ModelInfo}`. Parse with `serde_json::from_slice::<ModelsResponse>()`, edit `catalog.models`, and serialize the whole wrapper with `serde_json::to_vec()`. The wrapper handles compatibility fields for model instructions.
529- Use [`codex-models-manager::bundled_models_response()`](https://github.com/openai/codex/blob/rust-v0.162.1/codex-rs/models-manager/src/lib.rs) to load that revision's static bundled catalog as a `ModelsResponse`. It doesn't fetch current upstream defaults.
530
328## Related docs531## Related docs
329 532
330- [Configure the provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider)533- [Configure the provider](https://learn.chatgpt.com/docs/enterprise/connect-to-a-gateway#configure-the-provider)