Grok setup
Create a Grok key to use Grok 4.6 and Grok 4.5. Every request goes through https://api.bruceai.net/v1, where BRUCEAI authenticates and bills it; see the pricing page for rates.
Codex uses the standard HTTP Responses API; the Responses WebSocket is not offered.
Five ways to connect: Grok Build, xAI's official terminal agent (recommended, about one minute), the CC Switch UI for the Codex client, a custom provider in ZCode, Codex CLI with a hand-written config, or any OpenAI-compatible client. All five use the same key; pick one.
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 keyGrok Build, Codex and OpenAI-compatible clients all use https://api.bruceai.net/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-astra, 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.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 steps below switch to the method you choose.
xAI's official terminal coding agent. Install it, paste one config block, done in about a minute.
The commands below switch to the system you choose.
Create a Grok key
Sign in to BRUCEAI, open API keys, click Create API key and choose the Grok type.
The full key is shown only once; copy it before closing the dialog.
Install Grok Build
After installing, close the terminal, open a new window and run grok --version to confirm.
curl -fsSL https://x.ai/cli/install.sh | bashOpen the config file
The config file is ~/.grok/config.toml on macOS / Linux and %USERPROFILE%\.grok\config.toml on Windows.
mkdir -p ~/.grok
nano ~/.grok/config.tomlTo save in nano: Ctrl+O, Enter, Ctrl+X.
Paste this config
Paste the block below and replace only the key with your own Grok key. Keep any existing [marketplace], [ui] or other sections; do not overwrite the whole file.
[models]
default = "bruceai-grok"
web_search = "bruceai-grok"
[model.bruceai-grok]
model = "grok-4.6"
name = "Grok (BRUCEAI)"
base_url = "https://api.bruceai.net/v1"
api_key = "sk-or-v1-your-key"
api_backend = "responses"
context_window = 500000
[ui]
fork_secondary_model = "bruceai-grok"bruceai-grok is just a local alias and [models].default must point at it; the model actually sent is model = "grok-4.6" (grok-4.5 also works). The /v1 at the end of base_url is required.
Sign out of the official login and test
Grok Build prefers a session left by the browser login and will keep opening the login page unless you sign out first. Run the commands below; the last line is the test.
A plain OK with no browser login means you are on BRUCEAI.
grok logout
rm -f ~/.grok/auth.json
grok -p "Reply with OK only"Open your project and start
Change to your project directory and run grok.
“Grok (BRUCEAI)” and “Logged in with API key” in the bottom-right corner mean you are on BRUCEAI; /model confirms it as well.
grokTroubleshooting
Still asked to log in: make sure you ran grok logout, auth.json is gone, and [models].default points at bruceai-grok. A .grok/config.toml inside the project overrides the user config.
401 / invalid token: the key is incomplete, has extra spaces, or is not a Grok key.
400 / unsupported_model: model must be grok-4.6 or grok-4.5.
404: base_url must end with /v1, not https://api.bruceai.net.
Sub-tasks open the official login: set fork_secondary_model under [ui] to bruceai-grok too.
Response format errors: try api_backend = "responses" first; if it still fails, switch to chat_completions.