Codex setup
Use Codex CLI with BRUCEAI. An OpenAI key gives you GPT-6.1 Sol, GPT-6 Astra / Sol / Luna, GPT-5.6 Sol / Terra / Luna and GPT-5.5.
To avoid touching your existing Codex or ChatGPT login, put the BRUCEAI config in a separate folder and isolate it with CODEX_HOME. Your personal ~/.codex stays unchanged and your normal codex command keeps working.
Grok and DeepSeek work in Codex the same way; just swap in the matching key and model id. See the Grok and DeepSeek guides on the left. If you would rather not edit files by hand, the CC Switch guide on the left offers a one-click import.
Copy these model IDs into config files, API request bodies, or any OpenAI-compatible client that asks for a model name. Each group needs the matching key type.
Prepare your API key
After signing in, open the API key page to create or copy a key. It looks like sk-or-v1-xxxxxxxxxxxx. Treat it like a password.
Create API keyCodex uses the OpenAI-compatible interface, so this Base URL must include /v1.
Click Create API key, give it a name you will recognize, then pick the key type by the models you plan to call:
- OpenAI key
- Serves gpt-6.1-sol, gpt-6-astra, gpt-6-sol, gpt-6-luna, gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna and gpt-5.5. Works with Codex, GitHub Copilot and any OpenAI-compatible client.
- Grok key
- Serves grok-4.7, grok-4.6 and grok-4.5. Works with Grok Build, Codex and any OpenAI-compatible client.
- DeepSeek key
- Serves deepseek-v4.1-flash: 1M context, thinking mode, tool calling and image input. Works with Codex and any OpenAI-compatible client.
A key only serves its own provider's models. Sending a GPT model id with a Grok key, or a Grok id with an OpenAI key, is refused with a 400. Create one key per provider if you use several.
Do not share your API key with anyone, and do not commit it to GitHub, GitLab, or any public repository.
The commands below switch to the system you choose.
Install and verify Codex CLI
Run npm install only if Codex CLI is not installed yet, then confirm with codex --version.
On an Ubuntu server, switch to Node.js 22 with NVM first so node and npm come from the same environment. After npm install, add the global bin directory to PATH and refresh the command cache; otherwise the install can succeed while the shell still reports codex not found.
node -v
npm -v
npm install -g @openai/codex@latest
hash -r
command -v codex
codex --versionIf Ubuntu prints “Command 'codex' not found” and suggests Snap, do not run snap install codex. Select Ubuntu server, finish the PATH setup, and make sure command -v codex resolves to the npm-installed binary.
Create an isolated config folder
mkdir -p ~/.codex-bruceaiOpen config.toml
Open config.toml with the command below. If the file does not exist, the editor will create it.
nano ~/.codex-bruceai/config.tomlPaste config.toml contents
Paste the full content below into config.toml. The default model is gpt-5.6-terra, a balance of capability and cost; you can switch any time with /model inside Codex. In Windows Notepad, press Ctrl+S to save, then close the window.
model_provider = "OpenAI"
model = "gpt-5.6-terra"
model_reasoning_effort = "high"
disable_response_storage = true
[model_providers.OpenAI]
name = "OpenAI"
base_url = "https://api.bruceai.net/v1"
wire_api = "responses"
requires_openai_auth = trueOpen auth.json
Open auth.json with the command below, then prepare to paste your OpenAI key.
nano ~/.codex-bruceai/auth.jsonPaste auth.json contents
Replace sk-or-v1-your-key with the OpenAI key you created on the API key page. auth.json is a secret; never commit it to Git. In Windows Notepad, press Ctrl+S to save, then close the window.
{ "OPENAI_API_KEY": "sk-or-v1-your-key" }Start Codex
CODEX_HOME="$HOME/.codex-bruceai" codexSwitch models inside Codex
After Codex starts, type /model to switch between the models BRUCEAI supports.
You can only switch to models of the provider your key belongs to: an OpenAI key uses the GPT family, a Grok key uses grok-4.7 / grok-4.6 / grok-4.5, and a DeepSeek key uses deepseek-v4.1-flash. Anything else returns a 400.
/model
# OpenAI key
gpt-6.1-sol
gpt-6-astra
gpt-6-sol
gpt-6-luna
gpt-5.6-sol
gpt-5.6-terra
gpt-5.6-luna
gpt-5.5
# Grok key
grok-4.7
grok-4.6
grok-4.5
# DeepSeek key
deepseek-v4.1-flashIf you select an unsupported model, the BRUCEAI backend returns the list of models this key can use.
Optional: create an alias
If you do not want to type CODEX_HOME every time, create a bcodex command. macOS goes in ~/.zshrc, an Ubuntu server in ~/.bashrc; in Windows Notepad, paste the function at the end of the file, press Ctrl+S, then close the window.
echo 'alias bcodex="CODEX_HOME=\"$HOME/.codex-bruceai\" codex"' >> ~/.zshrc
source ~/.zshrcAfter that, run bcodex for BRUCEAI. Your original codex command still uses your personal ChatGPT / Codex settings.
Troubleshooting
401 / invalid token: make sure the key is complete, has no extra spaces, and starts with sk-or-v1-.
400 / unsupported_model: the model id does not belong to this key's provider. An OpenAI key only serves the GPT family; create a Grok or DeepSeek key for those models.
403 / requires openai: contact the administrator to confirm account permissions.
Codex still uses your own ChatGPT account: make sure you started it with CODEX_HOME pointing at ~/.codex-bruceai and that base_url in config.toml is correct.
400 / conversation too large: compact the conversation with /compact in Codex, or start a new one.