auth.md +45 −2
26 26
27OpenAI bills API key usage through your OpenAI Platform account at standard API rates. See the [API pricing page](https://openai.com/api/pricing/).27OpenAI bills API key usage through your OpenAI Platform account at standard API rates. See the [API pricing page](https://openai.com/api/pricing/).
28 28
2929Recommendation is to use API key authentication for programmatic Codex CLI workflows (for example CI/CD jobs). Do not expose Codex execution in untrusted or publicly triggerable environments.Features that rely on ChatGPT credits, such as [fast mode](https://developers.openai.com/codex/speed), are
30available only when you sign in with ChatGPT. If you sign in with an API key,
31Codex uses standard API pricing instead.
32
33We recommend API key authentication for programmatic Codex CLI workflows, such
34as CI/CD jobs. Don't expose Codex execution in untrusted or public environments.
35
36### Use Codex access tokens for enterprise automation
37
38In ChatGPT Enterprise workspaces, admins can allow permitted members to create
39Codex access tokens for trusted, non-interactive Codex local workflows. Use an
40access token when automation needs ChatGPT workspace access, ChatGPT-managed
41Codex entitlements, or enterprise workspace controls without a browser sign-in.
42
43Access tokens are intended for trusted scripts, schedulers, and private CI
44runners. For general OpenAI API calls, continue to use Platform API keys.
45
46For setup steps, permissions, rotation, and revocation guidance, see
47[Access tokens](https://developers.openai.com/codex/enterprise/access-tokens).
30 48
31## Secure your Codex cloud account49## Secure your Codex cloud account
32 50
85 103
86If the active credentials don't match the configured restrictions, Codex logs the user out and exits.104If the active credentials don't match the configured restrictions, Codex logs the user out and exits.
87 105
88106These settings are commonly applied via managed configuration rather than per-user setup. See [Managed configuration](https://developers.openai.com/codex/security#managed-configuration).These settings are commonly applied via managed configuration rather than per-user setup. See [Managed configuration](https://developers.openai.com/codex/enterprise/managed-configuration).
107
108## Login diagnostics
109
110Direct `codex login` runs write a dedicated `codex-login.log` file under
111your configured log directory. Use it when you need to debug browser-login or
112device-code failures, or when support asks for login-specific logs.
113
114## Custom CA bundles
115
116If your network uses a corporate TLS proxy or private root CA, set
117`CODEX_CA_CERTIFICATE` to a PEM bundle before logging in. When
118`CODEX_CA_CERTIFICATE` is unset, Codex falls back to `SSL_CERT_FILE`. The same
119custom CA settings apply to login, normal HTTPS requests, and secure websocket
120connections.
121
122```shell
123export CODEX_CA_CERTIFICATE=/path/to/corporate-root-ca.pem
124codex login
125```
89 126
90## Login on headless devices127## Login on headless devices
91 128
141docker cp ~/.codex/auth.json MY_CONTAINER:"$CONTAINER_HOME/.codex/auth.json"178docker cp ~/.codex/auth.json MY_CONTAINER:"$CONTAINER_HOME/.codex/auth.json"
142```179```
143 180
181For a more advanced version of this same pattern on trusted CI/CD runners, see
182[Maintain Codex account auth in CI/CD (advanced)](https://developers.openai.com/codex/auth/ci-cd-auth).
183That guide explains how to let Codex refresh `auth.json` during normal runs and
184then keep the updated file for the next job. API keys are still the recommended
185default for automation.
186
144### Fallback: Forward the localhost callback over SSH187### Fallback: Forward the localhost callback over SSH
145 188
146If you can forward ports between your local machine and the remote host, you can use the standard browser-based flow by tunneling Codex's local callback server (default `localhost:1455`).189If you can forward ports between your local machine and the remote host, you can use the standard browser-based flow by tunneling Codex's local callback server (default `localhost:1455`).