API video
Chọn mô hình để xem ví dụ tạo tác vụ, tra trạng thái và tải video.
Mô hình video
API video khác
Tạo video với Kling 4.0 Omni
Use a Token168 API key with access to kling-4.0. The path selects the model. Replace example media URLs with reachable HTTPS URLs or authorized asset:// references.
Tham số yêu cầu ↓POST /omni-video/kling-4.0curl -X POST https://www.token168.cc/omni-video/kling-4.0 \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"type": "prompt",
"text": "A white ceramic cup on a plain wooden table. Static camera, soft daylight."
}
],
"settings": {
"resolution": "720p",
"duration": 3,
"aspect_ratio": "16:9"
}
}'Tham số yêu cầu
| Trường | Giá trị hỗ trợ và cách hoạt động |
|---|---|
| contents[].type / text | Include one prompt item with text. Use @id to reference media or a voice by its unique ID. |
| contents[].type / url / id | Use first_frame, middle_frame, last_frame, refer_image, feature_video or base_video. Use a reachable URL and a unique id when referencing the item from the prompt. |
| contents[].voice_id | Use a supported preset voice_id and assign it a unique id. The subject library and element_id are unsupported. |
| settings.resolution | 720p or 1080p. Defaults to 1080p. 4k is not supported. |
| settings.dynamic_range | sdr. hdr is not supported. |
| settings.audio | native generates audio and is the default. original, which preserves input audio, is not supported. |
| settings.aspect_ratio | 21:9, 16:9, 9:16, 1:1 or adaptive. With a feature video and no edit video or keyframe, use a fixed ratio. 4:3 and 3:4 are not supported. |
| settings.duration | Số nguyên tùy chọn từ 3 đến 30 giây. Khi bỏ qua, mô hình dựa vào lời nhắc hoặc video base. Giá trị dự phòng là 10 giây. |
| options.watermark_info.enabled | Optional boolean. With true, check outputs[].watermark_url for an available watermarked copy. |
| options.callback_url / external_task_id | Not supported. Poll by the task ID returned after creation. |
| GET /tasks / POST /tasks | GET accepts task_ids with up to 20 IDs. external_task_ids and cursor listing via POST are not supported. |
| HTTP 400 / 501 | Unsupported create parameters or task query parameters return HTTP 400 with a message. Cursor-based listing returns HTTP 501. |
| Pricing | Prices depend on resolution and whether there is video input. Without video input, billable seconds equal output seconds. With video input, billable seconds equal max(total input seconds, output seconds) plus output seconds. See Pricing for rates. |
Set TASK_ID to data.id from the create response. Poll while status is submitted or processing. On succeeded, set VIDEO_URL to outputs[0].url and download it promptly. On failed, inspect the task message.
GET /tasks?task_ids=…curl --get "https://www.token168.cc/tasks" \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
--data-urlencode "task_ids=$TASK_ID"VIDEO_URL = outputs[0].url
outputs[0].urlcurl --fail "$VIDEO_URL" --output video.mp4Tải video có hình mờ
WATERMARK_URL = outputs[0].watermark_url
outputs[0].watermark_urlcurl --fail "$WATERMARK_URL" --output video-watermark.mp4Wan 3.0
Ví dụ văn bản thành video cho Bản chuẩn và Prime.
Ví dụ này tạo video không âm thanh dài 5 giây ở 480P và 16:9. Lưu id được trả về.
POST /v1/videoscurl -X POST https://www.token168.cc/v1/videos \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wan3.0-video",
"prompt": "A red toy boat floats gently on a calm blue pond, soft daylight, steady camera, no text, no people.",
"duration": 5,
"size": "480P",
"metadata": {
"input": {
"prompt": "A red toy boat floats gently on a calm blue pond, soft daylight, steady camera, no text, no people.",
"media": []
},
"parameters": {
"ratio": "16:9",
"audio": false
}
}
}'Tham số yêu cầu
| Trường | Giá trị hỗ trợ và cách hoạt động |
|---|---|
| model | wan3.0-video / wan3.0-video-prime |
| prompt / metadata.input.prompt | Provide a prompt or media. When both prompt locations are set, metadata.input.prompt takes precedence. The model counts each character and truncates after 20,000. |
| metadata.input.media[] | Each item takes type and url. Omit the array for text-only requests. first_frame and last_frame allow one each; last_frame requires first_frame. Up to 10 reference_image, 5 reference_video, and 5 reference_audio entries. file and link each allow one, and cannot be combined. Frame inputs cannot be combined with references. |
| metadata.input.media[].url | Supply a reachable URL or a supported data URI. Reference video and audio each require 1–15 s per asset and at most 15 s in total per type. Reference video requires at least 16 fps. |
| size / metadata.parameters.resolution | 480P, 720P, or 1080P. Default: 1080P. Top-level size is the resolution in the examples. When both are given, metadata.parameters.resolution takes precedence. |
| duration / metadata.parameters.duration | Integer 2–30 s, or -1 for smart duration. Default: 5 s. With video input, input and output together must fit within 30 s. Nested duration takes precedence. |
| metadata.parameters.ratio | adaptive (default), 16:9, 9:16, 1:1, 4:3, or 3:4. Use these values for Token168; 21:9 is unavailable on the current compatibility path. |
| metadata.parameters.audio | Boolean. Default: true. Pass false to generate without sound. |
| metadata.parameters.seed | Integer from -1 to 2147483647. The same seed may still produce different outputs. |
| metadata.parameters.prompt_extend | Boolean. Default: true. Keep true when using file or link inputs. |
| metadata.parameters.watermark | Boolean. Default: false. Set true to add a watermark to the Wan output. |
Thay video_task_123 bằng id trả về. Tiếp tục tra khi queued hoặc in_progress, tải khi completed. Nếu unknown, hãy kiểm tra tác vụ gốc.
GET /v1/videos/{task_id}curl https://www.token168.cc/v1/videos/video_task_123 \
-H "Authorization: Bearer $TOKEN168_API_KEY"Khi tác vụ hoàn tất, thay video_task_123 bằng id của tác vụ để lưu MP4.
GET /v1/videos/{task_id}/contentcurl https://www.token168.cc/v1/videos/video_task_123/content \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
--output video.mp4API video khác
Video Seedance từ văn bản
Để tạo từ văn bản, chỉ giữ mục text trong content. Tham số tạo nằm ở cấp cao nhất, không thêm bí danh ảnh hay lớp bọc metadata.
curl https://www.token168.cc/api/v3/contents/generations/tasks \
-H "Authorization: Bearer $TOKEN168_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "dreamina-seedance-2-0-260128",
"content": [
{"type": "text", "text": "A futuristic tech city, but with a strange, surreal quality. People are more open and free, focused on developing themselves. The city blends pristine natural ecosystems with modern technology. Residential areas are highly ecological, green development is advanced, all power comes from green electricity, and controlled nuclear fusion, space elevators, and extremely deep underground spaces have already been achieved."}
],
"duration": 4,
"resolution": "480p",
"ratio": "16:9",
"generate_audio": false,
"watermark": false
}'
Đồng bộ khẩu hình MediaKit
Gửi video_url và audio_url dưới dạng URL HTTPS hoặc ID asset://. Không gửi model: khả năng nội bộ byteplus-lip-sync áp dụng quyền khóa API, chọn kênh và giá theo giây. enable_video_loop mặc định là false và giữ nguyên giá trị false được chỉ định.
Đầu vào phải truy cập được trong toàn bộ thời gian chờ và xử lý. URL có chữ ký đã hết hạn hoặc không đủ thời hạn bị từ chối trước khi gửi. Mỗi đầu vào tối đa 64 MiB và 1800 giây. Video là MP4 H.264 không HDR, chỉ có một người; âm thanh hỗ trợ MP3, AAC, WAV, M4A, FLAC. Kiểm tra luồng không xác minh số khuôn mặt hay chất lượng khẩu hình.
Đo thời lượng trước khi tạm giữ hạn mức. loop=false lấy đầu vào ngắn hơn; true lấy thời lượng âm thanh. Khi thành công, quyết toán một lần theo result.duration và giá tại lúc tạo. Thất bại được xác nhận sẽ hoàn lại khoản giữ. Với unknown, truy vấn tác vụ gốc và không gửi lại.
Truy vấn bằng task_id Token168 đã trả về. Trạng thái: running, completed, failed hoặc unknown. Sau completed, result.video_url là liên kết tải được cấp quyền tạm thời, không chia sẻ công khai. Điểm tải không có tham số cấp quyền vẫn cần khóa API. Liên kết nhà cung cấp hết hạn sau 24 giờ, hãy tải sớm. Không cam kết lưu trữ vĩnh viễn hay gia hạn mọi URL bên ngoài.
curl -X POST https://www.token168.cc/api/v1/tools/lip-sync \
-H 'Authorization: Bearer <TOKEN168_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{"video_url":"asset://<VIDEO_ID>","audio_url":"asset://<AUDIO_ID>","enable_video_loop":false}'
curl https://www.token168.cc/api/v1/tasks/<TASK_ID> \
-H 'Authorization: Bearer <TOKEN168_API_KEY>'
curl https://www.token168.cc/v1/tasks/<TASK_ID>/artifacts/video/content \
-H 'Authorization: Bearer <TOKEN168_API_KEY>' -o lip-sync.mp4
Đường dẫn tương thích cũ
Tích hợp hiện có có thể tiếp tục dùng tuyến tương thích đã cấu hình theo giao thức từng mô hình. Tích hợp Seedance mới dùng ví dụ gốc phía trên. Các tuyến này không bảo đảm mọi mô hình hỗ trợ cùng bí danh ảnh.
| Đường dẫn | Trạng thái | Ghi chú |
|---|---|---|
| /v1/videos | Đang hoạt động | Tuyến tạo tương thích; tuân theo giao thức mô hình đã chọn. |
| /v1/videos/{task_id} | Đang hoạt động | Tuyến truy vấn trạng thái tương thích. |
| /v1/videos/{task_id}/content | Đang hoạt động | Đường dẫn proxy nội dung. |
| /v1/video/generations | Đang hoạt động | Đường dẫn tạo kiểu cũ. |
| /v1/video/generations/{task_id} | Đang hoạt động | Đường dẫn trạng thái kiểu cũ. |