首页 开发文档 智能量体

智能量体

上传人体照片估算身材数据,返回体型分类、BMI、推荐尺码、三围估算与穿衣建议。正面照必传,背面/侧面照与身高体重年龄性别选填,信息越全精度越高。上游处理较慢时,同步请求超过等待秒数会自动转为异步返回 task_id,可凭 task_id 调用任务查询接口获取最终结果,失败自动退款。

请求信息
请求地址 https://www.cx4.cn/openApi/ai/body_measure 复制
请求方式 GET / POST
接口标识 body_measure
鉴权方式 必须
四种方式任选其一:Header「X-Api-Key」/ Header「Authorization: Bearer 你的key」/ URL 参数「?key=你的key」/ POST 参数「key」
请求参数
参数名 类型 必填 说明 示例
image_front string 是 正面照,公网 URL 或 base64(必传) https://example.com/front.jpg
image_back string 否 背面照,可提高估算精度 https://example.com/back.jpg
image_side string 否 侧面照,可提高估算精度 https://example.com/side.jpg
height int 否 身高(厘米),选填 170
weight float 否 体重(公斤),选填 65
gender string 否 性别 male/female,选填 male
age int 否 年龄,选填 28
async int 否 是否异步:0 同步直接返回(默认);1 异步提交返回 task_id,结果走回调或任务查询 0
callback_url string 否 异步回调地址(仅 async=1 生效),公网 http(s);有结果时 POST,HMAC-SHA256 签名 https://example.com/cb
返回参数

下表字段位于返回结构的 data 内;外层 code / message 为全平台统一格式,不在此重复列出。

参数名 类型 说明 示例
body_type string 体型分类:如 匀称/偏瘦/偏壮/苹果型/梨型 匀称
size string 推荐服装尺码:S/M/L/XL/XXL(含国际码标注) M (170/92A)
bust string 胸围估算(cm) 92.5
waist string 腰围估算(cm) 76.0
hip string 臀围估算(cm) 95.0
bmi float BMI 指数(未传身高体重时按照片估算) 22.5
advice string 穿衣建议与版型推荐 适合修身版型,避免过于宽松的上衣
confidence float 估算置信度 0-1 0.85
task_id string 同步请求超过系统配置的等待秒数仍未完成时自动转为异步,返回任务 ID;凭此调用「任务查询」接口获取结果 20261120a1b2c3d4e5
status string 仅转为异步时返回,任务状态 pending(同步完成时本字段不出现,直接返回业务结果) pending
返回示例

成功

{
    "code": 200,
    "message": "操作成功",
    "data": {
        "body_type": "匀称",
        "size": "M (170/92A)",
        "bust": "92.5",
        "waist": "76.0",
        "hip": "95.0",
        "bmi": 22.5,
        "advice": "适合修身版型",
        "confidence": 0.85
    }
}

失败

{
    "code": 500,
    "message": "智能识别失败",
    "data": null
}
平台通用状态码
状态码 说明
200调用成功
400缺少必填参数或参数格式有误
401密钥缺失或无效
402余额不足,请充值后重试
403未开通该接口,请在本页开通后调用
404接口不存在或已下架
429触发限流,请稍后重试
500接口调用失败(已扣款的会自动退款)
调用示例

cURL 复制

curl -X POST "https://www.cx4.cn/openApi/ai/body_measure" -H "X-Api-Key: 你的SecretKey" -d "image_front=https://example.com/front.jpg&image_back=https://example.com/back.jpg&image_side=https://example.com/side.jpg&height=170&weight=65&gender=male&age=28&async=0&callback_url=https://example.com/cb"

JavaScript 复制

fetch('https://www.cx4.cn/openApi/ai/body_measure', {
  method: 'POST',
  headers: {
    'X-Api-Key': '你的SecretKey',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: 'image_front=https://example.com/front.jpg&image_back=https://example.com/back.jpg&image_side=https://example.com/side.jpg&height=170&weight=65&gender=male&age=28&async=0&callback_url=https://example.com/cb'
})
.then(res => res.json())
.then(data => console.log(data));

PHP 复制

<?php
require 'vendor/autoload.php';

$client = new \GuzzleHttp\Client();
$response = $client->post('https://www.cx4.cn/openApi/ai/body_measure', [
    'headers' => ['X-Api-Key' => '你的SecretKey'],
    'form_params' => ['image_front' => 'https://example.com/front.jpg', 'image_back' => 'https://example.com/back.jpg', 'image_side' => 'https://example.com/side.jpg', 'height' => '170', 'weight' => '65', 'gender' => 'male', 'age' => '28', 'async' => '0', 'callback_url' => 'https://example.com/cb'],
]);
echo $response->getBody();

Java 复制

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://www.cx4.cn/openApi/ai/body_measure"))
    .header("X-Api-Key", "你的SecretKey")
    .header("Content-Type", "application/x-www-form-urlencoded")
    .POST(HttpRequest.BodyPublishers.ofString("image_front=https://example.com/front.jpg&image_back=https://example.com/back.jpg&image_side=https://example.com/side.jpg&height=170&weight=65&gender=male&age=28&async=0&callback_url=https://example.com/cb"))
    .build();
HttpResponse<String> response = client.send(
        request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());

Python 复制

import requests

res = requests.post('https://www.cx4.cn/openApi/ai/body_measure',
    headers={'X-Api-Key': '你的SecretKey'},
    data={'image_front': 'https://example.com/front.jpg', 'image_back': 'https://example.com/back.jpg', 'image_side': 'https://example.com/side.jpg', 'height': '170', 'weight': '65', 'gender': 'male', 'age': '28', 'async': '0', 'callback_url': 'https://example.com/cb'})
print(res.json())
在线测试 (使用你的密钥真实调用,计费与正常调用一致)

登录后可在线测试: 立即登录

计费说明

¥0.5000

每次调用


每日免费额度:无

累计调用:3 次


快速上手

1. 注册并完成邮箱验证:立即注册

2. 登录后复制 Secret Key:去登录

3. 点击右侧「开通接口」按钮

4. 用下方「在线测试」一键体验,或复制下方示例代码直接调用