> models and endpoints
Choose a model with --model/-m, the GROK_MODEL env var, or defaultModel in settings; the built-in default is grok-code-fast-1. Because Grok CLI speaks the OpenAI chat-completions standard, --base-url/-u (default https://api.x.ai/v1) lets you point it at OpenAI, OpenRouter, Groq, or any compatible endpoint.
// models and endpoints
5 commands$ grok -m grok-4-latest$ ~/.grok/user-settings.json$ grok --base-url https://api.x.ai/v1$ ~/.grok/user-settings.json$ grok --model gemini-2.5-pro --base-url https://your-endpoint.example.com/v1// faq
Which models can Grok CLI use?
Any model id your endpoint accepts. Against xAI the CLI defaults to grok-code-fast-1 and ships examples for grok-4-latest and the grok-3 family. The id is forwarded straight to the API, so check docs.x.ai for currently valid names — xAI has since folded grok-code-fast-1 into its newer coding models.
How does Grok decide which model to use?
Precedence is the --model flag, then the GROK_MODEL environment variable, then defaultModel in ~/.grok/user-settings.json, then a project's .grok/settings.json model, falling back to the system default grok-code-fast-1. A project-pinned model overrides your global default in that project.
Can I use Grok CLI with OpenAI, Claude, or Gemini?
Yes. Set baseURL to an OpenAI-compatible endpoint (OpenAI, OpenRouter, Groq, or your own gateway) and defaultModel to a model it serves, and supply that provider's key. The key and base URL must match — an xai- key only works against api.x.ai.
What is the default API endpoint?
https://api.x.ai/v1. Override it with the --base-url/-u flag, the GROK_BASE_URL environment variable, or baseURL in user-settings.json when you use a proxy, a gateway, or a different OpenAI-compatible provider.