Velox TriFit / DressMe / Developer tutorial

Virtual try-on API.
From demo to your app.

Build clothing virtual try-on with the JavaScript SDK: upload photos, submit a job and poll for its result, with your backend in control.

DressMe accepts a shopper photo and a clothing reference to create an AI outfit preview. TriFit is Velox's consumer app; Partner API credentials are issued separately. AI previews are not measurements or guarantees of fit.

Shopify app or custom API integration?

For a Shopify clothing store, start with the Velox Tri-Fit Shopify virtual try-on app and its demo store. That is the merchant installation route for DressMe photo previews and AnimateMe videos; it does not require you to build the example API backend below.

Use this guide when you are building your own website, mobile app or custom commerce integration. Shopify installation does not grant Partner API credentials. MCP helps a coding agent read the contract; your backend still needs separately approved API access.

For personal clothing previews, open TriFit. See the Velox app, Shopify, API and MCP comparison if you are choosing a route rather than implementing one.

1. Explore the working example

Open the hosted demo and its developer dashboard & SDK download. Viewing these pages does not submit a try-on. Real generation requires an explicit submission, consent and available demo allowance.

The public dashboard shows your browser session's requests and public source downloads, not Velox's operator admin. The demo key remains on Velox's server. Your own private partner dashboard and configuration are supplied after approval.

2. Run the preview without an API key

Install Node.js 22 or later and Git, then use a new local folder:

git clone https://github.com/Velox-XR/trifit-partner-api-example.git
cd trifit-partner-api-example
npm run preview

Open the local URL printed by the server. Preview mode does not upload images or generate results. The optional npm run demo:mock and npm run demo:failure commands use artificial local responses. They are not real AI output or performance evidence.

Read Getting started, the technical walkthrough and the SDK catalogue. Source and hosted deployments can have different release versions.

3. Request your own partner configuration

Apply for Partner API access with your use case, platform and expected usage. After review, Velox supplies an environment-specific integration identity, private API key and configuration. A free TriFit account or MCP connection is not a partner credential.

The example's checked-in key is deliberately invalid. Place only your own supplied partner.config.json beside package.json; keep it out of source control. npm start starts the configured backend and checks its assigned identity and environment. Unlike preview, this enables real API use, which can incur charges when you submit requests.

4. Connect the secure backend

The shipped SDK is JavaScript with TypeScript declarations, available as public source. See its method reference; do not assume a public npm package or an unlisted SDK exists.

  1. Verify your assigned API identity and environment before processing user media.
  2. Derive each shopper's opaque subject from your authenticated server session, never a client-selected identity.
  3. Upload a catalogue product through Partner API and persist the final asset ID. Reuse it within the same permitted catalogue and environment.
  4. Obtain the shopper's permission, upload their photo and persist the upload receipts.
  5. Before submission, durably save the exact input asset IDs and one idempotency key. Save the accepted job ID.
  6. Use the documented signed webhook flow when configured, or read job status. Display a result only to the authorized shopper.
  7. Reconcile uncertain submissions using saved receipts. Do not create a second job or new idempotency key merely because a response timed out.

Your app → your authenticated backend → Velox Partner API. Temporary storage URLs receive only their specified upload headers, never the Partner API credential. Keep private media and signed URLs out of logs.

Upload, submit and poll: the JavaScript API workflow

This is the DressMe image workflow for an approved application integration. It describes real API methods, not permission to send media or incur generation charges. Configure the supplied API URL, client ID and private key on your server; await applicationInfo(), verify its returned environment and bind the shopper subject from your authenticated session before use.

Upload the garment and shopper photo

Use uploadProductImage for the catalogue garment and uploadPersonalPhoto for the shopper's consented image. Both helpers reserve an asset, transfer bytes and complete the upload. Persist each provisional ID in the awaited onAssetCreated callback before bytes transfer, then save the final returned ID. Product completion can return an existing canonical ID; retain the provisional receipt too.

Reuse the final product ID within the permitted catalogue and environment. Personal photos and results remain shopper-scoped. Asset status: ready means upload completion; it is not proof that asynchronous product preparation is ready. Only send the returned upload headers to temporary storage URLs, never the Partner API key.

Submit asset IDs, not image bytes

Durably save personalAssetId, productAssetId and one UUID idempotencyKey before calling createDressMeJob. Save the accepted job ID. If the response is uncertain, reconcile the original request with the same input and key; do not start a second generation with a new key.

Poll the saved job or receive a signed webhook

getDressMeJob reads one status; waitForDressMe polls with a bounded deadline and interval. Job states are queued, running, succeeded and failed. On success, return the preview only to the authorized shopper. A simulated result is not AI output. A polling timeout or abort stops local waiting, not the accepted backend job.

Signed completion webhooks are an optional configured alternative to polling. Verify the signature and bind the event to your saved job before using its result. An expired result URL can be refreshed through the authorized getAsset read. Do not log private media URLs or resubmit generation just to obtain a fresh URL.

For uncertain uploads, keep the original receipt and reconcile with getAsset and completeImageUpload; a timeout does not prove the upload failed. Consult the SDK methods, upload recovery and webhook reference for exact arguments and error handling.

