post https://upload.heygen.com/v1/asset
Response Body
Parameter | Description |
---|---|
id | id of uploaded asset |
name | name of uploaded asset |
file_type | file type of uploaded asset (image, video) |
folder_id | folder of this asset |
meta | metadata of this asset |
The response will provide you with an id
, representing the asset ID of the uploaded image.
Image
Specify the content type of the image, which should be image/jpeg
for JPEG files or image/png
for PNG files. The API will respond with an id that represens your asset.
File type | Content type |
---|---|
JPEG | image/jpeg |
PNG | image/png |
Video
Specify the content type of the video, which should be video/mp4
for MP4 files or video/webm
for WEBM files. The API will respond with an id that represents your asset.
File type | Content type |
---|---|
MP4 | video/mp4 |
WEBM | video/webm |
Audio
Specify the content type of the audio, which should be audio/mpeg
for MPEG files. The API will respond with an id that represents your asset.
File type | Content type |
---|---|
MPEG | audio/mpeg |
Example Usage
import requests
url = "https://upload.heygen.com/v1/asset"
headers = {
"Content-Type": "image/jpeg",
"X-Api-Key": "xxx",
}
# Path to the image file
file_path = "/Users/user/Documents/image.jpg"
# Open the file in binary mode and send it with a POST request
with open(file_path, "rb") as file:
response = requests.post(url, headers=headers, data=file)
print(response.status_code)
print(response.json())
200
{'code': 100, 'data': {'id': 'eeb5d93b927c4ea38bf2503b0db5d4d6', 'name': 'eeb5d93b927c4ea38bf2503b0db5d4d6', 'file_type': 'image', 'folder_id': '', 'meta': None, 'created_ts': 1722360649, 'url': 'https://resource2.heygen.ai/image/...'}, 'msg': None, 'message': None}