Choose which model a run uses
models and endpoints
// what it does
Select a model with --model (short -m) or the GROK_MODEL environment variable, for example grok-code-fast-1 (the built-in default) or grok-4-latest. Precedence runs --model flag > GROK_MODEL > your default in user-settings > the system default grok-code-fast-1.
// shell
$ grok -m grok-4-latest$ export GROK_MODEL=grok-code-fast-1// gotcha
The model string is passed straight through to the xAI API, so a typo or a retired id surfaces as an API error, not a CLI validation error. xAI has consolidated older ids — grok-code-fast-1 now routes to its newer coding model — so check docs.x.ai for currently valid names.