Metadata-Version: 2.4
Name: vectali
Version: 0.4.0
Summary: Vectali API client for image vectorization and vector downloads
Author: Vectali
License-Expression: Apache-2.0
Project-URL: Homepage, https://vectali.com
Project-URL: Documentation, https://vectali.com/docs/
Project-URL: Repository, https://github.com/vectali/vectali-python
Project-URL: Issues, https://github.com/vectali/vectali-python/issues
Keywords: vectali,vectorization,raster-to-vector,svg,sdk
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

<a href="https://vectali.com">
  <picture>
    <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/vectali/.github/main/assets/vectali-logo-dark.svg#gh-dark-mode-only">
    <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/vectali/.github/main/assets/vectali-logo-light.svg#gh-light-mode-only">
    <img alt="Vectali" width="240" src="https://raw.githubusercontent.com/vectali/.github/main/assets/vectali-logo-light.svg">
  </picture>
</a>

# Vectali Python SDK

Official zero-dependency Python client for converting raster artwork to clean SVG, PDF, EPS, and DXF vectors. Requires Python 3.10+ (standard library only, ships `py.typed` for mypy and Pyright).

[Documentation](https://vectali.com/docs/) · [Code Examples](https://vectali.com/docs/code-examples/) · [API Keys](https://app.vectali.com/api) · [Pricing](https://vectali.com/pricing/#api)

## Install

```bash
pip install vectali
```

> Every Vectali account includes **3 free hosted API trial conversions** so you can test end-to-end before choosing a plan.

## Quickstart

```python
import os
from pathlib import Path
from vectali import Vectali

client = Vectali(os.environ["VECTALI_API_KEY"])
result = client.convert_image(Path("logo.png"))
allowance = client.get_allowance()

Path("logo.svg").write_text(result.svg, encoding="utf-8")
Path("logo.pdf").write_bytes(client.get_vector(result.conversion_id, "pdf"))
print(allowance.free_api_conversions.remaining)
```

## Key Methods

| Method | Description |
| --- | --- |
| `client.convert_image(image, ...)` | Accepts `pathlib.Path` (infers filename and MIME type), `bytes`, or a borrowed binary stream. Returns a frozen `Conversion` dataclass. |
| `client.get_vector(conversion_id, vector_format="pdf")` | Downloads `"svg"`, `"pdf"`, `"eps"`, or `"dxf"` as raw `bytes`. Free after conversion. |
| `client.get_allowance()` | Returns a frozen `BillingSummary` dataclass with monthly allowance, granted credits, and `free_api_conversions`. |
| `Vectali().health()` | Public health check; works without an API key and sends no `Authorization` header. |

- `VectaliError` exposes `status`, `details`, `request_id`, and `retry_after`.
- Borrowed binary streams passed to `convert_image` are never closed by the SDK.

## Limits & Billing

| Limit | Value |
| --- | --- |
| Input formats | PNG, JPG, GIF, BMP, WebP |
| Output formats | SVG, PDF, EPS, DXF |
| Max file size | 10 MiB |
| Max resolution | 4,000,000 pixels (4096 px max per side) |
| Billing | 3 free hosted trial conversions included; 1 credit per successful conversion, downloads are free |

- **Idempotent retries:** Every conversion accepts an `Idempotency-Key` (auto-generated UUID v4 if omitted). Reuse the same key and image bytes after an uncertain network error to avoid double-charging.
- **No automatic retries:** Failed requests raise a structured error with HTTP status, `X-Vectali-Request-Id`, and `Retry-After`.
- **Server-side only:** Keep `VECTALI_API_KEY` in server environment variables, never in browser code, prompts, or Git.
- **Safe transport defaults:** 260-second timeout, redirects disabled, and cookies ignored.

---

Apache-2.0 · Source & tests in [vectali/api-tooling](https://github.com/vectali/api-tooling) (`v0.4.0`).
