Developers
Instasize API
An image API in two tiers. Utility calls resize a photo to any social preset or remove its background; generative calls run the same GPU models as the editor to expand a canvas, upscale, or paint out an object. Sandbox keys are free and return watermarked output. Live keys use your plan's AI credits: 1 credit per utility output, 5 per generative call.
Authentication
Create a key in your account and send it on every request, either as an x-api-key header or as a bearer token in Authorization. Keys are shown once when created; store them in an environment variable, never in client-side code.
x-api-key: isk_live_...
# or
Authorization: Bearer isk_live_...isk_test_— sandbox. Free, 1,000 successful calls per calendar month per account (all your sandbox keys share it), output carries an Instasize watermark.isk_live_— live. Clean output, billed to the AI credits on the key owner's plan.
Remove background
POST /remove-background. Send the image as multipart image or as JSON { "image_url": "..." }. Returns a PNG with a transparent background. 1 credit.
curl -X POST https://instasize.com/api/v1/remove-background \
-H "x-api-key: $INSTASIZE_API_KEY" \
-F image=@photo.jpg \
-o cutout.pngResize
POST /resize. Pass a preset such as instagram/story, explicit width and height, or a presets array to get several sizes in one call. A single output returns the image bytes; multiple outputs return JSON with one URL per preset. 1 credit per output.
By preset
curl -X POST https://instasize.com/api/v1/resize \
-H "x-api-key: $INSTASIZE_API_KEY" \
-F image=@photo.jpg \
-F preset=instagram/story \
-o story.jpgMany presets at once (JSON)
curl -X POST https://instasize.com/api/v1/resize \
-H "x-api-key: $INSTASIZE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_url":"https://example.com/photo.jpg","presets":["instagram/story","instagram/square","tiktok/video-post"]}'Presets
GET /presets lists every platform and size the resize endpoint accepts, as platform/name ids with pixel dimensions. No key required.
curl https://instasize.com/api/v1/presetsAI expand
POST /expand. Grows the canvas and paints the new area to continue the scene. Say how much to add with left, right, top and bottom (pixels), or give an aspect such as 1:1 or a preset id and the padding is worked out for you, centred, never cropping the source. Every side rounds up to a multiple of 64 and stops at 2000 px; the response says what was actually added. Optional prompt, negative_prompt and seed. Output is the worker's ~1024 px render. 5 credits.
By aspect ratio
curl -X POST https://instasize.com/api/v1/expand \
-H "x-api-key: $INSTASIZE_API_KEY" \
-F image=@photo.jpg \
-F aspect=1:1 \
-F prompt="sandy beach, soft evening light" \
-o expanded.jpgBy pixels per side (JSON in, JSON out)
curl -X POST "https://instasize.com/api/v1/expand?response=json" \
-H "x-api-key: $INSTASIZE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image_url":"https://example.com/photo.jpg","left":256,"right":256}'{
"image": "data:image/jpeg;base64,...",
"width": 1024,
"height": 1024,
"format": "jpeg",
"added": { "left": 0, "right": 0, "top": 192, "bottom": 192 },
"credits_charged": 5,
"sandbox": false
}AI upscale
POST /upscale. Send the image and nothing else; the model enlarges and sharpens it and returns the image (PNG when the worker keeps transparency, otherwise JPEG). Add ?response=json to get a data URL together with the source size. 5 credits.
curl -X POST https://instasize.com/api/v1/upscale \
-H "x-api-key: $INSTASIZE_API_KEY" \
-F image=@photo.jpg \
-o upscaled.jpgAI object removal
POST /remove-object. Two images: the image and a mask of exactly the same pixel size, white where the object is and black everywhere else. Both travel the same way — multipart files, JSON data URLs, or image_url and mask_url. A mask of a different size is refused with 400 invalid_request. Returns PNG when the result has transparency, otherwise JPEG. 5 credits.
curl -X POST https://instasize.com/api/v1/remove-object \
-H "x-api-key: $INSTASIZE_API_KEY" \
-F image=@photo.jpg \
-F mask=@mask.png \
-o object-removed.jpgErrors
Every non-2xx response uses one envelope. Quote the request_id when you write in; it is also returned on successful calls as the X-Request-Id header.
{
"error": {
"code": "usage_exceeded",
"message": "Sandbox limit reached: 1,000 successful calls per calendar month across all your sandbox keys.",
"request_id": "req_01J8ZK3M2Q4X"
}
}| Code | Status | Meaning |
|---|---|---|
unauthorized | 401 | No key was sent. |
invalid_key | 401 | The key does not exist or is malformed. |
key_revoked | 401 | The key was revoked or disabled in /account. |
key_expired | 401 | The key passed its expiry date. |
usage_exceeded | 429 | Your account used its 1,000 free sandbox calls this calendar month. |
rate_limited | 429 | Too many requests in the current minute. Check X-RateLimit-Reset. |
payment_required | 402 | The owner of a live key has no AI credits left on their plan. |
invalid_request | 400 | A required field is missing or a value is out of range (unknown preset, bad dimensions). |
payload_too_large | 413 | The image exceeds the upload limit. |
unsupported_media_type | 415 | The body is not multipart/form-data or application/json, or the image format is not supported. |
upstream_failed | 502 | The model or processing worker failed. No credit was charged. |
Rate limits
Limits are per key, per minute: sandbox keys 20 requests, live keys 120. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (seconds until the window resets). Over the limit you get 429 rate_limited; back off until the reset time.
Credits
- Utility, 1 credit:
resizeper output image (three presets in one call cost 3 credits) andremove-background. - Generative, 5 credits per call:
expand,upscaleandremove-object. These run on GPU workers and take longer — allow up to a minute. - Failed calls (any 4xx or 5xx) are not charged; a charge taken before a failure is refunded.
- Sandbox keys are never billed. Your account gets 1,000 successful sandbox calls per calendar month across all its sandbox keys; refused requests (4xx) do not count.
Live keys spend the same AI credits as the editor, so usage shows in your account next to your keys.
OpenAPI
The machine-readable contract for every endpoint above is at /api/v1/openapi.json. Point a client generator at it, or import it into Postman or Insomnia.