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 nodeAfter the installation, confirm:
node -v
npm -vInstall Grok CLI
Install globally with npm:
npm install -g @vibe-kit/grok-cliAfter the installation, verify:
grok --versionConfigure the connection
Grok CLI offers three configuration methods with the following precedence: command-line arguments > environment variables > configuration file.
Method 1: Environment variables (recommended)
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/v1Launch and use
Once configured, simply run:
grokStart 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_KEYis correct - Whether
GROK_BASE_URL/baseURLpoints to the correct service address (the/v1suffix 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
/v1suffix - A custom default model is supported
Related links
- Official documentation: https://docs.aicentos.com/clients/grok-cli.html