GPU Compute / Recipe

Image and video batch jobs

Run Diffusers, ComfyUI, or video synthesis pipelines as one-off GPU jobs. Billing stops automatically when the script exits — no persistent endpoint to manage.

Prerequisites: npm install -g badgr-cli then badgr login. Setup guide →

Batch image generation with Diffusers

Run a Python script that generates images from a list of prompts. Point Badgr at your project folder and it handles the rest:

badgr run . --cmd "python generate.py" --gpu L40S \
  --env HF_TOKEN=$HF_TOKEN \
  --env MODEL_ID=black-forest-labs/FLUX.1-schnell \
  --max-cost 5

A typical generate.py using Diffusers:

import os, torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained(
    os.environ["MODEL_ID"],
    torch_dtype=torch.bfloat16,
).to("cuda")

prompts = [
    "A sunset over mountain peaks",
    "A futuristic city skyline, photorealistic",
    "Abstract watercolor painting of a forest",
]

for i, prompt in enumerate(prompts):
    image = pipe(prompt, num_inference_steps=4).images[0]
    image.save(f"output_{i}.png")
    print(f"Saved output_{i}.png")

Custom image (escape hatch)

For pinned dependency combinations, bring your own container. Pass model config via --env:

badgr run \
  --image ghcr.io/my-org/diffusers-runner:latest \
  --gpu L40S \
  --env MODEL_ID=black-forest-labs/FLUX.1-schnell \
  --env OUTPUT_DIR=/app/outputs \
  --max-cost 5

ComfyUI workflow (CLI)

Use badgr comfyui run to launch ComfyUI with a workflow file — no image or container config needed:

badgr comfyui run workflow.json \
  --gpu A100 \
  --max-cost 5.00

Badgr auto-detects ComfyUI images, health-checks /system_stats (up to 10 min), and returns the endpoint URL. Use --persistent to keep it running after the workflow completes.

Provision models the workflow needs

badgr comfyui run workflow.json --models manifest.json --startup-timeout 10 --max-cost 5

--models downloads models the workflow references but the image does not ship, before ComfyUI starts. The manifest is a JSON object mapping each model's path under ComfyUI's models/ folder to a direct https:// download URL, with at most 20 entries:

{
  "checkpoints/foo.safetensors": "https://huggingface.co/<org>/<repo>/resolve/main/foo.safetensors"
}

Badgr validates the manifest before provisioning anything and raises the disk floor to fit the downloads. --startup-timeout <minutes> (1 to 60) widens the startup allowance for a slow cold start, which is most useful with --models.

Image-editing workflows

badgr comfyui run qwen-image-edit.json --input-image photo.png --max-cost 5

A workflow that edits an image (for example qwen-image-edit) needs --input-image <path>. The file must exist and be at most 10MB. Without it, the command stops before provisioning.

ComfyUI batch (REST API)

Use the comfy.batch job type to send up to 20 prompts through ComfyUI in a single API call. Badgr provisions the GPU, waits for ComfyUI to be ready, runs the batch, downloads the images, and tears down the GPU. Currently supports workflow_id: "sdxl-basic" (SDXL 1.0, 1024×1024) and "flux-basic" (FLUX.1-schnell).

curl https://aibadgr.com/v1/jobs \
  -H "Authorization: Bearer $BADGR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "comfy.batch",
    "input": {
      "workflow_id": "sdxl-basic",
      "prompts": [
        "a red fox in a snowy forest, photorealistic",
        "a futuristic city at sunset, digital art",
        "an astronaut riding a horse on the moon"
      ]
    },
    "policy": { "max_cost": 3 }
  }'

Poll GET /v1/jobs/{job_id} until status === "completed". The output contains image_urls — download each with:

curl https://aibadgr.com/v1/jobs/$JOB_ID/images/0 \
  -H "Authorization: Bearer $BADGR_API_KEY" \
  -o image_0.png

Video synthesis

Run a video generation script — for example with CogVideoX or Wan:

badgr run . --cmd "python generate_video.py" --gpu H100 \
  --env HF_TOKEN=$HF_TOKEN \
  --env PROMPT="A time-lapse of a blooming flower" \
  --max-cost 10

Use the H100 for video models that require large VRAM. Billing stops when the script exits.

Detach and collect outputs later

Use --detach for long-running jobs — badgr returns the job ID immediately:

# Launch and return immediately
badgr run . --cmd "python generate.py" --gpu L40S --env HF_TOKEN=$HF_TOKEN --max-cost 5 --detach

# Follow logs when ready
badgr logs <deployment-id>

Options

--gpu <type>L40S or A100 for images; H100 for large video models
--cmd <command>Command to run inside the uploaded project folder.
--image <ref>Custom container image — bypasses the runner. Use for unusual dependencies.
--env KEY=VALUESet environment variables — repeatable
--detachReturn job ID immediately, don't stream logs
--max-runtime <min>Auto-stop after N minutes (recommended to cap spend)
--max-cost <$>Auto-stop when spend reaches this amount

Next steps