Image optimization API
Outcome-oriented parameters. Tell us the goal โ we pick the encoding. Available on the Business plan ($49/mo).
Quick start
curl -X POST https://www.imgsquash.com/api/images/optimize \ -H "Authorization: Bearer YOUR_API_KEY" \ -F "image=@photo.jpg" \ -F "format=avif" \ -F "quality=75"
Outcome-oriented parameters
| Goal | format | quality |
|---|---|---|
| smallest | avif | 60 |
| balanced (default) | avif | 75 |
| quality | webp | 85 |
Plus: width, height, maintainAspectRatio, preserveMetadata (Pro+), blur/sharpen/tint (Pro+).
Node.js
const fd = new FormData();
fd.append("image", new Blob([await file.arrayBuffer()]), "photo.jpg");
fd.append("format", "avif");
fd.append("quality", "75");
const res = await fetch("https://www.imgsquash.com/api/images/optimize", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.IMGSQUASH_API_KEY },
body: fd,
});
const pct = res.headers.get("X-Compression-Ratio");Limits & errors
- Business: 10,000 optimizations/hour, 100MB/file, 7680ร4320 max.
400invalid type/size โ429rate limit (respectRetry-After) โ403tier/dimension limit โ500processing failure.- Response headers:
X-Compression-Ratio,X-Original-Size,X-Optimized-Size. - Manage keys in Dashboard โ API Keys. Machine docs:
/llms.txt,/agents.md.