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

# Use Modellix LLM with Grok Build

> Point Grok Build at the Modellix LLM gateway with custom models in ~/.grok/config.toml, MODELLIX_API_KEY, and provider/name model IDs.

Configure [Grok Build](https://docs.x.ai/build/overview) to call the Modellix LLM gateway. Grok Build is xAI's coding agent (interactive TUI, headless CLI, or ACP). It has no built-in Modellix provider, so add [custom models](https://docs.x.ai/build/overview) in `~/.grok/config.toml` that point at Chat Completions on [`POST /v1/chat/completions`](/llm/chat-completions).

<Note>
  This page covers **LLM text** only (`https://llm.modellix.ai`).

  Modellix model IDs are `provider/name` (for example `openai/gpt-5.5`). Put that full string in each custom model's `model` field so Grok Build sends it unchanged in the request body. See [Models & Pricing](/llm/overview#models-and-pricing).
</Note>

## Set Up Grok Build

<Steps>
  <Step title="Install Grok Build">
    <CodeGroup>
      ```bash Mac / Linux theme={null}
      curl -fsSL https://x.ai/cli/install.sh | bash
      ```

      ```powershell Windows theme={null}
      irm https://x.ai/cli/install.ps1 | iex
      ```
    </CodeGroup>
  </Step>

  <Step title="Get a Modellix API Key">
    Create a key in the [Modellix console](https://modellix.ai/console/api-key) and export it. Grok Build reads the key from the environment variable named in `env_key`:

    ```bash theme={null}
    export MODELLIX_API_KEY="mdlx-xxxxxxxx"
    ```

    Add the same line to your shell profile (for example `~/.zshrc`), then run `source ~/.zshrc`.

    <Warning>
      Use a Modellix API key, not an xAI platform key. A built-in Grok catalog model with `XAI_API_KEY` still talks to `https://api.x.ai/v1`, not Modellix.
    </Warning>
  </Step>

  <Step title="Add Custom Models">
    Edit the **user** config at `~/.grok/config.toml` (Windows: `%USERPROFILE%\.grok\config.toml`). If `GROK_HOME` is set, the file is `$GROK_HOME/config.toml` instead.

    Merge the `[model."..."]` tables into an existing file. Do not put custom models in a project `.grok/config.toml`—that file only accepts MCP servers, plugins, and permission rules.

    ```toml theme={null}
    [model."openai/gpt-5.5"]
    model = "openai/gpt-5.5"
    base_url = "https://llm.modellix.ai/v1"
    name = "GPT 5.5"
    env_key = "MODELLIX_API_KEY"
    api_backend = "chat_completions"

    [model."openai/gpt-5.6-sol"]
    model = "openai/gpt-5.6-sol"
    base_url = "https://llm.modellix.ai/v1"
    name = "GPT 5.6 Sol"
    env_key = "MODELLIX_API_KEY"
    api_backend = "chat_completions"

    [model."anthropic/claude-sonnet-5"]
    model = "anthropic/claude-sonnet-5"
    base_url = "https://llm.modellix.ai/v1"
    name = "Claude Sonnet 5"
    env_key = "MODELLIX_API_KEY"
    api_backend = "chat_completions"

    [model."google/gemini-3.6-flash"]
    model = "google/gemini-3.6-flash"
    base_url = "https://llm.modellix.ai/v1"
    name = "Gemini 3.6 Flash"
    env_key = "MODELLIX_API_KEY"
    api_backend = "chat_completions"

    [model."xai/grok-4.6"]
    model = "xai/grok-4.6"
    base_url = "https://llm.modellix.ai/v1"
    name = "Grok 4.6"
    env_key = "MODELLIX_API_KEY"
    api_backend = "chat_completions"

    [models]
    default = "openai/gpt-5.5"
    ```

    Add or remove `[model."..."]` tables as needed. Quote the table key when the local ID contains `/` or `.`.

    | Field                      | Value                                                                       |
    | -------------------------- | --------------------------------------------------------------------------- |
    | Table key (`[model."id"]`) | Local picker ID used with `-m` and `/model`                                 |
    | `model`                    | Exact Modellix Model ID (`provider/name`) sent to the API                   |
    | `base_url`                 | `https://llm.modellix.ai/v1` (include `/v1`)                                |
    | `name`                     | Label shown in the model picker                                             |
    | `env_key`                  | `MODELLIX_API_KEY` (prefer this over an inline `api_key`)                   |
    | `api_backend`              | `chat_completions` for [`POST /v1/chat/completions`](/llm/chat-completions) |
    | `[models].default`         | Local picker ID of the Modellix model to use for new sessions               |

    Setting `models.default` to a Modellix ID avoids falling back to a built-in xAI catalog model that requires `XAI_API_KEY`. Full catalog: [Models & Pricing](/llm/overview#models-and-pricing).

    <Tip>
      You do **not** need a separate Anthropic base URL. Register `anthropic/...` and `google/...` IDs on the same Modellix `base_url`; traffic goes through OpenAI-compatible Chat Completions. Native Anthropic Messages (`api_backend = "messages"` without `/v1`) is for the [Anthropic SDK](/llm/sdk/anthropic-sdk) and [Claude Code](/llm/agent/claude-code).
    </Tip>

    <Tip>
      If you prefer Responses instead of Chat Completions, set `api_backend = "responses"` and keep `base_url = "https://llm.modellix.ai/v1"`. See [Responses](/llm/responses). Most setups should keep `chat_completions`.
    </Tip>
  </Step>

  <Step title="Select a Modellix Model">
    Confirm Grok Build loaded the user config, then start a session from your project directory:

    ```bash theme={null}
    grok inspect
    cd your-project
    grok
    ```

    In the TUI, switch models with `/model <id>` (for example `/model openai/gpt-5.5`). Headless:

    ```bash theme={null}
    grok -p "Explain this repo" -m "openai/gpt-5.5"
    ```

    You can also set `GROK_DEFAULT_MODEL` for the current session (same idea as `-m`).
  </Step>
</Steps>

## Troubleshooting

| Symptom                          | Check                                                                                                                        |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| 401 / auth errors                | `MODELLIX_API_KEY` is a valid Modellix key, and `env_key` matches that variable name                                         |
| Model not found / 404            | `model` is a full ID like `openai/gpt-5.5`, not bare `gpt-5.5`; ID is in the live catalog                                    |
| Wrong path / URL errors          | `base_url` is `https://llm.modellix.ai/v1` (include `/v1`), not the media API host (`https://api.modellix.ai`)               |
| Traffic hits `api.x.ai`          | You selected a custom Modellix table, not a built-in `grok-*` catalog model; `models.default` is a Modellix ID               |
| Custom model missing from picker | Entry is in **user** `~/.grok/config.toml` (or `$GROK_HOME/config.toml`); run `grok inspect` to see loaded config sources    |
| First launch opens a browser     | Built-in xAI auth. Set `models.default` to a Modellix ID and export `MODELLIX_API_KEY` so sessions do not need `XAI_API_KEY` |

## Related

* [Grok Build overview](https://docs.x.ai/build/overview) — install, custom models, TUI and headless usage
* [Grok Build settings](https://docs.x.ai/build/settings) — `config.toml` scopes and `[model.<id>]` fields
* [Models & Pricing](/llm/overview#models-and-pricing) — Model IDs and rates
* [LLM API guide](/llm/api/api) — protocols and curl examples
* [OpenAI SDK](/llm/sdk/openai-sdk) — same `/v1` Chat Completions gateway
* [OpenCode](/llm/agent/opencode) · [Codex](/llm/agent/codex) — other OpenAI-compatible agent setups
