How to batch low poly background generation with the runner and api
- Step 1Pair the runner once — Install and pair @jadapps/runner from your dashboard. It listens on 127.0.0.1:9789 (a legacy port 49217 is also probed). Confirm it is up with GET /v1/health before scripting.
- Step 2Confirm the tool is server-safe — svg-polygon-gen is in the server-safe set, so it runs in engine mode — no headless browser. You can call /v1/tools/svg-polygon-gen/run directly without browser dependencies.
- Step 3Build the options payload — Assemble the four options: polyPoints (8–300), polyWidth (200–3840), polyHeight (100–3840), and polyColors (an array of hex strings; use four for parity with the UI). Omit a value to take its default.
- Step 4POST one job per background — Send a multipart request with the options field as JSON to the run endpoint. Because the tool is generative, there is no file part — the options are the whole request. Each POST returns one SVG.
- Step 5Cache by your own key — Since there is no seed, the call is not reproducible. Generate once, then store the returned SVG under a key you control (user id, page slug, content hash) and serve from that cache. Never regenerate on demand expecting the same mesh.
- Step 6Pre-minify before shipping — Pipe the saved SVG through /svg-tools/svg-pro-minifier (also server-safe) to trim whitespace and shorten numbers, then deploy the minified file to your CDN.
Real automation routes for svg-polygon-gen
svg-polygon-gen is server-safe, so unlike browser-only tools it runs in the engine. The endpoint is exposed by the local runner; there is no public hosted REST batch service.
| Route | Mechanism | Reproducible? | Notes |
|---|---|---|---|
| Web tool (Free) | In-browser, blended fill | No (unseeded) | Manual; click Generate, download |
| Web tool (Pro+) | Auto-routes to local runner | No (unseeded) | Falls back to browser if runner down |
| Runner HTTP | POST 127.0.0.1:9789/v1/tools/svg-polygon-gen/run | No (unseeded) | Engine mode, flat band fill |
| Self-hosted | Re-implement Bowyer-Watson in your code | Yes if you seed it | Full control, no runner needed |
The options object for batch calls
These four fields are the entire request for this generative tool. Numbers are validated against the schema min/max; out-of-range values are rejected by the engine's option validator.
| Field | Type | Range / shape | Default if omitted |
|---|---|---|---|
| polyPoints | number | 8 – 300 | 50 |
| polyWidth | number | 200 – 3840 | 1200 |
| polyHeight | number | 100 – 3840 | 600 |
| polyColors | string[] (hex) | any length; use 4 for UI parity | #6366f1 #818cf8 #a5b4fc #c7d2fe |
Cookbook
Patterns that work given the unseeded, generate-once reality. Pseudocode for the runner endpoint and the cache-by-key approach.
POST one job to the local runner
Generative tool: the request body is just the options. curl against the runner's run endpoint. The runner saves the SVG locally and returns metadata.
curl -s -X POST \
127.0.0.1:9789/v1/tools/svg-polygon-gen/run \
-F 'options={"polyPoints":40,"polyWidth":1600,"polyHeight":900,"polyColors":["#0f172a","#1e3a8a","#3b82f6","#93c5fd"]}'
# -> { outputPath, filename: "low-poly-bg.svg",
# mimeType: "image/svg+xml", sizeBytes, metrics:{Points,Triangles} }Generate-once, cache-by-key (the right pattern)
Because there is no seed, do NOT regenerate on demand. Generate the first time a key is requested, store the SVG, and serve from cache forever after.
function backgroundFor(key): # key = userId, pageSlug, ...
cached = store.get(key)
if cached: return cached
svg = runner.run('svg-polygon-gen', {
polyPoints: 50,
polyColors: paletteFor(key) # deterministic palette is fine
})
store.put(key, svg) # SVG is now stable for this key
return svgAnti-pattern: assuming a seed makes it reproducible
This does NOT work. The tool ignores any seed-like field — points are Math.random(). Two identical calls return different meshes.
# WRONG: there is no seed parameter
runner.run('svg-polygon-gen', { seed: hash(userId), polyPoints: 50 })
runner.run('svg-polygon-gen', { seed: hash(userId), polyPoints: 50 })
# -> two DIFFERENT SVGs. 'seed' is silently ignored.
# Fix: generate once and cache (see previous example).Batch a folder of palettes
Loop over palettes you control, generate one background each, and minify. Each output is unique geometry; the palette is the deterministic part you vary.
for name, palette in palettes:
svg = runner.run('svg-polygon-gen', {
polyPoints: 60, polyWidth: 1200, polyHeight: 600,
polyColors: palette
})
write("out/" + name + ".svg", svg)
# optional: server-safe minify pass
runner.run('svg-pro-minifier', svg) -> "min/" + name + ".svg"Self-host with your own seeded triangulation
If you truly need reproducible per-user meshes, re-implement Bowyer-Watson in Node with a seeded PRNG. The algorithm is pure JS with no native deps. The JAD tool's geometry rules are documented in the algorithm guide.
import seedrandom from 'seedrandom'
const rng = seedrandom(userId) // deterministic points
const pts = anchors(W,H).concat(
Array.from({length:N}, () => [rng()*W, rng()*H])
)
const tris = bowyerWatson(pts) // your own copy
// now user X always gets the same meshEdge cases and what actually happens
Passing a seed to get reproducible output
IgnoredThere is no seed parameter. Any seed-like field is silently dropped and points are generated with Math.random(), so repeated calls with identical options return different meshes. Use the generate-once-and-cache pattern instead.
Regenerating an avatar from a user id on every request
Wrong designBecause the tool is unseeded, you cannot recompute 'the same' background from a user id. Generate it once, store the SVG keyed by the user id, and serve from that store; otherwise the avatar background changes on every load.
polyPoints out of range in a batch call
RejectedThe engine validates number options against the schema and throws if polyPoints is below 8 or above 300 (similarly for width/height). Clamp values in your script before sending to avoid failed jobs.
Expecting a public hosted REST endpoint
Not availableThere is no public batch REST service. Automation goes through the local @jadapps/runner's endpoint on 127.0.0.1:9789. The tool being server-safe means it runs in engine mode there — but you still run the runner yourself.
Runner not running during a batch
Falls backThe Pro+ web tool falls back to in-browser processing if the runner is down, which is fine interactively but defeats unattended batching. For scripts, check GET /v1/health first and keep the runner alive.
Output looks more banded than the web preview
ExpectedThe engine colours each triangle a flat palette-band colour at fixed 0.92 opacity, whereas the browser blends between swatches and varies opacity by Y. Same algorithm, slightly different colouring — design your palettes to look good banded.
Sending a file with the generative job
Ignoredsvg-polygon-gen takes no input file. Any uploaded part is irrelevant — the request is defined entirely by the options object. Keep payloads small by sending options only.
Hundreds of unique backgrounds at the 300-point cap
SupportedEach job is independent and fast (milliseconds in engine mode even near the 300-point maximum), so large batches are practical. Cache results so you never pay the generation cost twice for the same key.
Frequently asked questions
Can I call svg-polygon-gen programmatically?
Yes. It is server-safe, so it runs in engine mode and can be driven via the paired @jadapps/runner's local endpoint at 127.0.0.1:9789/v1/tools/svg-polygon-gen/run. Send the four options as a JSON field; no input file is needed.
Is there a hosted REST API I can hit from the cloud?
No public hosted batch endpoint is exposed. The supported automation route is the local runner, which the Pro+ web tool also auto-dispatches to when it is running on your machine.
How do I make the same user always get the same background?
You can't via this tool — it has no seed and uses Math.random(). Generate the background once, store the resulting SVG keyed by the user id, and serve it from your cache. The palette can be deterministic; the mesh cannot.
Why are two identical calls returning different images?
Because point placement is random and unseeded. Identical options still produce different meshes by design. If reproducibility matters, cache the first result or self-host a seeded triangulation.
Does the API output look the same as the web tool?
Almost — the geometry is identical, but the engine fills triangles with flat palette-band colours at a fixed opacity, while the browser blends between swatches and varies opacity by Y. The API output is slightly more banded.
What goes in the request body?
Just the options object: polyPoints, polyWidth, polyHeight, polyColors. It is a generative tool, so there is no file part. Omitted fields fall back to their defaults (50, 1200, 600, and the indigo palette).
Are out-of-range values rejected?
Yes. The engine validates numeric options against the schema and throws if polyPoints, polyWidth, or polyHeight fall outside their min/max. Clamp before sending: points 8–300, width 200–3840, height 100–3840.
Is anything uploaded when I batch via the runner?
No. The runner executes locally and writes output to a path on your machine. For a generative tool there is no input to send anyway — only the options travel over localhost.
Can I self-host the algorithm instead?
Yes, and it is the only way to get reproducible per-key meshes. The triangulation is pure JavaScript (Bowyer-Watson) with no native dependencies — re-implement it with a seeded PRNG so a given key always yields the same points.
How fast is each job?
Milliseconds. In engine mode even a 300-point mesh (~600 triangles) completes quickly. The cost is small enough that the real optimisation is caching by key so you never regenerate the same background twice.
Can I minify the batch output?
Yes. svg-pro-minifier is also server-safe, so you can chain it after generation in the same runner-driven loop to trim whitespace and shorten coordinates before deploying.
Which other generators can I batch the same way?
The sibling generative tools /svg-tools/svg-blob-generator and /svg-tools/svg-wave-divider are also server-safe and follow the same options-only, generate-once pattern. /svg-tools/svg-pattern-tiler tiles an uploaded SVG if you need repeating art.
Privacy first
Every JAD SVG tool runs entirely in your browser using the DOM API and Canvas. Your SVG files never leave your device — verified by zero outbound network requests during processing.