Upload asset to Kling
April 18, 2025
Table of contents
This endpoint uploads an asset to your Kling account for later use in image and video generation.
https://api.useapi.net/v1/kling/assets/?…
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 | Max Size | Notes |
---|---|---|---|
image/png | png | 10MB | Minimum dimensions of 300px |
image/jpeg | jpg/jpeg | 10MB | Minimum dimensions of 300px |
video/mp4 | mp4 | 100MB | 720p/1080p resolution, 10s max |
video/quicktime | mov | 100MB | 720p/1080p resolution, 10s max |
audio/wav | wav | 20MB | 30 seconds max |
audio/wave | wav | 20MB | 30 seconds max |
audio/mpeg | mp3 | 20MB | 30 seconds max |
audio/mp4 | m4a | 20MB | 30 seconds max |
audio/flac | flac | 20MB | 30 seconds max |
audio/aac | aac | 20MB | 30 seconds max |
audio/ogg | ogg | 20MB | 30 seconds max |
Query Parameters
email
is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.
Responses
-
{ "status": 3, "url": "https://s21-kling.klingai.com/....jpg", "message": "" }
-
{ "error": "Content-Type {content-type} is not supported. Valid values: image/png,image/jpeg,video/mp4,video/quicktime,audio/wav,audio/wave,audio/mpeg,audio/mp4,audio/flac,audio/aac,audio/ogg" }
-
{ "error": "Unauthorized", "code": 401 }
Model
{ // TypeScript, all fields are optional
status: number // 3 = ok for image, 1 = ok for video
url: string // URL of the uploaded asset
message: string
}
Examples
-
curl "https://api.useapi.net/v1/kling/assets/[email protected]" \ -H "Authorization: Bearer …" \ -H "Content-Type: image/jpeg" \ --data-binary @/path/to/your/image.jpg
-
const token = "API token"; const email = "Previously configured account email"; const apiUrl = `https://api.useapi.net/v1/kling/assets/?email=${email}`; let blob; /* // Example 1: Fetch image from URL const imageUrl = "https://example.com/image.jpg"; const responseImage = await fetch(imageUrl); blob = await responseImage.blob(); */ /* // Example 2: Load image from local file (Node.js) const fsp = require('fs').promises; const imageFileName = "./image.jpg"; 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}`, "Content-Type": "image/jpeg" }, 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/v1/kling/assets/?email={email}" headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'image/jpeg' } # Example: 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(apiUrl, headers=headers, data=file_content) print(response, response.json())