Skip to Content
aicentos

Grok CLI

Use aicentos in Grok CLI — connect through environment variables or a configuration file

Last updated:

Grok CLI is a command-line tool that uses the OpenAI-compatible interface, so a custom API address can be plugged in directly as its backend service.

Prerequisites

You need Node.js 18+ and npm installed first.

The recommended source is the official Node.js download page: https://nodejs.org/en/download

  • macOS/Windows: download and install the LTS version
  • Linux: install using the distro instructions

macOS users can also use Homebrew:

brew install node

After the installation, confirm:

node -v
npm -v

Install Grok CLI

Install globally with npm:

npm install -g @vibe-kit/grok-cli

After the installation, verify:

grok --version

Configure the connection

Grok CLI offers three configuration methods with the following precedence: command-line arguments > environment variables > configuration file.

Set the following environment variables:

export GROK_BASE_URL="https://aicentos.com/v1"
export GROK_API_KEY="your_api_key_here"

For a quick test, running the exports in the current shell is enough. To persist them, add the lines above to ~/.zshrc or ~/.bashrc, then run source ~/.zshrc to apply.

Method 2: Configuration file

Edit ~/.grok/user-settings.json:

{
  "apiKey": "your_api_key_here",
  "baseURL": "https://aicentos.com/v1",
  "defaultModel": "gpt-4o"
}

Method 3: Command-line arguments

Specify it through arguments at launch:

grok --base-url https://aicentos.com/v1

Launch and use

Once configured, simply run:

grok

Start a conversation in Grok CLI; if replies come back normally, the integration is working.

Verification and troubleshooting

If you hit authentication errors, check:

  • Whether GROK_API_KEY is correct
  • Whether GROK_BASE_URL / baseURL points to the correct service address (the /v1 suffix is required)

After confirming the configuration is correct, just restart.

Notes

  • Grok CLI uses the OpenAI-compatible interface, so configuration is simple and direct
  • The three configuration methods can be chosen freely; the environment variable method is recommended
  • The API address must include the /v1 suffix
  • A custom default model is supported