DEV Community

Ramandeep Singh
Ramandeep Singh

Posted on

NVIDIA - NIM Free Image generation Model PS scripts

Checkout the Git Repository
PowerShell scripts in nim-image-gen, one per NVIDIA NIM model:

Script Model Notable defaults
flux1-dev.ps1 black-forest-labs/flux.1-dev 50 steps, 1024×1024
flux1-schnell.ps1 black-forest-labs/flux.1-schnell 4 steps (fast)
sd-3.5-large.ps1 stabilityai/stable-diffusion-3.5-large text_prompts format, cfg 5.0
sdxl.ps1 stabilityai/stable-diffusion-xl text_prompts format, sampler K_DPMPP_2M
sdxl-turbo.ps1 stabilityai/sdxl-turbo 1 step, cfg 0 (real-time)

Shared design:

  • Each takes params: -ApiKey, -Prompt, -Out, -Seed (+ model-specific ones like -Steps, -Width, -Height, -CfgScale).
  • API key falls back to $env:NVIDIA_API_KEY if -ApiKey isn't passed.
  • Forces TLS 1.2 (for Windows PowerShell 5.1), has try/catch error handling that prints the API's error body, validates the response, and decodes base64 → PNG.
  • FLUX scripts use the prompt field; Stability scripts use the text_prompts array format.

Usage example:

cd nim-image-gen
$env:NVIDIA_API_KEY = "nvapi-xxxx"
.\flux1-dev.ps1 -Prompt "a red fox in autumn leaves" -Out fox.png
Enter fullscreen mode Exit fullscreen mode

One caveat: endpoint slugs and exact request fields on NVIDIA NIM change occasionally. If any script returns a 4xx, open that model's page on build.nvidia.com and confirm the URL/fields — set sensible defaults based on NIM's common conventions, but the Stability field names (text_prompts, cfg_scale, sampler) in particular are worth a quick check.

Top comments (0)