noninteractive.md +22 −0
111 111
112`codex exec` reuses saved CLI authentication by default. In CI, it's common to provide credentials explicitly:112`codex exec` reuses saved CLI authentication by default. In CI, it's common to provide credentials explicitly:
113 113
114### Use API key auth (recommended)
115
114- Set `CODEX_API_KEY` as a secret environment variable for the job.116- Set `CODEX_API_KEY` as a secret environment variable for the job.
115- Keep prompts and tool output in mind: they can include sensitive code or data.117- Keep prompts and tool output in mind: they can include sensitive code or data.
116 118
122 124
123`CODEX_API_KEY` is only supported in `codex exec`.125`CODEX_API_KEY` is only supported in `codex exec`.
124 126
127Use ChatGPT-managed auth in CI/CD (advanced)
128
129Read this if you need to run CI/CD jobs with a Codex user account instead of an
130API key, such as enterprise teams using ChatGPT-managed Codex access on trusted
131runners or users who need ChatGPT/Codex rate limits instead of API key usage.
132
133API keys are the right default for automation because they are simpler to
134provision and rotate. Use this path only if you specifically need to run as
135your Codex account.
136
137Treat `~/.codex/auth.json` like a password: it contains access tokens. Don't
138commit it, paste it into tickets, or share it in chat.
139
140Do not use this workflow for public or open-source repositories. If `codex login`
141is not an option on the runner, seed `auth.json` through secure storage, run
142Codex on the runner so Codex refreshes it in place, and persist the updated file
143between runs.
144
145See [Maintain Codex account auth in CI/CD (advanced)](https://developers.openai.com/codex/auth/ci-cd-auth).
146
125## Resume a non-interactive session147## Resume a non-interactive session
126 148
127If you need to continue a previous run (for example, a two-stage pipeline), use the `resume` subcommand:149If you need to continue a previous run (for example, a two-stage pipeline), use the `resume` subcommand: