创建视频或 GIF 人脸检测任务
curl --request POST \
--url https://api.crun.ai/api/v1/client/job/detect-face-video \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"video_url": "https://example.com/face-video.mp4"
}
'import requests
url = "https://api.crun.ai/api/v1/client/job/detect-face-video"
payload = { "video_url": "https://example.com/face-video.mp4" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({video_url: 'https://example.com/face-video.mp4'})
};
fetch('https://api.crun.ai/api/v1/client/job/detect-face-video', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.crun.ai/api/v1/client/job/detect-face-video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'video_url' => 'https://example.com/face-video.mp4'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.crun.ai/api/v1/client/job/detect-face-video"
payload := strings.NewReader("{\n \"video_url\": \"https://example.com/face-video.mp4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.crun.ai/api/v1/client/job/detect-face-video")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"video_url\": \"https://example.com/face-video.mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.crun.ai/api/v1/client/job/detect-face-video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"video_url\": \"https://example.com/face-video.mp4\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "success",
"data": {
"detect_task_id": "dit60yt8reqplt1c16"
}
}{
"code": 422,
"message": "Missing Params or Type Error",
"errors": [
"具体字段错误信息"
]
}人脸交换
检测人脸(视频和 GIF)
创建视频或 GIF 人脸检测任务,用于多人换脸。
POST
/
api
/
v1
/
client
/
job
/
detect-face-video
创建视频或 GIF 人脸检测任务
curl --request POST \
--url https://api.crun.ai/api/v1/client/job/detect-face-video \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"video_url": "https://example.com/face-video.mp4"
}
'import requests
url = "https://api.crun.ai/api/v1/client/job/detect-face-video"
payload = { "video_url": "https://example.com/face-video.mp4" }
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({video_url: 'https://example.com/face-video.mp4'})
};
fetch('https://api.crun.ai/api/v1/client/job/detect-face-video', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.crun.ai/api/v1/client/job/detect-face-video",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'video_url' => 'https://example.com/face-video.mp4'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.crun.ai/api/v1/client/job/detect-face-video"
payload := strings.NewReader("{\n \"video_url\": \"https://example.com/face-video.mp4\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.crun.ai/api/v1/client/job/detect-face-video")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"video_url\": \"https://example.com/face-video.mp4\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.crun.ai/api/v1/client/job/detect-face-video")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"video_url\": \"https://example.com/face-video.mp4\"\n}"
response = http.request(request)
puts response.read_body{
"code": 200,
"message": "success",
"data": {
"detect_task_id": "dit60yt8reqplt1c16"
}
}{
"code": 422,
"message": "Missing Params or Type Error",
"errors": [
"具体字段错误信息"
]
}概述
多人换脸前,先调用此接口创建视频或 GIF 人脸检测任务。接口会返回detect_task_id,你需要再调用人脸检测结果接口查询状态,并在成功后获取 detect_id 与人脸列表。
接口地址
POST https://api.crun.ai/api/v1/client/job/detect-face-video
请求参数
需要检测人脸的视频或 GIF URL。
请求示例
curl -X POST "https://api.crun.ai/api/v1/client/job/detect-face-video" \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d "{\"video_url\":\"https://example.com/face-video.mp4\"}"
import requests
url = "https://api.crun.ai/api/v1/client/job/detect-face-video"
headers = {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY",
}
payload = {
"video_url": "https://example.com/face-video.mp4",
}
response = requests.post(url, json=payload, headers=headers, timeout=30)
print(response.json())
const url = "https://api.crun.ai/api/v1/client/job/detect-face-video";
const payload = {
video_url: "https://example.com/face-video.mp4",
};
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "YOUR_API_KEY",
},
body: JSON.stringify(payload),
});
console.log(await response.json());
响应示例
{
"code": 200,
"message": "success",
"data": {
"detect_task_id": "dit60yt8reqplt1c16"
}
}
下一步
查询人脸检测结果
查询检测任务状态,获取多人换脸需要的 detect_id 和 faces 列表
相关资源
视频多人换脸
使用
detect_id 和 faces 替换视频中的指定人脸GIF 多人换脸
使用与视频相同的请求结构替换 GIF 中的指定人脸
授权
所有 API 都需要通过 API Key 认证。
获取 API Key:
- 访问 API Key 管理页面 获取你的 API Key
使用方式: 添加到请求头:
x-api-key: YOUR_API_KEY
注意:
- 请妥善保管你的 API Key,不要分享给他人
- 如果怀疑 API Key 已泄露,请立即在管理页面重置
请求体
application/json
需要检测人脸的视频或 GIF URL。
示例:
"https://example.com/face-video.mp4"
响应
请求成功
响应状态码
- 200:成功 - 请求已成功处理
- 401:未授权 - 认证凭据缺失或无效
- 402:余额不足 - 账户积分不足,无法执行操作
- 404:未找到 - 请求的资源或接口不存在
- 422:验证错误 - 请求参数未通过校验
- 429:请求过多 - 已超过该资源的请求限制
- 455:服务不可用 - 系统正在维护
- 500:服务器错误 - 处理请求时发生意外错误
- 501:生成失败 - 内容生成任务失败
- 505:功能已禁用 - 请求的功能当前不可用
可用选项:
200, 401, 402, 404, 422, 429, 455, 500, 501, 505 响应消息,失败时为错误描述
示例:
"success"
Show child attributes
Show child attributes
此页面对您有帮助吗?
⌘I
