Upload image, video or audio file

December 6, 2024

Table of contents

  1. Request Headers
  2. Query Parameters
  3. Responses
  4. Model
  5. Examples
  6. Try It

Upload an image, video, or audio file up to 5GB in size. Files uploaded to one PixVerse.ai account can be accessed from any other PixVerse.ai account just by referencing the id (image) or path (video/audio) so keep that in mind.

POST raw content using Make.com and similar nocode tools.

https://api.useapi.net/v2/pixverse/files/?…

Request Headers
Authorization: Bearer {API token}
Content-Type: select from the table below
  • API token is required, see Setup useapi.net for details.
  • Content-Type is required, select from the table below:
Content-Type File Extension
image/png png
image/jpeg jpeg
image/gif gif
image/webp webp
video/mp4 mp4
video/quicktime mov
video/3gpp 3gp
video/x-matroska mkv
video/x-flv flv
video/mpeg mpeg
video/MP2T ts
video/x-msvideo avi
video/x-motion-jpeg mjpeg
video/webm webm
video/ogg ogv
audio/wav wav
audio/wave wav
audio/mpeg mp3

NOTE We took a guess on supported video and audio types and only tested the most popular ones.

Query Parameters
  • email is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.
Responses
  • 200 OK

    The image upload response contains a id that you can use to reference the uploaded image file:

    {
        "result": [
            {
                "id": 123456,
                "url": "<file url>",
                "path": "<file path>",
                "size": 112233,
                "name": "<file name>",
                "category": 0,
                "err_msg": ""
            }
        ]
    }
    

    The video/audio upload response contains a path that you can use to reference the uploaded video/audio file:

    {
        "path": "<file path>",
        "url": "<file url>"
    }
    
  • 400 Bad Request

    {
        "error": "<Error message>",
        "code": 400
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized",
      "code": 401
    }
    
Model
{ // TypeScript, all fields are optional
    url: string
    path: string
    result: {
        id: number
        url: string
        path: string
        size: number
        name: string
        category: number
        err_msg: string
    }[]
}
Examples
  • curl "https://api.useapi.net/v2/pixverse/files/?email=email" \
      -H "Authorization: Bearer …" \
      -H "Content-Type: image/jpeg" \
      --data-binary /path/to/your/image.jpeg
    
  • const token = "API token";
    const email = "Previously configured account email"; 
    const apiUrl = `https://api.useapi.net/v2/pixverse/files/?email=${email}`; 
    let blob;
    /*
        // Example 1: Fetch image from URL
        const imageUrl = "https://upload.wikimedia.org/wikipedia/commons/7/7d/Mona_Lisa_color_restoration.jpg";
        const responseImage = await fetch(imageUrl);
        blob = await responseImage.blob();
    */
    /* 
        // Example 2: Load image from local file (Blob)
        const fsp = require('fs').promises;
        const imageFileName = "./cat.png";
        blob = new Blob([await fsp.readFile(imageFileName)]);
    */
    /*
        // Example 3: Load from input file html element
        // <input id="image-file" type="file"> 
        const imageFile = document.getElementById(`image-file`);
        if (imageFile.files[0])
            blob = imageFile.files[0]);
    */
    const response = await fetch(apiUrl, {
      method: "POST"
      headers: {
        "Authorization": `Bearer ${token}`,
      },
      body: blob
    });
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    token = "API token"
    email = "Previously configured account email"
    apiUrl = f"https://api.useapi.net/v2/pixverse/files/?email={email}"
    headers = {
        'Authorization': f'Bearer {token}',
        'Content-Type': 'image/jpeg'
    }
    
    # # Example 1: Fetch image from URL
    # image_url = "https://upload.wikimedia.org/wikipedia/commons/7/7d/Mona_Lisa_color_restoration.jpg"
    # response_image = requests.get(image_url)
    # file_content = response_image.content
    
    # # Example 2: Load image from local file
    # image_file_path = "./image.jpg"
    # with open(image_file_path, 'rb') as image_file:
    #     file_content = image_file.read()
    
    response = requests.post(api_url, headers=headers, data=file_content)
    print(response, response.json())
    
Try It