Conversion API
Programmatic image conversion for Pro subscribers. Convert between AVIF, JPG, PNG, and WebP with a single HTTP request.
The iLoveAVIF API gives you server-side image conversion via a simple REST endpoint. Send a file, get a converted file back. Requires a Pro subscription ($4.99/mo) and an API key from your dashboard.
Quick Start
curl -X POST https://iloveavif.com/api/v1/convert \
-H "X-API-Key: YOUR_API_KEY" \
-F "file=@photo.jpg" \
-F "format=avif" \
-F "quality=75" \
--output photo.avifAuthentication
All API requests require an API key sent via the X-API-Key header. Keys use the format ilav_ followed by 40 hex characters (45 characters total).
Create and manage API keys in your dashboard. You can have up to 5 active keys. Keys are shown once at creation — only the SHA-256 hash is stored on our servers.
Endpoint: POST /api/v1/convert
Send a multipart/form-data request with the image file and conversion parameters. The response is the converted image as raw binary data.
Request Fields
| Field | Type | Required | Description |
|---|---|---|---|
file | binary | Yes | Image file (max 10MB, max 10 megapixels) |
format | string | Yes | Output format: avif, jpg, png, or webp |
quality | integer | No | 1–100 (default 75). Ignored for PNG (lossless). |
Response Headers
| Header | Description |
|---|---|
Content-Type | MIME type of the output (image/avif, image/jpeg, etc.) |
Content-Disposition | attachment; filename="photo.avif" |
X-Original-Size | Input file size in bytes |
X-Output-Size | Output file size in bytes |
X-Savings | Compression savings percentage (e.g. 60%) |
Cache-Control | no-store |
Supported Formats
| Input | AVIF | JPG | PNG | WebP |
|---|---|---|---|---|
| AVIF | ✓ | ✓ | ✓ | ✓ |
| JPG | ✓ | ✓ | ✓ | ✓ |
| PNG | ✓ | ✓ | ✓ | ✓ |
| WebP | ✓ | ✓ | ✓ | ✓ |
Response
Success (200)
The response body is the raw converted image binary. Use the Content-Type header to determine the output format and X-Savings to check compression efficiency.
Error (JSON)
All errors return JSON with an error field:
{
"error": "Daily rate limit exceeded",
"limit": 1000,
"used": 1000,
"resets": "2026-02-26T00:00:00Z"
}Error Codes
| Status | Condition | Example Response |
|---|---|---|
| 400 | Missing file, invalid format, bad quality, or exceeds 10MP | {"error":"No file provided"} |
| 401 | Missing or invalid API key | {"error":"Invalid API key"} |
| 403 | User not on Pro plan | {"error":"Pro subscription required"} |
| 413 | File exceeds 10MB | {"error":"File exceeds 10MB limit"} |
| 429 | Daily rate limit exceeded | {"error":"Daily rate limit exceeded","limit":1000} |
| 500 | Conversion failure or internal error | {"error":"Conversion failed"} |
Rate Limits
Pro subscribers can make up to 1,000 API requests per day (UTC). The limit is enforced atomically — concurrent requests cannot exceed the limit. When the limit is reached, the API returns a 429 response with limit, used, and resets fields.
CORS
The conversion endpoint includes CORS headers for browser-based integrations:
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, OPTIONS
Access-Control-Allow-Headers: X-API-Key, Content-Type
Access-Control-Max-Age: 86400An OPTIONS preflight handler returns these headers with a 204 response. This means you can call the API directly from browser JavaScript.
Code Examples
curl
curl -X POST https://iloveavif.com/api/v1/convert \
-H "X-API-Key: ilav_YOUR_KEY_HERE" \
-F "file=@input.jpg" \
-F "format=avif" \
-F "quality=60" \
--output output.avifJavaScript (fetch)
const form = new FormData();
form.append("file", fileInput.files[0]);
form.append("format", "webp");
form.append("quality", "80");
const res = await fetch("https://iloveavif.com/api/v1/convert", {
method: "POST",
headers: { "X-API-Key": "ilav_YOUR_KEY_HERE" },
body: form,
});
const blob = await res.blob();
const url = URL.createObjectURL(blob);Python (requests)
import requests
res = requests.post(
"https://iloveavif.com/api/v1/convert",
headers={"X-API-Key": "ilav_YOUR_KEY_HERE"},
files={"file": open("input.png", "rb")},
data={"format": "avif", "quality": "75"},
)
with open("output.avif", "wb") as f:
f.write(res.content)
print(f"Savings: {res.headers['X-Savings']}")Limitations
- Animated images — Animated GIF/WebP/AVIF files are converted as a static image (first frame only).
- Metadata stripping — EXIF data, ICC color profiles, and other metadata are removed during conversion. Output images are clean sRGB.
- CMYK JPEGs — CMYK images are automatically converted to RGB, but color accuracy may vary.
- Max file size — 10MB per request.
- Max dimensions — 10 megapixels (width × height).
Get API access with a Pro subscription — $4.99/mo for 1,000 conversions/day.
Get Started