Image convert
POST https://tools.yukai.uk/api/v1/image/convert
Convert an image to JPEG, PNG, WebP or AVIF. Converts to format. Transparent areas become white in JPEG (or background). AVIF is limited to 1,200 px per side: larger results are written as WebP with the warning avif_too_large_used_webp (or send maxSize 1200). PNG results are limited to 16 megapixels (send maxSize). Metadata (EXIF, GPS) is removed. Typical time under 1 second; 20+ megapixel photos 3-9 seconds. Send an image URL (GET or POST), a base64 image (POST JSON), a file upload (POST multipart/form-data, field image) or the raw image bytes (POST with Content-Type: image/*, options in the query string). The answer is the image itself by default (response=json for metadata + base64). One call = one image. The same image with the same options is answered from a 24-hour cache.
Cost
Credits: 18 ($0.0018) per successful call. Failed calls are free. Source price: ai-image-toolkit/image-processed.
Input
Send a JSON body (POST) or the same fields as a query string (GET).
Required: format.
| Field | Type | Default | Description |
|---|---|---|---|
url | string | Public image URL (JPEG, PNG, WebP or GIF, up to 10 MB, 50 megapixels and 12,000 px per side). Private, local and cloud-metadata addresses are refused on every redirect. Alias: imageUrl. For POST you can send image (base64) or upload the file instead. | |
format required | string | Target format (required). | |
quality | integer | 85 | Quality for JPEG, WebP and AVIF (ignored for PNG, which is lossless). Default 85. |
maxSize | integer | Longest side of the result in pixels; larger images are scaled down (never up), keeping the aspect ratio. | |
background | string | Fill color for transparent areas when converting to JPEG (default white). | |
response | string | "image" | image (default): the response body is the image itself (Content-Type: image/..., metadata in x-* headers). json: JSON with the metadata and the image as base64 in image (results up to 15 MB). |
image | string | The image itself as base64 or a data URL (data:image/png;base64,...), up to 10 MB decoded. POST only. Aliases: imageBase64, base64. |
Examples
Replace tt_live_XXXX with your key from the pricing page.
curl
curl -i -X POST "https://tools.yukai.uk/api/v1/image/convert" \
-H "Authorization: Bearer tt_live_XXXX" \
-H "Content-Type: application/json" \
-d '{"url":"https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/960px-Tux.svg.png","format":"webp","response":"json"}'JavaScript (fetch)
const res = await fetch("https://tools.yukai.uk/api/v1/image/convert", {
method: "POST",
headers: { "Authorization": "Bearer tt_live_XXXX", "Content-Type": "application/json" },
body: JSON.stringify({"url":"https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/960px-Tux.svg.png","format":"webp","response":"json"}),
});
console.log(res.status, res.headers.get("x-credits-charged"), res.headers.get("x-credits-balance"));
console.log(await res.json());Python (requests)
import requests
r = requests.post(
"https://tools.yukai.uk/api/v1/image/convert",
headers={"Authorization": "Bearer tt_live_XXXX"},
json={"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/35/Tux.svg/960px-Tux.svg.png", "format": "webp", "response": "json"},
timeout=120,
)
print(r.status_code, r.headers.get("x-credits-charged"), r.headers.get("x-credits-balance"))
print(r.json())
Response
JSON with "success": true and the result fields; on failure {"success": false, "error": {"code", "message", "retryable"}} and no credits are used. Every answer carries x-credits-charged (credits used) and x-credits-balance (balance after the call); check the balance any time with GET https://tools.yukai.uk/v1/billing/balance.
Full field list and response schema: OpenAPI spec image-tools (its servers entry is the marketplace gateway; call https://tools.yukai.uk with your key).