Store the API key in user settings
api keys and auth
// what it does
Set "apiKey" in ~/.grok/user-settings.json to authenticate every project without an environment variable. The same file also holds baseURL, defaultModel, and a models list, making it the durable home for global preferences.
// shell
$ ~/.grok/user-settings.json// gotcha
It is plain JSON in your home directory, readable by anything running as you. A syntax error such as a trailing comma or an unquoted key makes the CLI silently ignore the file and fall back to env vars — lint it if auth stops working.