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.
- Call this endpoint to get
uploadUrlandexternalId. - Send the raw image bytes to
uploadUrlwith an HTTPPUTand the file's realContent-Type(for exampleimage/png). Do not use a multipart form. - Call
POST /v2/media/image/registerwith theexternalId. Itsidis the media ID you pass to other endpoints.
Authorization
bearerAuth 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
}Get an upload URL for an audio file POST
Step 1 of uploading an audio clip for `referenceAudioMediaIds` of `POST /v2/reference-video/create`. The flow is the same as for images: `PUT` the bytes to `uploadUrl` with the file's `Content-Type` (`audio/mpeg` or `audio/wav`), then call `POST /v2/media/audio/register`.
Inspect a video or audio file GET
Returns the duration, size, containers and codecs of a video or audio media item, so you can check a reference file against the model's limits before creating a reference video task.