To get started you will need to set up an API key for Duke GPT using the AI Dashboard tool.
-
Once logged in you should navigate to the AI Gateway tab and select the "Create Api Key" button in the upper right.
-
Pick a identifiable nickname for your key (e.g. Codex) and leave the Fund Code entry blank.
-
Read through the usage agreement and click "I Agree" when finished.
-
Copy the key to your clipboard using the provided buttons and save it somewhere safe (Password manager, a text file, etc.) Note that once this modal dialog is closed you will not be able to recover this key - you will have to regenerate the key or delete and create a new key.
After creating your API key you will need to make it available to other tools, the easiest way of doing this is assigning it as an environment variable. Depending on your operating system and shell the directions vary slightly, see below for various options.
If you do not know what shell you are using you run echo $SHELL in the terminal to see which binary is being used.
Bash:
export DUKEGPT_API_KEY="your-api-key-here"
# Add to your .bashrc to make it permanent
echo 'export DUKEGPT_API_KEY="your-api-key-here"' >> ~/.bashrcZsh:
export DUKEGPT_API_KEY="your-api-key-here"
# Add to your .zshrc to make it permanent
echo 'export DUKEGPT_API_KEY="your-api-key-here"' >> ~/.zshrcWindows (Command Prompt):
set DUKEGPT_API_KEY=your-api-key-here
# Or permanently via System Properties > Environment VariablesWindows (PowerShell):
$env:DUKEGPT_API_KEY="your-api-key-here"
# Add to your PowerShell profile to make it permanentWe have already installed codex on the departmental servers - it is install in /usr/local/bin/codex and should be available in your path.
If you want to install codex directly you can use one of the following methods depending on your OS:
# Using Homebrew
brew install codex
# Using npm
npm i -g @openai/codex# Using npm
npm i -g @openai/codex
# Using curl (direct download)
curl -L https://github.com/openai/codex/releases/latest/download/codex-linux -o codex
chmod +x codex
sudo mv codex /usr/local/bin/# Using npm
npm i -g @openai/codex
# Using winget
winget install OpenAI.Codex
# Direct download: Download the Windows executable from
# https://github.com/openai/codex/releases/latestOnce installed you will need to adjust codex's configuration to use the DukeGPT API rather than OpenAI's. To do this we will Create (or edit) your codex config.toml file.
On macOS or Linux this should be located in ~/.codex/config.toml and on Windows it should be in %USERPROFILE%\.codex\config.toml.
Make sure that it includes the following:
model = "gpt-5"
model_provider = "dukegpt"
[model_providers.dukegpt]
name = "OpenAI via DukeGPT"
base_url = "https://litellm.oit.duke.edu"
env_key = "DUKEGPT_API_KEY"For more details on configuration options in this file see config.md
-
Using DukeGPT has a relatively low daily limit of $1 of usage per day - this is relatively easy to exhaust so consider using a smaller model like
gpt-5-mini. -
The default requests per minute is fairly low and will likely trigger when using agentic tools like codex, particularly when doing a series of simple operations (e.g. exploring files in your repo). Usually there will be a handful of timeout errors but the process will manage to continue with the default waits that are used by codex. If things do end up timing out, just let it sit for a minute or two and then tell the tool to continue. It should pick up where it left off.
-
You can view the "spend" for your API key by selecting the "Manage" action from the AI Gateway tab. Note that this is updated at the end of each day so it will not reflect your current usage.
- See the following colab's article: Getting Started with Duke's AI Gateway: A Developer's Guide

