Grok Build Setup

Connect the official Grok Build CLI to Modelflare with your API key, grok-4.5, and the Responses API endpoint.

1. Create an API key

Create a Modelflare API key that can access grok-4.5.

2. Install Grok Build

Windows PowerShell

irm https://x.ai/cli/install.ps1 | iex
grok version

Linux or macOS

curl -fsSL https://x.ai/cli/install.sh | bash
grok version

3. Create config.toml

Windows PowerShell

New-Item -ItemType Directory -Force "$HOME\.grok" | Out-Null
Set-Location "$HOME\.grok"
$config = @'
[models]
default = "modelflare-grok"

[model.modelflare-grok]
model = "grok-4.5"
base_url = "https://modelflare.dev/v1"
name = "Modelflare Grok 4.5"
env_key = "MODELFLARE_API_KEY"
api_backend = "responses"
'@
$utf8NoBom = New-Object System.Text.UTF8Encoding -ArgumentList $false
[System.IO.File]::WriteAllText(
  (Join-Path (Get-Location) "config.toml"),
  $config,
  $utf8NoBom
)

Linux or macOS

mkdir -p ~/.grok
cd ~/.grok
cat > config.toml << 'EOF'
[models]
default = "modelflare-grok"

[model.modelflare-grok]
model = "grok-4.5"
base_url = "https://modelflare.dev/v1"
name = "Modelflare Grok 4.5"
env_key = "MODELFLARE_API_KEY"
api_backend = "responses"
EOF
chmod 600 config.toml

4. Save your API key

Replace YOUR_MODELFLARE_API_KEY with your complete Modelflare API key.

Windows PowerShell

[Environment]::SetEnvironmentVariable(
  "MODELFLARE_API_KEY",
  "YOUR_MODELFLARE_API_KEY",
  "User"
)
$env:MODELFLARE_API_KEY = "YOUR_MODELFLARE_API_KEY"

Linux

echo 'export MODELFLARE_API_KEY="YOUR_MODELFLARE_API_KEY"' >> ~/.bashrc
source ~/.bashrc

macOS

echo 'export MODELFLARE_API_KEY="YOUR_MODELFLARE_API_KEY"' >> ~/.zshrc
source ~/.zshrc

5. Start and test

Windows PowerShell

Set-Location $HOME
grok -p "Reply only: Modelflare connected" -m modelflare-grok
grok

Linux or macOS

cd ~
grok -p "Reply only: Modelflare connected" -m modelflare-grok
grok