PowerShell API Examples
Use Invoke-RestMethod from PowerShell without exposing API keys in command history.
Prerequisites
Set the key in the process environment rather than pasting it into a script or committing it to source control.
Model discovery
$env:HOSTNOTGPU_API_KEY = "YOUR_API_KEY"
$headers = @{ Authorization = "Bearer $env:HOSTNOTGPU_API_KEY" }
$models = Invoke-RestMethod -Method Get -Uri "https://api.hostnotgpu.ae/v1/models" -Headers $headers
$models.dataPublic GPU availability
Invoke-RestMethod -Method Get -Uri "https://api.hostnotgpu.ae/v1/public/gpu-availability"Serverless chat request
$headers = @{
+ Authorization = "Bearer $env:HOSTNOTGPU_API_KEY"
+ "Idempotency-Key" = [guid]::NewGuid().ToString()
+}
+$body = @{ model = "MODEL_SLUG"; messages = @(@{ role = "user"; content = "Hello" }) } | ConvertTo-Json -Depth 5
+Invoke-RestMethod -Method Post -Uri "https://serverless.hostnotgpu.ae/v1/inference/chat" -Headers $headers -ContentType "application/json" -Body $bodyErrors and safety
Invoke-RestMethod throws for non-success status codes. Inspect the response body in a controlled diagnostic tool, never print the Authorization header, and retry only documented transient failures. Use curl.exe rather than the Windows PowerShell curl alias when you need curl syntax.
Published · Updated