JavaScript examples you can inspect before connecting

For a coding-agent workflow, use the existing Codex, Copilot and Gemini integration guide alongside the example below. MCP supplies API guidance; your application backend performs the separately authorized REST integration.

The runnable JavaScript offline example uses simulated responses, with no cloud upload or generation. In the checked-out public example repository, run:

npm run demo:mock
npm run demo:failure

Compare it with the backend integration walkthrough and SDK source and TypeScript declarations. The SDK is supplied as public source; these commands do not install an assumed public npm package or grant API access. A mock passing is not live acceptance.

Complete existing offline example

This is the repository's demo.mjs, reproduced from the inspected source. Run it from that repository so its existing client and mock modules are available. It demonstrates the full REST workflow with a local mock and a placeholder result; it is not a real try-on or a standalone production backend.

import { randomUUID } from 'node:crypto';
import { DressMeClient } from './src/client.mjs';
import { DUMMY, PLACEHOLDER, startMockApi } from './src/mock-api.mjs';

const failure = process.argv.includes('--failure');
const mock = await startMockApi({ failure });
try {
  console.log('DressMe Partner API — LOCAL SIMULATION ONLY');
  console.log('Dummy credentials. Placeholder images. No Velox/cloud calls or generation charges.\n');
  const api = new DressMeClient({ baseUrl: mock.baseUrl, ...DUMMY });
  await api.verifyEnvironment('local-mock');
  console.log('1. Backend connection and expected environment verified.');
  // In this throwaway simulation, IDs live in memory. Persist them in your database in a real integration.
  const saved = {};
  const image = new Blob([PLACEHOLDER], { type: 'image/png' });
  const product = await api.upload(image, { role: 'product', fileName: 'dummy-product.png', onReserved: id => { saved.productUploadId = id; } });
  saved.productAssetId = product.id; // Completion may return a deduplicated catalogue ID.
  console.log('2. Product uploaded and completed. Reuse its final asset ID for later shoppers.');
  const personal = await api.upload(image, { role: 'personal', fileName: 'dummy-person.png', onReserved: id => { saved.personalUploadId = id; } });
  saved.personalAssetId = personal.id;
  console.log('3. Personal image uploaded under this shopper’s opaque subject.');
  saved.idempotencyKey = randomUUID();
  saved.payload = { personalAssetId: saved.personalAssetId, productAssetId: saved.productAssetId };
  const job = await api.createJob(saved.payload, saved.idempotencyKey);
  saved.jobId = job.id;
  console.log(`4. Job accepted: ${job.status}. Poll this job; do not submit another.`);
  const done = await api.waitForJob(saved.jobId, { intervalMs: 50, onStatus: status => console.log(`   Status: ${status}`) });
  const result = await fetch(done.result.url, { redirect: 'error', signal: AbortSignal.timeout(5000) }); // No API headers.
  if (!result.ok) throw new Error('Could not read simulated result.');
  const imageBytes = new Uint8Array(await result.arrayBuffer());
  console.log(`5. Result retrieved (${imageBytes.length} bytes). simulated=${done.simulated}.`);
  console.log('   This is a one-pixel placeholder, NOT an AI try-on or evidence of quality/latency.');
} catch (error) {
  if (failure && error.code === 'generation_failed') console.log(`Handled expected failure: ${error.message}`);
  else { console.error(`Example stopped: ${error.name}${error.code ? ` (${error.code})` : ''}. No automatic retry.`); process.exitCode = 1; }
} finally {
  await mock.close();
  console.log('\nRegister Partner API interest: https://studio.v3lox.com/partner-api#apply (mention Partner API / DressMe)');
}

The example verifies its environment, retains upload receipts and final IDs, submits an exact payload with one idempotency key, polls the accepted job and reads the simulated result without forwarding API credentials. Run npm run demo:failure to exercise its handled failure. The mock keeps receipts in memory; use durable storage and the existing backend walkthrough for a real integration.

For a coding agent, start with the Velox TriFit virtual try-on MCP connection guide to retrieve the same public contracts. Connecting MCP or installing skills does not supply a Partner API credential. Review generated code and obtain separate authorization before any real upload or generation.

5. Build for Swift, C# or your web framework

A coding agent can generate application code from the documented HTTP contract. There is no separate official Swift or C# SDK in the current public catalogue. Mobile apps should call your own authenticated backend; that backend holds the Velox key and enforces consent, authorization and spending controls.

Connect the public developer MCP server, then adapt this prompt:

Build a mobile virtual try-on integration using Velox TriFit / DressMe. Ask which platform I need: Swift/SwiftUI or C#/.NET. Read the official API walkthrough and SDK source first. Create the mobile UI and a separate authenticated backend; keep the Velox application key on the backend. Include photo consent, upload receipts, job status, cancellation of local waiting, uncertain-response recovery and privacy-aware error messages. Do not promise that cancelling local waiting cancels an accepted job. Use mocks for tests. Do not upload, generate, provision credentials, deploy or change quotas without my explicit instruction. Cite the exact API contracts used and label generated native code as an example, not a released Velox SDK.

Before enabling real requests

Discuss your integration ↗