How to Use Codex with Grok Bot: Set Up Codex on the Cloud Computer
Grok Bot is xAI's cloud-based AI agent. Each account includes a cloud Linux computer. This guide explains how to install and use Codex on that computer to write code and generate images. Eligible ChatGPT plans include Codex; check OpenAI's current plan information for availability and usage limits. Codex on the cloud computer can keep running when your local computer is off.
Follow these five steps. They take about 15 minutes.
What You Need
- A Grok Bot account: Grok Bot is available on the web, desktop, and mobile app at x.ai/bot. It is included in plans such as SuperGrok and Cursor Pro; each account has a cloud Linux computer. See the Grok Bot subscription guide for subscription details
- An eligible ChatGPT plan: Codex availability and usage limits can change. See OpenAI's information about using Codex with ChatGPT plans
- A browser that can open chatgpt.com: You will use it to enable the setting and sign in
You will need to take two actions yourself: enable the setting in Step 1, then open the login link and enter the code in Step 3. Grok Bot handles the other steps.
Step 1: Enable Device-Code Sign-In in ChatGPT
The cloud computer has no browser window for an interactive sign-in, so Codex needs device-code sign-in. This option is off by default and must be enabled first.
- Open chatgpt.com in a browser and sign in
- Select your profile icon in the lower-left corner, then choose Settings
- Select Security under account security and sign-in
- Find Enable device code authorization for Codex and turn it on. Sign-in requirements and setting locations can change; see OpenAI's CLI sign-in documentation. The setting is shown below

The step is complete when the switch is on. If the setting is missing from an organization or team account, ask the administrator to enable it.
Step 2: Create a Dedicated Codex Bot
Create a separate Bot for Codex so its coding and image-generation context stays separate from your other tasks.
- Open Grok Bot and start a conversation with the default main Bot
- Create a Bot and name it Codex

The step is complete when Codex appears in the Bot list on the left.
Step 3: Install and Sign In to Codex on the Cloud Computer
Grok Bot handles the installation. You only need to open the sign-in link and enter the code. The cloud computer is shared by all Bots on the account, so install and sign in once.
- Select Codex from the Bot list and send:
Install the Codex command-line tool on your cloud computer.
After it is installed, sign me in using a device code and send me the sign-in link and code.
After I finish signing in, test that Codex works.
- If sign-in fails, ask Grok Bot to diagnose the actual error. In the test documented here, the Bot traced the issue to the cloud computer's proxy settings. Switching to a direct connection fixed that issue. This only applies to the proxy issue observed in this test; diagnose other errors from their actual messages:


Wait for the Bot to say Codex is installed and send you a sign-in link and a code such as
XXXX-XXXXXOpen the link, sign in to your ChatGPT account, enter the code, and approve access

Return to the conversation and let Grok Bot run its test

The step is complete when the Bot confirms that the Codex test succeeded.
The sign-in page may warn that device codes are common phishing targets. Enter only the code sent by your own Bot. Codes expire; ask the Bot to generate a new one if needed.
Step 4: Teach the Bot How to Use Codex
Send this prompt once. After that, you can say “Use Codex” without explaining the setup each time.
In the Codex conversation, send:

Remember the steps for using Codex to write code and GPT Image to generate images.
When I say “Use Codex,” call Codex using those steps.
When you finish, send me the result and any generated files.The step is complete when the Bot confirms that it has saved the instructions.
Step 5: Write Code and Generate Images
Send a request to the Codex Bot. State what you want it to do and how it should deliver the result; otherwise, files may remain on the cloud computer.
Example 1: Create an expense-tracking webpage

Use Codex to build an expense-tracking webpage. It should record daily income and expenses and show monthly totals.
Send me the webpage file when it is ready, and tell me how to open it.
Expected result: an HTML file with this month's income, expenses, and balance; a transaction list; and a monthly expense bar chart.
Example 2: Generate an image (Codex calls GPT Image)
Use Codex to generate a Keqing avatar in a Grok Bot style.
Expected result: an image file. Replace “Keqing avatar” with any subject you want.
Optional: Use Codex on Your Local Computer
If you do not want to sign in to your ChatGPT account on the cloud computer, skip Steps 1 and 3 and ask Grok Bot to use Codex already installed on your local computer. The trade-off is that it stops when your computer is off.
- Install Codex locally and sign in (
npm install -g @openai/codex, then runcodexand follow the prompts) - Install the Grok Bot desktop app on the same computer and sign in to the same account
- Create a Bot, such as Local Codex, and send:
Codex CLI is installed on my computer and I am already signed in.
When Codex is needed, run it on my computer. Do not install or sign in to Codex on the cloud computer.
Test it once and confirm that it works.- When Grok Bot asks whether it can use this computer, select Allow. You will be asked to approve each Codex run.
| Cloud Codex (main setup) | Local Codex | |
|---|---|---|
| After your computer is off | Keeps running | Stops |
| Where the account is signed in | Cloud computer | Local computer only |
| Best for | Long tasks and overnight runs | Projects stored locally |
Frequently Asked Questions
How do I use Codex with Grok Bot?
What should I do if Codex device-code sign-in fails?
What if the Codex device code is invalid?
Which ChatGPT plan or quota does Grok Bot use with Codex?
Will Codex keep running after I shut down my computer?
What should I do if Grok Bot cannot install Codex?
Where is a file generated by Codex?
How do I revoke the Codex sign-in on the cloud computer?
Manual Troubleshooting Commands
For Codex CLI installation and command changes, check the official OpenAI Codex CLI documentation before using these troubleshooting commands:
npm install -g @openai/codex # Install Codex CLI
codex login --device-auth # Start device-code sign-in
codex exec "Introduce yourself in one sentence" # Check that Codex responds