GROK_TEXT_API

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.

Model IDs

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.

GrokNeeds a Grok key
BEFORE YOU START

Prepare your API key

1. Open the API key page

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 key
3. Confirm the Base URL
https://api.bruceai.net/v1

Grok Build, Codex and OpenAI-compatible clients all use https://api.bruceai.net/v1.

2. Create a key for the provider you want

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.

Choose a setup method

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.

Choose your system first

The commands below switch to the system you choose.

STEP 01

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.

STEP 02

Install Grok Build

After installing, close the terminal, open a new window and run grok --version to confirm.

macOS / Linux
bash
curl -fsSL https://x.ai/cli/install.sh | bash
STEP 03

Open the config file

The config file is ~/.grok/config.toml on macOS / Linux and %USERPROFILE%\.grok\config.toml on Windows.

macOS / Linux
bash
mkdir -p ~/.grok
nano ~/.grok/config.toml

To save in nano: Ctrl+O, Enter, Ctrl+X.

STEP 04

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.

toml
[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.

STEP 05

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.

macOS / Linux
bash
grok logout
rm -f ~/.grok/auth.json
grok -p "Reply with OK only"
STEP 06

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.

Grok Build
bash
grok
STEP 07

Troubleshooting

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.