PixAI Platform
API DocumentationMedia

Upload an image or video

Upload an image or video and receive a media ID that identifies the stored file.

POST
/media/upload

Authorization

bearerAuth
AuthorizationBearer <token>

In all requests that require authentication, please add the following to the HTTP header:

In: header

The raw bytes of the file. This endpoint does not accept multipart/form-data.

Two headers are required:

  • Content-Type — the MIME type of the file, for example image/png or video/mp4. The server accepts image/* and video/* types only.
  • Content-Length — the exact byte length of the body. The request fails when the body length is different from this value.

TypeScript Definitions

Use the request body type in TypeScript.

body*file
Formatbinary

Response Body

application/json

application/json

application/json

curl -X POST https://api.pixai.art/v1/media/upload \  -H "Authorization: Bearer $PIXAI_API_KEY" \  -H "Content-Type: image/png" \  --data-binary @reference.png
{
  "id": "string",
  "type": "IMAGE",
  "urls": [
    {
      "variant": "PUBLIC",
      "url": "string"
    }
  ],
  "width": 0,
  "height": 0,
  "imageType": "string",
  "fileUrl": "string",
  "duration": 0,
  "thumbnailUrl": "string",
  "hlsUrl": "string",
  "size": 0
}
{
  "code": 0,
  "message": "string"
}
{
  "code": 0,
  "message": "string"
}