Grok Build
TIP
Let the skill configure it
With the ModelFold skills installed, you can simply ask your agent "Configure Grok Build to use ModelFold" and it follows the steps on this page. You can also configure it by hand as described below.
npx skills add https://ai.modelfold.online/Key rules
- Discover models with
GET https://ai.modelfold.online/xai/v1/models, not from memory or training data. This endpoint gives the list Grok Build can run on this prefix. - Authenticate with
Authorization: Bearer. Every ModelFold endpoint, including the model listing, carries the API key in this one header. A header literally namedapikeyis rejected with 401. - Set
api_backend = "responses". Grok Build's default backend ischat_completions, which sends to/v1/chat/completions. ModelFold serves these models on/xai/v1/responses. - Fill the
modelfield with anidfrom the listing. That is the name sent to ModelFold. It is neither the table name[model.<name>]nor Grok Build's own spelling (for examplegrok-4.6). The listing uses a different set of ids (for examplegrok-4-6). Copy theidfrom the list; with the built-in name ModelFold rejects the request even ifbase_urlis right. - Put the table in user-level config. A project-level
.grok/config.tomlonly contributes MCP, plugin and permission keys. A[model.*]table there is not inference configuration.
List available models
curl -s -H "Authorization: Bearer $MODELFOLD_API_KEY" \
https://ai.modelfold.online/xai/v1/models |
jq -r '.data[] | .id'On Windows (PowerShell), send the same request with curl.exe:
curl.exe -s -H "Authorization: Bearer $env:MODELFOLD_API_KEY" `
https://ai.modelfold.online/xai/v1/models | jq -r '.data[].id'The response has the OpenAI-compatible shape. .data[] is the list: id is the value for model. object, owned_by, created and aliases are boilerplate.
List the ids for the user to choose from. Re-run the listing every time instead of reusing an earlier answer; the model set changes.
Configure
Grok Build configures custom models with [model.<name>] tables. <name> is the key in the model picker, and model is the id sent to ModelFold:
[models]
default = "ModelFold"
[model.ModelFold]
model = "grok-4-6"
base_url = "https://ai.modelfold.online/xai/v1"
name = "ModelFold"
api_backend = "responses"
env_key = "MODELFOLD_API_KEY"base_url is the root that requests are sent to. With api_backend = "responses", Grok Build appends /responses itself, so the value is https://ai.modelfold.online/xai/v1, not the full request URL https://ai.modelfold.online/xai/v1/responses.
env_key names the environment variable Grok Build reads the credential from and sends as a bearer token. It does not hold the key itself. Prefer it over writing the key into api_key.
You choose the picker key (ModelFold here). [models] default must be that key (or another [model.*] key), not a name from Grok's built-in catalog; otherwise new sessions still go to xAI instead of ModelFold.
macOS and Linux
The file is ~/.grok/config.toml. Export the credential in the same shell that starts grok, or add it to your shell profile:
export MODELFOLD_API_KEY=…Set GROK_HOME to keep the configuration somewhere other than ~/.grok.
Windows (PowerShell)
The file is %USERPROFILE%\.grok\config.toml, with identical content.
$env:MODELFOLD_API_KEY = "…"
setx MODELFOLD_API_KEY "…"Verify the setup
grok models should list the custom key. grok inspect reports which config file is in effect. Start grok in a shell where MODELFOLD_API_KEY is set and send a message, or run grok -p "…" -m ModelFold.
RUST_LOG=debug GROK_LOG_FILE=/tmp/grok.log grok writes a request trace. Check the base_url and the model id.
Common pitfalls
- A header named
apikey. ModelFold returns 401. Put the key inAuthorization: Bearer. - The full request URL in
base_url. Withapi_backend = "responses", Grok Build appends/responsesitself, so abase_urlending in/responsesbecomes/responses/responses. - No
api_backend. The default ischat_completions, which sends to/v1/chat/completions, not/xai/v1/responses. - Grok's own model name in
model. ModelFold reads themodelfield of[model.<name>], which must be anidfrom the listing. A built-in spelling such asgrok-4.6is not that id. [model.*]in the project-level.grok/config.toml. That file does not carry inference configuration. Use~/.grok/config.toml.- The key itself in
env_key. It takes the name of an environment variable. The key lives in that variable, not in the config file. setxdoes not affect the current window. It applies to windows opened afterwards. Set$env:as well to use it right away.- PowerShell
curl. It is an alias forInvoke-WebRequestand does not accept these arguments. Usecurl.exe.
To use a model from a listing that isn't on this protocol, see When protocols don't match on the Install modelfold-chat-agents page.