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

调用batchEmbedContents时models/embeddings-001遇GoogleGenerativeAIError 404问题

解决GoogleGenerativeAIEmbeddings指定models/embeddings-001时的GoogleGenerativeAIError错误

错误原因

代码中使用GoogleGenerativeAIEmbeddings(model="models/embeddings-001")指定的模型在API v1beta版本中不存在,或该模型不支持batchEmbedContents方法,导致抛出GoogleGenerativeAIError。

解决步骤

  • 调用Google Gemini API的ListModels接口,获取当前API版本下可用的所有模型列表,筛选出支持嵌入功能且兼容batchEmbedContents方法的模型。
  • 修改代码中的模型ID,将models/embeddings-001替换为ListModels返回的有效嵌入模型ID(例如当前常用的models/text-embedding-004,具体以实际查询结果为准)。
  • 确认使用的API版本兼容性,若v1beta版本不支持目标模型,可尝试升级至稳定版v1(如果官方提供)。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 05:19:50