Media Uploads
Upload an image once with your API key and refer to it by its id. PNG, JPEG and WebP images are kept until you delete them, and they also appear in your Studio Library.
Endpoints
POST /v1/mediaUpload one image.GET /v1/mediaList the 40 newest images this key may use.GET /v1/media/{id}Read one image's details.PATCH /v1/media/{id}Turn shared_with_keys on or off (the key that uploaded the image only).DELETE /v1/media/{id}Delete an image (the key that uploaded it only).
Uploading an image
Send the file as the raw request body with Content-Type image/png, image/jpeg or image/webp, or as multipart/form-data with the file in a field named file. A data: URL, a JSON body and a link to fetch are not accepted.
curl -sS -X POST https://api.fastmetal.ai/v1/media \
-H "Authorization: Bearer $FASTMETAL_API_KEY" \
-H "Content-Type: image/jpeg" \
--data-binary @frame.jpgcurl -sS -X POST https://api.fastmetal.ai/v1/media \
-H "Authorization: Bearer $FASTMETAL_API_KEY" \
-F "file=@frame.jpg" \
-F "shared_with_keys=true"Add ?shared_with_keys=true (or a shared_with_keys field in the form) to make the image available to all your keys from the start.
The answer is 201 with the image's id, type, size in bytes, width and height. The id names the image in the other media calls.
{
"id": "6f1c2a0e-8d4b-4f6e-9a51-3c2d7e8f9b10",
"object": "media",
"mime_type": "image/jpeg",
"bytes": 1342177,
"width": 1080,
"height": 1920,
"created_at": 1794700800,
"expires_at": null,
"status": "ready",
"shared_with_keys": false,
"access": "own"
}Limits
- 10 MiB per image.
- At most 25 million pixels, and one frame: animated images are refused.
- 500 uploads per account, counted together with Studio uploads, and 30 uploads a minute.
- Two uploads at a time per account, whichever keys send them. A third is refused (429) until one of them ends.
- The body must keep arriving: from the first 10 seconds on, at least 160 KiB in every 10 seconds (about 128 kbit/s), and all of it within 120 seconds; otherwise it is cut (408). 10 MiB needs about 0.7 Mbit/s.
- Checking images takes server time. An account whose uploads have used 15 seconds of it in one minute waits for the next minute (429 decode_budget). An ordinary photo takes well under a second.
- Every file is decoded once before it is kept. A damaged or incomplete file is refused and nothing is stored.
- width and height are the stored pixels: an EXIF orientation tag is not applied, so a photo a phone stored sideways reports its stored size. The file itself is kept exactly as uploaded.
Which keys can use an image
An image is usable by the key that uploaded it. Two settings, both off by default, widen that within your own account:
- Whole-library access, set per key on the keys page while signed in: the key can use every image you own, including Studio uploads, character and reference photos, and image results. Videos are not included: no key reaches a video through the media API.
- Available to all my keys, set per image in the Studio Library, or with shared_with_keys by the key that uploaded it: every key of yours can use that image.
Each image in a listing carries access: own (this key uploaded it), shared (available to all your keys) or library (this key has whole-library access).
Only the key that uploaded an image, and you when signed in to Studio, can delete it or change shared_with_keys.
Images uploaded in Studio keep Studio's own checks and are not decoded again: a key with access sees them as ready, with width and height null.
curl -sS -X PATCH https://api.fastmetal.ai/v1/media/6f1c2a0e-8d4b-4f6e-9a51-3c2d7e8f9b10 \
-H "Authorization: Bearer $FASTMETAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{"shared_with_keys": true}'
curl -sS -X DELETE https://api.fastmetal.ai/v1/media/6f1c2a0e-8d4b-4f6e-9a51-3c2d7e8f9b10 \
-H "Authorization: Bearer $FASTMETAL_API_KEY"Errors
400The file is not a PNG, JPEG or WebP image, is damaged, animated or above the pixel limit, or the body is in a form that is not accepted.401missing_api_key or invalid_api_key: no key was sent, or the key is not valid (revoked, or its account was closed).403media_not_shared: the image is yours but this key may not use it, and the message says how to allow it. media_not_creator: only the key that uploaded it can delete it or change its setting. media_not_available: campaign keys and Lite seat keys cannot use media.404No image with this id in this account. upload_url_invalid: the upload URL was already used, expired (after 15 minutes) or never existed.408body_timeout: the body took longer than 120 seconds. body_too_slow: after the first 10 seconds, less than 160 KiB arrived in some 10 seconds.409media_pending: the image is still being uploaded, and cannot be deleted until its upload ends.413The image is larger than 10 MiB.429rate_limited: more than 30 uploads in one minute, or too many requests from one address. uploads_in_flight: two uploads from this account are already in progress. decode_budget: this account's uploads have used this minute's image-checking time. Each answer carries Retry-After.502media_store_failed or media_delete_failed: the file could not be stored or deleted. The image is as it was; try again.503media_busy: the server is busy with other uploads or image checks. auth_unavailable: the key could not be checked right now, and has not been rejected. Retry after the Retry-After time.Cost and data
Uploading, listing and deleting images is not charged. An image is reachable from your own account only: by default only the key that uploaded it can use it, and no setting shares it with another account or organization.