OpenAI Codex Setup
OpenAI Codex CLI is OpenAI’s command-line coding agent. Because KeyMaker is OpenAI-compatible, you can point Codex at KeyMaker and run it against campusGenAI’s models — billed to your sponsor’s funding — instead of a personal OpenAI account.
Prerequisites
Section titled “Prerequisites”- Terminal access (macOS, Linux, or Windows PowerShell)
- A valid KeyMaker API key from your sponsor — see Getting Started
You can check whether Codex is already installed:
codex --versionIf you see a version number, skip to Save your API key.
Install Codex CLI
Section titled “Install Codex CLI”macOS or Linux:
curl -fsSL https://chatgpt.com/codex/install.sh | shWhen prompted Start Codex now?, press y.
Windows (PowerShell):
powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"Then verify the installation on either platform:
codex --versionIf you see a version number, the installation was successful.
Save your API key
Section titled “Save your API key”Store your KeyMaker key as an environment variable rather than putting it directly in a config file.
macOS / Linux:
echo 'export KEYMAKER_API_KEY="YOUR_KEY_HERE"' >> ~/.zshrc && source ~/.zshrcConfirm it was saved:
echo $KEYMAKER_API_KEYWindows (PowerShell):
[Environment]::SetEnvironmentVariable("KEYMAKER_API_KEY", "YOUR_KEY_HERE", "User")Restart PowerShell, then verify:
echo $env:KEYMAKER_API_KEYSee available models
Section titled “See available models”List the models your KeyMaker account can use:
curl https://thekeymaker.umass.edu/v1/models \ -H "Authorization: Bearer $KEYMAKER_API_KEY"Make note of the model name you want to use (for example, gpt5).
Configure Codex
Section titled “Configure Codex”-
Create the Codex configuration directory:
Terminal window mkdir -p ~/.codex -
Open (or create) the configuration file:
Terminal window nano ~/.codex/config.toml -
Add the following configuration, then save. Replace
gpt5with any model from your available list if your team uses a different one:model_provider = "keymaker"model = "gpt5"model_reasoning_effort = "high"[model_providers.keymaker]name = "Keymaker"base_url = "https://thekeymaker.umass.edu/v1"env_key = "KEYMAKER_API_KEY"wire_api = "responses"In
nano, save withCtrl + OthenEnter, and exit withCtrl + X. (The same shortcuts work on macOS, Linux, and Windows via WSL/Git Bash.) -
Confirm the file was saved:
Terminal window cat ~/.codex/config.toml
Verify the setup
Section titled “Verify the setup”Start Codex:
codexThen enter a prompt to confirm it’s routing through KeyMaker:
Say hello and tell me which model provider I am using.If Codex responds successfully, your configuration is working — all Codex requests now route through KeyMaker, using the models, permissions, and usage controls of the KeyMaker platform.
For existing Codex users
Section titled “For existing Codex users”If you’ve previously logged into Codex with a ChatGPT or OpenAI account, log out so Codex uses the KeyMaker provider:
codex logoutIf Codex still uses your old configuration after that, remove the config directory and reinstall:
rm -rf ~/.codexThen reinstall Codex and repeat the setup from Install Codex CLI.
Troubleshooting
Section titled “Troubleshooting”Authentication errors
Confirm your key is available with echo $KEYMAKER_API_KEY, then test it directly:
curl https://thekeymaker.umass.edu/v1/models \ -H "Authorization: Bearer $KEYMAKER_API_KEY"If that fails, verify the key is correct, hasn’t expired or been revoked, and re-copy it from the KeyMaker portal if needed.
Model not found
List the models available to your account (the curl command above) and update the model value in ~/.codex/config.toml to match.
Codex still uses OpenAI
Run codex logout, restart your terminal, and try again. If it persists, rm -rf ~/.codex, reinstall Codex, and repeat the setup.
Configuration file not found
Create the directory and file manually: mkdir -p ~/.codex then nano ~/.codex/config.toml.
Next steps
Section titled “Next steps”- Usage and Best Practices — monitoring usage, cost awareness, and security
Need help?
Section titled “Need help?”- Get help: Contact us
- About campusGenAI: Main site
Your interface may look slightly different depending on your institution’s deployment.