Skip to content

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.

bash
npx skills add https://ai.modelfold.online/

Key rules ​

  1. 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.
  2. Authenticate with Authorization: Bearer. Every ModelFold endpoint, including the model listing, carries the API key in this one header. A header literally named apikey is rejected with 401.
  3. Set api_backend = "responses". Grok Build's default backend is chat_completions, which sends to /v1/chat/completions. ModelFold serves these models on /xai/v1/responses.
  4. Fill the model field with an id from the listing. That is the name sent to ModelFold. It is neither the table name [model.<name>] nor Grok Build's own spelling (for example grok-4.6). The listing uses a different set of ids (for example grok-4-6). Copy the id from the list; with the built-in name ModelFold rejects the request even if base_url is right.
  5. Put the table in user-level config. A project-level .grok/config.toml only contributes MCP, plugin and permission keys. A [model.*] table there is not inference configuration.

List available models ​

bash
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:

powershell
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:

toml
[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:

bash
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.

powershell
$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 ​

  1. A header named apikey. ModelFold returns 401. Put the key in Authorization: Bearer.
  2. The full request URL in base_url. With api_backend = "responses", Grok Build appends /responses itself, so a base_url ending in /responses becomes /responses/responses.
  3. No api_backend. The default is chat_completions, which sends to /v1/chat/completions, not /xai/v1/responses.
  4. Grok's own model name in model. ModelFold reads the model field of [model.<name>], which must be an id from the listing. A built-in spelling such as grok-4.6 is not that id.
  5. [model.*] in the project-level .grok/config.toml. That file does not carry inference configuration. Use ~/.grok/config.toml.
  6. 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.
  7. setx does not affect the current window. It applies to windows opened afterwards. Set $env: as well to use it right away.
  8. PowerShell curl. It is an alias for Invoke-WebRequest and does not accept these arguments. Use curl.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.

ModelFold — one API for all the best AI models.