Skip to content

Setting up OpenAI Codex CLI on DCC

Codex CLI is OpenAI’s coding agent that can be run on a terminal. It can read, change, and run code and assist with agentic AI tasks.

Codex CLI can be used on DCC, either through a SSH terminal or an Open OnDemand Jupyter/RStudio container terminal.

Once you are connected to DCC, enter the following commands on the terminal to first setup Node.js through nvm in your home directory.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

Then do,

source ~/.bashrc

to reload your shell. Next, install Node.js with,

nvm install node 

Now install codex,

npm i -g @openai/codex

Launch the application with,

codex

If this is the first time you are using it, you will see the following setup screen,

                                      
            _,+_=+*++=+__             
         _=|+|\_,_==,|_|*|+_          
       ,"+|',;*`    "~:+|\;||,        
      /;|*;/`          _;;\||;\       
     //|`/'          ,/,,'*/*\|\      
    ,\|"/`         _***''/*'|~\|,     
    `||"|         /:/. _|`  "!|'*     
    ~/| |         |"|,_\,   | */|     
    ^"\ |+~;=====;=|_*|_"\_ | |~|     
    |\\_|"="       /`\ \|_\,~ \_|     
     /'| | `"""""""   '`/;=|_/^/`     
      ,||_|.             ,/|\^/`      
       \ |,'/__       _.";*/+/        
         \=\+;*+\~==_++"-_+*`         
           "~!*=\~__+__**`            
                                      

  Welcome to Codex, OpenAI's command-line coding agent

  Sign in with ChatGPT to use Codex as part of your paid plan
  or connect an API key for usage-based billing

> 1. Sign in with ChatGPT
     Usage included with Plus, Pro, Team, and Enterprise plans

  2. Sign in with Device Code
     Sign in from another device with a one-time code

  3. Provide your own API key
     Pay for what you use

  Press Enter to continue

Select option (2) and follow the instructions provided to complete the process. You may either use your personal OpenAI account or Duke's AI Gateway account. For your personal account, you may have to login to your ChatGPT settings and toggle "Enable device code authorization for codex" to get this to work (Thank you, Dr. Elaine Guevara for pointing this out). If you are using Duke's AI Gateway account, make sure you sign in with your Duke credentials.

Now you are all set to use codex. Enjoy!

Important!

If you will be using codex to perform computationally intensive tasks, first request an interactive session on DCC and run it on that.