[CmdletBinding()] param( [int]$Port = 8080, [string]$KeyPath = "" ) $ErrorActionPreference = "Stop" if (-not $KeyPath) { $KeyPath = Join-Path $PSScriptRoot "..\.local\llama.cpp\api-key.txt" } if (-not (Test-Path $KeyPath)) { throw "Local API key is missing at $KeyPath" } $key = (Get-Content $KeyPath -Raw).Trim() $headers = @{ Authorization = "Bearer $key" } $health = Invoke-RestMethod -Uri "http://127.0.0.1:$Port/health" -Headers $headers -TimeoutSec 5 if ($health.status -notin @("ok", "no slot available")) { throw "Unexpected llama.cpp health response: $($health | ConvertTo-Json -Compress)" } $health