> ## Documentation Index
> Fetch the complete documentation index at: https://runinfra.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Grok Build

> Add RunInfra models to Grok Build's user model picker.

Add RunInfra models to Grok Build's user model picker.

Support level: `ready`. Connect supports automatic setup.

<Note>
  Literal mode is the default. Only the selected model stores your API key. Other models need `RUNINFRA_API_KEY` in the environment before you select them.
</Note>

## Connect Grok Build

Have Grok Build installed, a workspace API key, and available RunInfra credits.

```bash theme={"dark"}
npx @runinfra/connect grok
```

The bare agent command is an alias for `on`. In an interactive terminal, Connect starts login if needed. Review and approve the proposed changes. Connect saves a snapshot, writes the model settings, and makes a real Chat Completions request that uses credits.

To choose a model during setup:

```bash theme={"dark"}
npx @runinfra/connect grok on --model deepseek-v4-flash
```

See [Connect](/docs/tools-sdks/connect) for status, diagnostics, and key replacement.

## What Connect writes

| Platform        | Connect's default target          |
| --------------- | --------------------------------- |
| macOS and Linux | `~/.grok/config.toml`             |
| Windows         | `%USERPROFILE%\.grok\config.toml` |

When `GROK_HOME` is set, Connect writes `config.toml` inside that directory. Check which configuration Grok Build loads before use.

Connect adds a `[model.runinfra-<model-id>]` table for each catalog model. It writes the exact API `model` id, `base_url = "https://api.runinfra.ai/v1"`, the catalog `name` and `context_window`, and `api_backend = "chat_completions"`.

Connect sets `[models] default` to `runinfra-<model-id>` for the selected model. Unrelated model settings are preserved. A table name alone does not establish ownership of its credentials or destination.

### Key placement

Literal mode writes `api_key` only in the selected model's table and removes its `env_key`. That selected model does not need `RUNINFRA_API_KEY` in the environment. Other RunInfra model tables use `env_key = "RUNINFRA_API_KEY"`.

For helper mode:

```bash theme={"dark"}
npx @runinfra/connect grok on --key-source helper
```

Helper mode uses `env_key = "RUNINFRA_API_KEY"` instead of a literal `api_key`. Set the variable securely in the environment that launches Grok Build.

<Accordion title="Pass the helper key to the app">
  Export `RUNINFRA_API_KEY` with your RunInfra API key in the environment that launches the app. Restart GUI apps and background services with that environment.

  On Windows, set `RUNINFRA_API_KEY` in your user environment, then fully restart the app. GUI and Start menu launches do not receive a terminal-only `$env:RUNINFRA_API_KEY` value. Connect does not change your external environment.
</Accordion>

## Verify

Grok Build 1.0.13 on Windows completed verified round trips on September 8, 2026, with both literal `api_key` and helper `env_key` settings. Both returned `RUNINFRA_OK` and were confirmed in RunInfra usage. The literal-key run succeeded with `RUNINFRA_API_KEY` absent from the environment.

Inspect the loaded configuration:

```bash theme={"dark"}
grok inspect
```

In an authorized isolated environment, run the follow-up command for `deepseek-v4-flash`. Connect prints it but does not execute it:

```bash theme={"dark"}
grok -p "Reply exactly RUNINFRA_OK. Do not use tools." -m runinfra-deepseek-v4-flash --output-format plain --no-leader
```

The no-tools prompt is not a permission boundary. Confirm the selected RunInfra model and request destination separately. The output format is `plain`, not `text`. Other supported choices are `json`, `streaming-json`, and `streaming-messages-json`.

## Restart

Restart Grok Build. Run `grok inspect` to check which configuration is loaded. Confirm the selected RunInfra model and request destination separately. Connect's API probe does not verify Grok Build.

## Known behaviours

Still check `GROK_HOME` edge cases, precedence when both credential forms are present, parser edge cases, and restoration after Grok saves changes.

Connect replaces owned literal credentials on other RunInfra model tables with environment references. Before selecting another model, ensure that the actual Grok Build process has `RUNINFRA_API_KEY`.

## Troubleshooting

| Symptom                                | What to check                                                                                                                 |
| -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| Another model cannot authenticate      | Only the selected model stores a literal key. Set `RUNINFRA_API_KEY` in the launch environment before selecting other models. |
| Helper mode cannot authenticate        | Check `env_key` and the actual Grok Build process environment. Restart the app with that environment.                         |
| A RunInfra model table is refused      | Review its credentials and destination. The table name alone does not establish ownership.                                    |
| The output format is rejected          | Use `plain`, `json`, `streaming-json`, or `streaming-messages-json`, not `text`.                                              |
| Grok Build loads another configuration | Inspect the loaded settings and review `GROK_HOME`.                                                                           |
| Normal `off` refuses changed bytes     | Review Grok Build's saved changes before choosing `off --force`.                                                              |

## Revert

```bash theme={"dark"}
npx @runinfra/connect grok off
```

In both recorded key-mode runs, `off` restored the original `config.toml` byte for byte. With intact state and snapshots, `off` restores the original bytes from before the first `on` in the active connection. If the file did not exist then, Connect removes it. Later `on` calls and key rotations keep that restore point.

If Grok Build or another editor changed the file, Connect refuses to overwrite it. Back up and review the edits before choosing to discard them:

```bash theme={"dark"}
npx @runinfra/connect grok off --force
```

Connect saves the current contents in a recovery snapshot and prints its id before restoring the origin. Keep the snapshots. If the origin snapshot is missing, cleanup does not guarantee original-byte restoration. See [Connect recovery](/docs/tools-sdks/connect#what-off-restores).

Restore manual environment changes yourself. Restoring `config.toml` does not restore your external environment.

## Related

<Columns cols={3}>
  <Card title="Connect" icon="plug" href="/docs/tools-sdks/connect">
    Set up, inspect, and restore your coding agent.
  </Card>

  <Card title="Chat completions" icon="braces" href="/docs/api-reference/chat-completions">
    Read the request contract.
  </Card>

  <Card title="Models" icon="list" href="/docs/api-reference/models">
    Find model ids and context windows.
  </Card>
</Columns>
