sangtao.ai
API key

Upload a reference image

Upload via presign

Upload an image up to 25 MB and get a URL back, for use as a reference image.

POSThttps://api.sangtao.ai/v2/images/presign

Images uploaded here are kept only temporarily, as reference images (referenceImages) for the image you create right after, and are deleted automatically after 1 day. To keep a file for good and reuse it, use the asset library. Files up to 25 MB, in two calls: get a link, then PUT the file to it.

Headers

X-Api-Keystringrequired

Your API key. Create one on the API Key page in your account.

Content-Typestringrequired

application/json

Request

fileNamestringrequired

Any name you like — only the extension matters, since it decides how the file is served back.

contentTypestringrequired

The image’s type. Any other is refused with 400 UNSUPPORTED_FILE_TYPE.

Available options:image/pngimage/jpegimage/webp

Response

uploadUrlstring

Where to send the file. The signature is in the URL, so that request needs no X-Api-Key.

methodstring

The method for that request: "PUT".

headersobject

Send exactly these headers with the file — Content-Type, and x-ms-blob-type when it is there. Read them from here rather than writing them in your code.

urlstring

The image’s address once uploaded: pass it as referenceImages.

expiresInnumber

Seconds until uploadUrl stops working (600). Upload as soon as you have it.

fileKeystring

The file’s key on our side. Not needed to create an image.

POST/images/presign
curl -X POST \
  https://api.sangtao.ai/v2/images/presign \
  -H "X-Api-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "fileName": "design.png",
    "contentType": "image/png"
  }'

# Then send the file to data.uploadUrl with data.method,
# adding every header in data.headers
{
  "success": true,
  "data": {
    "uploadUrl": "https://…/ref-uploads/…/745c53c6-….png?sv=…&sig=…",
    "method": "PUT",
    "headers": {
      "Content-Type": "image/png",
      "x-ms-blob-type": "BlockBlob"
    },
    "url": "https://cdn.sangtao.ai/ref-uploads/…/745c53c6-….png",
    "expiresIn": 600,
    "fileKey": "284c42a4-…/745c53c6-….png"
  },
  "error": null,
  "errorCode": null
}