Grok CLI
Add GreenTokens models to xAI's Grok CLI.
Install
Grok CLI (Grok Build) is xAI's terminal coding agent. It needs Node 20 or newer for the npm install.
npm install -g @xai-official/grokAdd GreenTokens models
Grok CLI supports custom OpenAI-compatible endpoints in its config file. Add one block per GreenTokens model you want to use:
~/.grok/config.toml
[models]
default = "grok-4.7"
[model."grok-4.7"]
model = "grok-4.7"
name = "Grok 4.7 (GreenTokens)"
base_url = "https://api.greentokens.io/v1"
env_key = "GREENTOKENS_API_KEY"
api_backend = "chat_completions"
[model."claude-sonnet-5"]
model = "claude-sonnet-5"
name = "Claude Sonnet 5 (GreenTokens)"
base_url = "https://api.greentokens.io/v1"
env_key = "GREENTOKENS_API_KEY"
api_backend = "chat_completions"modelis the GreenTokens model ID sent to the API. Any text model from the models page works, not just Grok.base_urlishttps://api.greentokens.io/v1: Grok CLI adds/chat/completionsitself.env_keynames the environment variable holding your key, so it never sits in the file.
Quote block names that contain dots:
[model."grok-4.7"], not [model.grok-4.7].Run it
export GREENTOKENS_API_KEY="sk-gt-…"
grok # uses the default model
grok -m claude-sonnet-5 # or pick oneSwitch models inside a session with /model or Ctrl+M.