The official Forge-generated Python SDK requires Python 3.10+ and uses only the standard library. The SDK ships type information for mypy and Pyright.
Install
pip install vectaliInstall directly from PyPI (v0.4.1+), or pin a Git tag with pip install "git+https://github.com/vectali/vectali-python.git@v0.4.1".
Convert and download
Set VECTALI_API_KEY before running the example. convert_image returns a frozen Conversion dataclass with result.svg, result.conversion_id, result.paths and result.optimized_bytes. get_vector returns the exact download bytes.
import os
from pathlib import Path
from vectali import Vectali
client = Vectali(os.environ["VECTALI_API_KEY"])
result = client.convert_image(Path("logo.png"))
Path("logo.svg").write_text(result.svg, encoding="utf-8")
Path("logo.pdf").write_bytes(client.get_vector(result.conversion_id, "pdf"))Choose an input type
Pass a Path to infer the filename and MIME type, or pass bytes with an explicit filename. A borrowed BinaryIO is read up to the upload limit plus one byte, and the caller closes it. Rewind or reopen the stream before a retry.
with Path("logo.png").open("rb") as image:
result = client.convert_image(image, filename="logo.png")
Check allowance and health
allowance = client.get_allowance()
print(allowance.free_api_conversions.remaining)
print(allowance.api_credits.available)
Vectali().health()
get_allowance() returns the frozen BillingSummary dataclass. Unit tests can point Vectali at a local fixture with base_url. Its default timeout is 260 seconds.
Handle errors and retries
Keep the same idempotency_key and image bytes across attempts. If the key is omitted, the SDK creates a UUID per call.
from vectali import VectaliError
try:
result = client.convert_image(Path("logo.png"), idempotency_key=job_id)
except VectaliError as error:
print(error.status, error.request_id)
if error.status == 429:
print("Retry-After:", error.retry_after)
raise
Read error.details for the decoded API body when available. Handle ValueError for local input validation and credentials, and handle transport failures separately. See errors and recovery for retryable responses.