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

调用Google Vertex API含retrieval工具时触发400错误求助

Gemini-1.0-Pro-001调用添加Retrieval工具触发400无效参数错误

在调用Gemini-1.0-Pro-001的generateContent接口时,请求负载中包含retrieval工具就会返回400错误,移除该工具后请求可正常执行。

请求端点

https://us-central1-aiplatform.googleapis.com/v1/projects/<project_id>/locations/us-central1/publishers/google/models/gemini-1.0-pro-001:generateContent

正常工作的请求负载

{
  "contents": [{
    "role": "user",
    "parts": [{
      "text": "<prompt>"
    }]
  }],
  "model": "projects/<project_id>/locations/us/publishers/google/models/gemini-1.0-pro-001"
}

触发错误的请求负载

在上述负载中添加tools字段后触发400错误:

{
  "contents": [{
    "role": "user",
    "parts": [{
      "text": "<prompt>"
    }]
  }],
  "model": "projects/<project_id>/locations/us/publishers/google/models/gemini-1.0-pro-001",
  "tools": [{
    "retrieval": {
      "vertexAiSearch": {
        "datastore": "projects/<project_id>/locations/us/collections/default_collection/dataStores/<datastore_id>"
      }
    }
  }]
}

错误信息

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT"
  }
}

已完成的排查操作

  • 确认搜索应用与Cloud Storage存储桶位置一致
  • 验证相关权限配置充足
  • 激活Enterprise版本
  • 创建关联Cloud Storage的搜索应用
  • 日志确认存储桶已完成索引,通过Workbench可正常查询测试文档
  • 调整资源位置设置后问题仍存在
  • 确认Agent与Cloud Storage连接状态正常
  • 全程使用gemini-1.0-pro-001模型

资源位置层级

  1. Endpoint:URL区域为us-central1
  2. Project:无位置,作为资源容器
  3. 搜索应用:选择us区域
  4. 数据存储(Data stores):关联Cloud Storage存储桶
  5. Cloud Storage存储桶:选择us区域

目前已无明确排查方向,寻求解决思路。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 23:41:06