You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Google AutoML JS predict接口报Unsupported payload type `row`错误

报错根因

Unsupported payload type 'row' 报错由两个核心问题导致:

  1. 客户端库不匹配:Python代码使用的是Vertex AI平台的aiplatform客户端,对应JS端应该使用@google-cloud/aiplatform库,你当前使用的旧版@google-cloud/automl v1beta1客户端和Vertex AI预测接口的请求结构完全不兼容。
  2. Payload结构错误:Vertex AI预测接口不需要嵌套row.values字段,直接传入实例数组即可。
修复步骤
  • 第一步:替换依赖库
npm uninstall @google-cloud/automl
npm install @google-cloud/aiplatform
  • 第二步:调整请求代码结构
const {PredictionServiceClient} = require('@google-cloud/aiplatform').v1;

const ai = new PredictionServiceClient({
    projectId: projectId,
    // Vertex AI API端点为区域专属,需要替换为你部署模型的区域
    apiEndpoint: `${computeRegion}-aiplatform.googleapis.com`
});

// 直接复用你原有的data数组,不需要额外嵌套结构
const instances = data;

const request = {
    // 替换为你实际的Vertex AI端点ID,不要使用旧AutoML的model ID
    name: `projects/${projectId}/locations/${computeRegion}/endpoints/${ENDPOINT_ID}`,
    instances: instances,
    parameters: {feature_importance: true}
};

const [result] = await ai.predict(request);
额外排查验证点
  • 确认computeRegion参数和模型部署的区域完全一致,如us-central1、asia-east1
  • 确认表格类模型传入的每个实例字段名、字段类型和训练时的特征完全匹配,无缺失必填字段
  • 确认你使用的模型已经部署到Vertex AI端点,替换代码中的ENDPOINT_ID为实际端点ID

内容的提问来源于stack exchange,提问作者xfx

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 17:54:02