Skip to content

Uploads and reference images

Models that edit, combine or animate images take them in reference_images. Each entry can be:

  • One of your outputs: the url of an image your account generated, while it still exists.
  • An upload: the url returned by POST /v1/uploads.
  • Any other HTTPS image URL: it’s imported as an upload when you create the task.

Every upload is screened before it can be used, and each model’s page says how many reference images it takes and how the prompt refers to them (“the first image”, “the second image” and so on).

Send the image itself, a multipart form with a file field, or JSON with a url to import. JPEG, PNG and WebP are accepted, up to 20 MB.

Terminal window
# The image as the body
curl https://api.velvetapi.dev/v1/uploads?user=user-123 \
-H "Authorization: Bearer $VELVET_API_KEY" \
-H "Content-Type: image/jpeg" \
--data-binary @portrait.jpg
# Or import it from a URL
curl https://api.velvetapi.dev/v1/uploads \
-H "Authorization: Bearer $VELVET_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/portrait.jpg", "user": "user-123"}'

The answer is 201 Created with the upload:

{
"id": "9309bf14-9c4d-4a0a-b72c-84d9105269a5",
"object": "upload",
"url": "https://api.velvetapi.dev/v1/uploads/9309bf14-9c4d-4a0a-b72c-84d9105269a5",
"status": "ready",
"content_type": "image/jpeg",
"bytes": 151235,
"source_url": null,
"created_at": "2026-10-20T21:00:29.187Z",
"expires_at": "2026-10-27T21:00:29.187Z"
}

Pass url in reference_images:

{
"model": "flux-3-klein",
"user": "user-123",
"input": {
"prompt": "The same person as a 1940s film noir portrait, dramatic rim light, black and white.",
"reference_images": ["https://api.velvetapi.dev/v1/uploads/9309bf14-9c4d-4a0a-b72c-84d9105269a5"]
}
}

The upload URL only works in your own account’s tasks; it isn’t a public link to the image.

Each upload is checked for faces before it’s stored as ready, which takes a few seconds:

  • If a face in the image looks under 18, the image can’t be used. The upload fails with 422 upload_blocked, and so does any task that references it.
  • If that image is also explicit, it’s kept in locked evidence storage for review and counts as a strike against the end user. Send their id as user when you upload for them.
  • If screening can’t run, the upload isn’t created and you get 503 screening_unavailable. Retry after a short wait.

Uploading the same bytes again returns the earlier upload instead of screening it twice.

An upload can be used for 7 days, until expires_at. GET /v1/uploads/{id} returns it, and DELETE /v1/uploads/{id} deletes the image straight away; after either, its status is expired and tasks can’t use it. Outputs made from an upload aren’t affected.

Status Type When
400 invalid_image The file is empty, isn’t a JPEG, PNG or WebP, or can’t be decoded.
400 image_too_large Over 20 MB.
400 image_unreachable The URL to import couldn’t be fetched.
415 unsupported_media_type The body isn’t an image, a multipart form with file, or JSON with url.
422 upload_blocked A face in the image looks under 18.
422 reference_not_allowed A task referenced an expired upload, another account’s upload, or a CDN link that isn’t your account’s live output.
503 screening_unavailable Screening couldn’t run. Nothing was stored.