BUILD / add-a-custom-model-in-grok-build

Build

Add a custom model in Grok Build

Add a custom model in Grok Build

Grok Build can talk to any OpenAI-compatible or Anthropic Messages endpoint you configure. Define the model in your user-level ~/.grok/config.toml (on Windows, %USERPROFILE%\.grok\config.toml).

[model.my-model]
model = "model-id"
base_url = "https://api.example.com/v1"
name = "Display Name"
env_key = "API_KEY"

[models]
default = "my-model"

Prefer env_key (an environment variable name) over hardcoding api_key. Useful per-model keys include api_backend (chat_completions | responses | messages), context_window, temperature, top_p, max_completion_tokens, extra_headers, and supports_backend_search.

Verify and switch

grok inspect
grok -p "Hello" -m my-model

grok inspect shows what Grok discovered for the current directory, including config sources. Inside the TUI, switch with /model <id> (alias /m). List catalog models with grok models.

Under [models] you can also set:

Key Purpose
default Model for new sessions
web_search Model used by the client web_search tool
allowed_models Glob list restricting picker / -m
hidden_models Hide from picker (still usable via -m)
disabled_models Remove from the catalog (wins over hidden)

Credential order

When several credentials are available, Grok resolves them per model: model.api_keymodel.env_key → active session token → XAI_API_KEY. For CI, set XAI_API_KEY and skip the config file — see Headless & Scripting.

The same coding model that powers Grok Build (grok-4.6) is also available on the xAI API for your own agent loops; that path is separate from BYOK custom models in config.toml.