Grok Build CLI: Models and Custom Endpoints
Grok Build defaults to xAI's models, but it is not locked to them. You can switch models mid-session, set a project default, or point Grok at Anthropic, OpenAI, Ollama, or any OpenAI-compatible endpoint. This part shows how.
First time here? Start with Grok Build CLI: Zero to Hero (Start Here).
Pick a model
List everything available, choose one per run with -m, or switch live with /model (alias /m) or the Ctrl+M picker. The default for new sessions is grok-build.
Add a custom model
Custom endpoints live under [model.<name>] in ~/.grok/config.toml. Grok speaks three API backends, selected with api_backend: OpenAI Chat Completions (the default), OpenAI Responses, and Anthropic Messages. Pair each with the right auth_scheme, bearer for most providers, x_api_key for Anthropic.
Run models locally
Point Grok at a local Ollama server and your code never leaves the machine. Any OpenAI-compatible server works the same way, just change the base_url.
Override a built-in, keep the defaults
You do not have to redefine a model to tweak it. Use the model's name as the section key and set only the fields you want to change. Grok starts from the built-in defaults, including the correct base_url, and applies your overrides on top. Credential resolution runs api_key, then env_key, then the global XAI_API_KEY fallback.
The web search model is separate
The web_search tool uses its own model, configured under [models]. If you point it at a custom model, that model must use the Responses API backend. The context_window value you set is what tells Grok when to auto-compact, so set it accurately for custom endpoints.
For enterprise setups, combine a custom base_url proxy with an external auth provider and auto_update = false for a fully managed deployment.
Continue the series
The full series
- Grok Build CLI: Zero to Hero (Start Here)
- Grok Build CLI: Sessions, Rewind and Compaction
- Grok Build CLI: Slash Commands and Keyboard Mastery
- Grok Build CLI: Teaching Grok Your Project (AGENTS.md)
- Grok Build CLI: Models and Custom Endpoints (you are here)
- Grok Build CLI: Extending Grok with MCP, Skills, Plugins and Hooks
- Grok Build CLI: Cross-Session Memory
- Grok Build CLI: Subagents, Plan Mode and Background Work
- Grok Build CLI: Headless Mode and Automation
- Grok Build CLI: Sandbox and Permissions
- Grok Build CLI: IDE Integration with ACP
- Grok Build CLI: The Evolution (Power-User Version History)