Thiết lập Grok Build
Kết nối Grok Build CLI chính thức với Modelflare bằng khóa API, grok-4.5 và endpoint Responses API.
1. Tạo khóa API
Tạo khóa API Modelflare có thể truy cập grok-4.5.
2. Cài đặt Grok Build
Windows PowerShell
irm https://x.ai/cli/install.ps1 | iex
grok version
Linux hoặc macOS
curl -fsSL https://x.ai/cli/install.sh | bash
grok version
3. Tạo 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 hoặc 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. Lưu khóa API của bạn
Thay thế YOUR_MODELFLARE_API_KEY bằng khóa API Modelflare hoàn chỉnh của bạn.
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. Bắt đầu và kiểm tra
Windows PowerShell
Set-Location $HOME
grok -p "Reply only: Modelflare connected" -m modelflare-grok
grok
Linux hoặc macOS
cd ~
grok -p "Reply only: Modelflare connected" -m modelflare-grok
grok