GreenTokens

Search

Search models, guides, docs and the FAQ.

Clients

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/grok

Quick setup

Run the setup script in a terminal and choose Grok CLI from its list. It finds Grok CLI's settings, checks your API key, and makes the changes described below for you, backing up each file first. It can set up your other agents in the same run.

curl -fsSL https://www.greentokens.io/setup.sh | bash

The script saves your key as the GREENTOKENS_API_KEY environment variable, which Grok CLI reads. Open a new terminal window afterwards so it picks it up.

To undo, run the same command again and choose Remove.

Add 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"
  • model is the GreenTokens model ID sent to the API. Any text model from the models page works, not just Grok.
  • base_url is https://api.greentokens.io/v1: Grok CLI adds /chat/completions itself.
  • env_key names 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 one

Switch models inside a session with /model or Ctrl+M.