Pixloomdocs

Resolve a batch

POST /api/v1/embed/resolve turns a page full of prompts into a page full of images in one call.

This is what pixloom-client.js calls. You rarely need it directly, but it is the right endpoint any time one screen needs many images at once: a grid, a feed, a server-rendered page, a static build step.

It takes either kind of key, which is the whole point. A publishable key can call it from the browser, so the script tag ships in page source without exposing anything.

curl -X POST https://pixloom.dev/api/v1/embed/resolve \
  -H "Authorization: Bearer pk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "elements": [
      { "id": "hero", "prompt": "cozy bookstore at sunset", "style": "watercolor" },
      { "id": "sidebar", "shortcut": "weekly-banner" },
      { "id": "footer", "prompt": "stack of books", "mode": "instant" }
    ]
  }'
{
  "results": [
    { "id": "hero", "status": "ready", "imageUrl": "https://...", "imageId": "b71e..." },
    { "id": "sidebar", "status": "generating", "jobId": "3f6c..." },
    { "id": "footer", "status": "ready", "imageUrl": "https://...", "match": "nearest", "matchScore": 0.86, "poolImageId": "9c41..." }
  ]
}

Results come back in the order you sent them, one per element, each carrying the id you chose. Anything generating has a jobId to poll.

Elements

One to fifty per request. Each element needs either a prompt or a shortcut.

FieldTypeDefaultNotes
idstringrequiredYour own label, 1 to 100 characters. Echoed back so you can match results to slots.
promptstring1 to 2000 characters.
shortcutstringThe name of a permalink, 1 to 200 characters.
stylestringnoneUp to 200 characters.
widthinteger1024256 to 2048.
heightinteger1024256 to 2048.
formatpng, jpeg or webpwebp
characteruuidnone
agekids, bigkids or adultsnoneA single value here, not an array.
modegenerate or instantgenerate
tagsarray of stringnoneUp to ten taxonomy slugs that narrow an instant match.

The three kinds of element

A shortcut resolves to the best image for that permalink. It never starts a generation and never touches your quota.

A prompt in generate mode returns ready with an image if we already have one for that exact prompt and style, and otherwise starts a job and returns generating. This is what makes the second visitor to a page see images immediately.

A prompt in instant mode always returns the closest image from our shared library, in one round trip. Never a job, never a generation, free on every plan. match is exact or nearest, and matchScore is how close, from 0 to 1.

Results

FieldNotes
idThe id you sent.
statusready, generating or failed.
imageUrlSet when ready.
imageIdSet when ready.
jobIdSet when generating. Poll it.
errorSet when failed.
matchexact or nearest, on library matches.
matchScore0 to 1, or null when unscored.
poolImageIdThe library image, so you can save it as a permalink.

One element failing never fails the batch. An element that would push you past your quota comes back failed while everything else in the request still resolves, so a single bad slot cannot blank out a page.

Responses

StatusBody
200The results above, even when some of them failed.
400{ "error": "Invalid request", "details": { ... } }. An element with neither prompt nor shortcut lands here.
401Missing or invalid key.
403Account not approved, or a domain that is not on the key.
429Over your per-minute rate limit.

On this page