Skip to Content

Async jobs

Start an import or a generation, then poll the job until it finishes.

Importing a 3D file and generating a model from photos take from seconds to minutes, so the API runs them as jobs. The request that starts a job returns at once with the job id. You then read the job until it finishes.

Job status

StatusMeaningFinished
queuedThe job waits for a worker.No
processingA worker runs the job. stage says which step it is on.No
succeededThe object is ready: the job has its tinuuid and url.Yes
failedThe job stopped. error.code says why.Yes
cancelledYou cancelled the generation. Generations only.Yes

A job goes queued → processing → one of the finished statuses.

Polling

Read the job until its status is finished. Each unfinished job suggests how long to wait before the next read: retryAfterMs in imports, retry_after_ms in generations. Wait that long rather than polling in a tight loop.

Import a 3D file

On Node.js?

The Node.js SDK runs these four steps in one call: objects.importModel() uploads the file, starts the import and waits for the object.

Get an upload URL

Describe the file. type is model_source for a 3D file.

curl https://api.vizbl.com/developer-api/uploads/presign \
  -H "Authorization: Bearer $VIZBL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "model_source",
    "fileName": "chair.glb",
    "fileSize": 18452312,
    "fileType": "model/gltf-binary"
  }'

The response holds an uploadId, where to upload (uploadUrl) and the form fields the upload needs (uploadFields). The upload URL expires at expiresAt.

Upload the file

Send a multipart POST to uploadUrl with every field of uploadFields, then the file itself in a field named file. The file goes straight to storage: this request carries no API key.

# every field of uploadFields as -F "name=value", then the file last
curl "$UPLOAD_URL" \
  -F "key=…" \
  -F "Content-Type=model/gltf-binary" \
  -F "file=@chair.glb"

Start the import

Name the object and list its variants by uploadId. publish: true publishes the object once it is imported; see Publish later for an import without it. The x-idempotency-key header makes the request safe to retry.

curl https://api.vizbl.com/developer-api/objects/imports \
  -H "Authorization: Bearer $VIZBL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-idempotency-key: import-chair-2026-06-11" \
  -d '{
    "name": "Oak lounge chair",
    "variants": [
      { "uploadId": "upl_01HX7P6P1P7J9W8V4Y2R7A1KQ9", "name": "Default" }
    ],
    "publish": true
  }'

Poll the job

curl https://api.vizbl.com/developer-api/objects/imports/$JOB_ID \
  -H "Authorization: Bearer $VIZBL_API_KEY"
{
  "jobId": "objimp_01HX7P8FQH4A0VZN0XG5M1NE1R",
  "status": "queued",
  "stage": "waiting_for_worker",
  "retryAfterMs": 1000,
  "createdAt": "2026-06-11T10:00:00.000Z",
  "updatedAt": "2026-06-11T10:00:00.000Z"
}

A succeeded import may also carry warnings, like ai_preview_generation_failed when you asked for an AI preview and it could not be made. The object is imported all the same.

Publish later

An object imported without publish: true is a draft when your account doesn't publish imports automatically, and that setting is off by default: its url doesn't open yet. Publish it when it's ready:

curl -X POST https://api.vizbl.com/developer-api/objects/$TINUUID/publish \
  -H "Authorization: Bearer $VIZBL_API_KEY"

Generate a 3D model from photos

Generations spend tokens

Starting a generation reserves its tokens, and the key needs the developer:generations:create scope. See What a key may do.

Upload the photos

Upload each photo as in Import a 3D file, with type set to image (JPEG, PNG or WebP). Keep each uploadId.

Check the price

POST /developer-api/generations/estimate returns the exact tokens the generation will reserve, and how long it usually takes.

curl https://api.vizbl.com/developer-api/generations/estimate \
  -H "Authorization: Bearer $VIZBL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "provider": "trellis", "quality": "standard", "photo_count": 1 }'

Start the generation

curl https://api.vizbl.com/developer-api/generations \
  -H "Authorization: Bearer $VIZBL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "x-idempotency-key: chair-photo-2026-06-11" \
  -d '{
    "provider": "trellis",
    "quality": "standard",
    "images": [{ "upload_id": "upl_…" }],
    "name": "Oak lounge chair"
  }'

The response is the job, with its job_id and the tokens it holds. The call fails with 402 when the balance is short or the starter generations are used up (see Errors), and with 429 when 5 generations already run at once.

Poll the job

curl https://api.vizbl.com/developer-api/generations/$JOB_ID \
  -H "Authorization: Bearer $VIZBL_API_KEY"

progress shows how far the job is, from 0 to 100. When it succeeds, object holds the tinuuid and the url of the model in your catalog.

{
  "job_id": "…",
  "provider": "trellis",
  "status": "queued",
  "stage": "…",
  "progress": 0,
  "tokens": 40,
  "name": "Oak lounge chair",
  "quality": "standard",
  "object": null,
  "error": null,
  "retry_after_ms": 5000,
  "created_at": "2026-06-11T10:00:00.000Z",
  "updated_at": "2026-06-11T10:00:00.000Z"
}

Cancel, if you need to

curl -X POST https://api.vizbl.com/developer-api/generations/$JOB_ID/cancel \
  -H "Authorization: Bearer $VIZBL_API_KEY"

The job becomes cancelled and its reserved tokens are released.

A complete import

The same flow in code: upload the file, start the import, then poll the job until it finishes.

import.mjs
import { readFile } from 'node:fs/promises';
import { setTimeout as sleep } from 'node:timers/promises';

const API_URL = 'https://api.vizbl.com/developer-api';
const SECRET_KEY = process.env.VIZBL_API_KEY;

async function vizbl(path, { method = 'GET', headers = {}, body } = {}) {
  const response = await fetch(`${API_URL}${path}`, {
    method,
    headers: {
      Authorization: `Bearer ${SECRET_KEY}`,
      'Content-Type': 'application/json',
      ...headers,
    },
    body: body ? JSON.stringify(body) : undefined,
  });

  if (!response.ok) {
    throw new Error(`${method} ${path} failed: ${response.status}`);
  }

  return response.json();
}

// 1. Get an upload URL
const file = await readFile('chair.glb');

const upload = await vizbl('/uploads/presign', {
  method: 'POST',
  body: {
    type: 'model_source',
    fileName: 'chair.glb',
    fileSize: file.byteLength,
    fileType: 'model/gltf-binary',
  },
});

// 2. Upload the file straight to storage, without the API key
const form = new FormData();

for (const [name, value] of Object.entries(upload.uploadFields)) {
  form.append(name, value);
}

const blob = new Blob([file], { type: 'model/gltf-binary' });
form.append('file', blob, 'chair.glb');

const stored = await fetch(upload.uploadUrl, {
  method: upload.uploadMethod,
  body: form,
});

if (!stored.ok) {
  throw new Error(`Upload failed: ${stored.status}`);
}

// 3. Start the import
let job = await vizbl('/objects/imports', {
  method: 'POST',
  headers: { 'x-idempotency-key': `import-${upload.uploadId}` },
  body: {
    name: 'Oak lounge chair',
    variants: [{ uploadId: upload.uploadId, name: 'Default' }],
    publish: true,
  },
});

// 4. Poll the job until it finishes
while (job.status === 'queued' || job.status === 'processing') {
  await sleep(job.retryAfterMs);
  job = await vizbl(`/objects/imports/${job.jobId}`);
}

if (job.status === 'succeeded') {
  console.log('Published:', job.url);
} else {
  console.error('Import failed:', job.error.code, job.error.message);
}

On this page