Run the real OpenAI Codex CLI against an Azure AI Foundry deployment through a local token-refreshing passthrough, with no request translation.
pks codex [subcommand] [options]$ pks codex initPreflight a deployment and write the managed provider block
$ pks codexLaunch codex against the default Foundry deployment
$ pks codex -m gpt-5.6-solPick a specific Foundry deployment for this run
$ pks codex resume --lastResume the most recent Codex session through Foundry
$ pks codex --print-envPrint the launch command instead of starting codex
pks codex runs the genuine upstream Codex CLI — the @openai/codex package — against an Azure AI Foundry Responses-API deployment. Nothing about the Codex request or response is translated; pks only supplies authentication and points Codex at a local endpoint.
pks codex starts a loopback HTTP passthrough on 127.0.0.1, injects a fresh Microsoft Entra ID bearer token into every Codex Responses request, and forwards the body through unchanged. Because the token is minted per request rather than exported once at launch, a Codex session outlives the roughly one-hour lifetime of an Entra access token.
codex CLI, with its own interface, sessions, and tooling.pks codex init writes one marker-delimited block into ~/.codex/config.toml and leaves everything else in that file alone.pks claude codex runs Claude Code against a Foundry GPT/Codex deployment through a translating proxy. pks codex is the opposite choice — the real Codex CLI, billed through Foundry.~/.codex/config.toml gets a provider block pointing at the loopback proxy. No key or token is written into it.pks codex init makes a real Foundry Responses call against the chosen deployment before writing any configuration, so a wrong deployment name surfaces immediately.resume, exec, fork, archive, unarchive, and delete are forwarded verbatim to the real Codex CLI through the same authenticated path.response.failed events are appended to ~/.pks-cli/codex-passthrough-failures.log.Authentication comes from pks foundry init. Every codex subcommand checks that you are authenticated and that a Foundry resource endpoint is resolved; without both it prints an error pointing at pks foundry init and exits 1.
On launch, pks resolves a deployment name, starts the passthrough on a loopback port, generates a random per-run token that the passthrough validates on every incoming request, and then executes the real codex binary with the pks-foundry provider selected. Codex talks to 127.0.0.1; the passthrough talks to Foundry. Two files hold state: ~/.codex/config.toml holds the managed provider block, and ~/.pks-cli/codex.json holds the pks-side launch defaults written by init.
resume, fork, archive, unarchive, and delete do.| Subcommand | Purpose | Guide |
|---|---|---|
run | Launch codex against the resolved Foundry deployment (default) | Launch the Codex CLI on Foundry |
resume | Reattach to an earlier session by ID or with --last | Resume a Codex session |
exec | Codex's non-interactive execution mode | Run Codex non-interactively |
fork | Branch a session into a second continuation | Manage Codex sessions |
archive | Move a session out of the active set | Manage Codex sessions |
unarchive | Restore an archived session | Manage Codex sessions |
delete | Permanently delete a session — no undo | Manage Codex sessions |
init | Preflight a deployment and write the managed config block | Set up pks codex |
Running pks codex with no subcommand is identical to pks codex run. Full flag, argument, and environment detail lives on the pks codex CLI reference.
| Setting | Value |
|---|---|
| Deployment | gpt-5-codex |
| Loopback port | 8788 |
| Reasoning effort | medium |
| Approvals and sandbox | Bypassed unless --safe is passed |
pks codex init overwrites these defaults in ~/.pks-cli/codex.json, and -m, -p, and -e override them for a single run. See the pks codex CLI reference for the resolution order.
Drive Codex's own scripted execution mode through the Azure AI Foundry passthrough, giving a resumed or fresh session one instruction without a terminal UI.
pks codex exec [ARGS] [options]
Authenticate with Azure AI Foundry, preflight a deployment, and write the managed pks-foundry provider block into your Codex config in one command.
pks codex init --model gpt-5-codex
The loopback proxy behind pks codex — per-request Entra tokens, the managed Codex config block, request sanitizing, and where silent failures are recorded.
Complete command, flag, file, and environment-variable reference for pks codex — launch, init, session commands, and the Azure AI Foundry passthrough.
pks codex [subcommand] [options]
Reattach to an earlier Codex session by ID or with --last, with Azure AI Foundry authentication injected transparently by the pks loopback passthrough.
pks codex resume [ARGS] [options]
Start the upstream Codex CLI against an Azure AI Foundry deployment, choose the model and reasoning effort, and control the sandbox and loopback port.
pks codex run [ARGS] [options]
Fork, archive, unarchive, and delete Codex sessions over the pks loopback passthrough — the session lifecycle verbs, what pks contributes, and what stays native Codex behavior.
pks codex [options] <fork|archive|unarchive|delete> [ARGS]