Load the API key from a .env file
api keys and auth
// what it does
Grok CLI reads a .env file in the working directory, so a key can live next to the project. The repo includes a .env.example to copy and fill in, and the same file is where an optional MORPH_API_KEY goes.
// shell
$ cp .env.example .env$ echo 'GROK_API_KEY=xai-your-key' >> .env// gotcha
Add .env to .gitignore before putting a real xai- key in it, or you leak the secret on your next commit. The file is only read from the directory you launch grok in, so it applies per-project by design.