Codex Grok: Use Grok 4.5 in Codex
This guide shows you how to add Grok 4.5 to the Codex model picker with Codex Router. Grok offers two authentication paths — the official Grok CLI OAuth session and a separately billed xAI API key — and the OAuth path adds hosted web search and x_search tools to the routed model.
What you can add
| Picker label | Model ID | Authentication |
|---|---|---|
| Grok 4.5 (OAuth) | grok-oauth/grok-4.5 | Official Grok CLI OAuth session |
| Grok 4.5 (API) | grok-api/grok-4.5 | Separately billed xAI API key |
Choose your authentication
- Grok OAuth reuses the official Grok CLI credential at
~/.grok/auth.json. The router sends it only to xAI’s documented Grok CLI inference proxy. On this path, the router also attaches bare hostedweb_searchandx_searchtools — the same agentic surface Grok Build uses — and xAI’s backend decides when to search and how to filter results. - Grok API uses a separately billed xAI API key entered through a hidden prompt. Use this if you do not want to install the Grok CLI, or on Windows where Smart App Control may block the CLI (see below).
Enable Grok OAuth
Install the official Grok CLI and authenticate:
npm install -g @xai-official/grok
grok login --oauth
Then enable the provider:
./bin/model-router codex providers enable grok-oauth
./bin/model-router codex doctor
The OAuth token stays in ~/.grok/auth.json and is sent only to the Grok CLI inference proxy. Never copy it into Codex config, an API-key file, or an environment variable.
Enable Grok API
./bin/model-router codex provider-key grok-api set
./bin/model-router codex providers enable grok-api
On Windows, use ./codex-router.ps1 codex provider-key grok-api set. The hidden prompt disables terminal echo and the key is stored in a protected per-user file.
Verify the integration
./bin/model-router codex doctor
./bin/model-router codex providers
The chosen provider must report SHOW and ready. Then fully quit Codex, reopen it, create a new task, and check the picker for Grok 4.5. For a live check:
./bin/test-model 'grok-oauth/grok-4.5' --live --yes
Windows caveat: Smart App Control
On Windows, Smart App Control can block the official Grok CLI. If grok --version reports spawn UNKNOWN, “An Application Control policy has blocked this file,” or a Smart App Control notification, Grok OAuth cannot complete login or refresh its session. Keep Smart App Control enabled — it does not offer a safe per-app bypass — and use the grok-api provider with an xAI API key instead:
./model-router.ps1 codex provider-key grok-api set
./model-router.ps1 codex providers enable grok-api
./model-router.ps1 codex doctor
An OAuth session created while the executable was allowed is not a durable workaround: the router invokes the official CLI again near token expiry, so the session eventually stops refreshing if Windows blocks the executable later.
Common pitfalls
- OAuth and API are separate billing systems. A Grok CLI subscription does not pay for
grok-apiusage, and an xAI API key cannot refresh a Grok OAuth session. - Search behavior is upstream-controlled. The router attaches the search tools but takes no search env knobs or request-side filter configuration; xAI decides when and how to search.
- Provider policy risk. xAI may restrict or block proxy traffic. Using Grok through Codex Router is at your own risk.
Official links
Related: models overview, Windows install notes, troubleshooting.