Convert API
Server-side image conversion. POST an image, get AVIF/WebP/PNG/JPEG back.
What is it?
POST /api/convert accepts a multipart form with an image file and optional format/quality. The response is the converted image binary. You must send a valid API key in the request (create one after signing in with GitHub).
Authentication
Every request must include your API key in the header:
Authorization: Bearer YOUR_API_KEYCreate and manage keys (after signing in):
API Keys →Endpoint
POST /api/convert
Request (multipart/form-data)
| Field | Required | Description |
|---|---|---|
| file | ✅ | Image file (AVIF, WebP, PNG, JPEG, GIF). Max 20MB. |
| format | - | Output format: avif, webp, png, jpeg. Default: avif. |
| quality | - | Quality 1–100. Default: 75. Ignored for png. |
| speed | - | AVIF encode speed 0–10 (higher = faster, lower compression). Default: 5. |
Examples
cURL
curl -X POST \
-H "Authorization: Bearer YOUR_API_KEY" \
-F file=@image.png \
-F format=avif \
-F quality=80 \
https://getavif.com/api/convert \
-o out.avifFetch (JavaScript)
const formData = new FormData();
formData.append("file", imageFile);
formData.append("format", "avif");
formData.append("quality", "80");
const res = await fetch("https://getavif.com/api/convert", {
method: "POST",
headers: {
Authorization: `Bearer ${YOUR_API_KEY}`,
},
body: formData,
});
if (!res.ok) throw new Error(await res.text());
const blob = await res.blob();
// e.g. save or use blobReplace YOUR_API_KEY with your API key.
Response
200: binary image with Content-Type (e.g. image/avif) and Content-Disposition attachment. 400: invalid request. 401: missing or invalid API key. 503: conversion or key validation unavailable.
Errors
All errors return JSON with an "error" field. Use GET /api/convert for a short usage summary.