PixAI Platform
API v2 DocumentationMedia

Get an upload URL for an image

Step 1 of uploading an image you want to use as an input, for example a contextImages entry, a video frame or an inpaint base image.

  1. Call this endpoint to get uploadUrl and externalId.
  2. Send the raw image bytes to uploadUrl with an HTTP PUT and the file's real Content-Type (for example image/png). Do not use a multipart form.
  3. Call POST /v2/media/image/register with the externalId. Its id is the media ID you pass to other endpoints.
POST
/media/image/upload-url

Authorization

bearerAuth
AuthorizationBearer <token>

In all requests that require authentication

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

# 1. Get an upload URLUPLOAD=$(curl -s -X POST https://api.pixai.art/v2/media/image/upload-url \  -H "Authorization: Bearer $PIXAI_API_KEY" \  -H "Content-Type: application/json" -d '{}')URL=$(echo "$UPLOAD" | jq -r .uploadUrl)EXTERNAL_ID=$(echo "$UPLOAD" | jq -r .externalId)# 2. Upload the bytescurl -X PUT "$URL" -H "Content-Type: image/png" --data-binary @input.png# 3. Register it and read the media IDcurl -s -X POST https://api.pixai.art/v2/media/image/register \  -H "Authorization: Bearer $PIXAI_API_KEY" \  -H "Content-Type: application/json" \  -d "{\"externalId\": \"$EXTERNAL_ID\"}" | jq -r .id
{
  "uploadUrl": "string",
  "externalId": "string"
}
{
  "code": "string",
  "status": 0,
  "message": "string",
  "data": {},
  "defined": true
}