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.jsonimport { readFile, writeFile } from "node:fs/promises";
import { randomUUID } from "node:crypto";
const apiKey = process.env.VECTALI_API_KEY;
if (!apiKey) throw new Error("Set VECTALI_API_KEY on your server.");
const requestId = randomUUID(); // Keep this value when retrying this conversion.
const body = new FormData();
body.append("image", new Blob([await readFile("logo.png")], {
type: "image/png",
}), "logo.png");
const response = await fetch("https://api.vectali.com/api/v1/vectorize", {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Idempotency-Key": requestId,
},
body,
signal: AbortSignal.timeout(240_000),
});
const result = await response.json();
if (!response.ok) throw new Error(result.error ?? "Conversion failed.");
await writeFile("logo.svg", result.svg, "utf8");from pathlib import Path
import os
import uuid
import requests
request_id = str(uuid.uuid4()) # Reuse this value for retries.
with open("logo.png", "rb") as image:
response = requests.post(
"https://api.vectali.com/api/v1/vectorize",
headers={
"Authorization": f"Bearer {os.environ['VECTALI_API_KEY']}",
"Idempotency-Key": request_id,
},
files={"image": ("logo.png", image, "image/png")},
timeout=240,
)
response.raise_for_status()
Path("logo.svg").write_text(response.json()["svg"], encoding="utf-8")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.