Sign up free
Documentation
Type to search. Use the down arrow to browse results, or Escape to close them.

Code examples

Upload from your server with an API key, keep retries consistent, and save the SVG string.

Send an image from your server

Create a vt_live_... key in the dashboard and store it as VECTALI_API_KEY in your server environment. Your account needs available API credits, from a subscription or an administrator grant. Never use a browser-exposed environment variable for this secret.

These examples use ordinary HTTP clients. Node.js uses its built-in Fetch, FormData, Blob, and filesystem APIs. For Python, install requests with python -m pip install requests.

# Set a new request ID for each new conversion; keep it for retries.
REQUEST_ID="logo-upload-20261015-001"
curl --fail-with-body \
  https://api.vectali.com/api/v1/vectorize \
  --header "Authorization: Bearer $VECTALI_API_KEY" \
  --header "Idempotency-Key: $REQUEST_ID" \
  --form 'image=@logo.png' \
  --output result.json

The 240-second timeout is an application choice, not a processing-time promise. An upstream failure can return sooner. Preserve the request ID when handling a timeout, since the server may have already completed the conversion.

Keep a request ID for each conversion

Create an ID once, when starting a new conversion. Store it with your upload job if the request can outlive the process handling it. Reuse it only for retries of that same conversion.

const job = {
  id: crypto.randomUUID(),
  filename: "logo.png",
};

// Each attempt rebuilds the multipart body from the same input.
// Keep job.id in the Idempotency-Key header across those attempts.

A 409 conversion_in_progress means the original attempt is still running. Wait before trying again. A completed replay returns the original conversion_id and SVG without spending another allowance. See the full retry contract.

Browser preview

Your server can return the resulting SVG to your own authenticated browser client. Reference a Blob URL from an image instead of assigning SVG markup to innerHTML.

const preview = document.querySelector("img[data-preview]");
let previousUrl;

function showSvg(svg) {
  if (previousUrl) URL.revokeObjectURL(previousUrl);
  previousUrl = URL.createObjectURL(
    new Blob([svg], { type: "image/svg+xml" }),
  );
  preview.src = previousUrl;
}

// Also revoke previousUrl when the preview is removed.

Keep the integration small

Validate your upload, check the response status, and save the returned svg string as UTF-8. Keep the conversion_id with your application’s record so you can identify the result. Do not log the API key, original image bytes, or full SVG just to record a successful request.

A useful next step? Read the journal