You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Google Cloud项目调用Vertex AI Gemini 1.5 Pro模型持续返回404 Not Found错误求助

Google Cloud项目调用Vertex AI Gemini 1.5 Pro模型持续返回404 Not Found错误求助

大家好,我最近在Google Cloud项目里遇到了一个棘手的问题:调用Vertex AI API的gemini-1.5-pro-preview-0409模型时,持续收到404 Not Found错误,已经做了大量排查但问题依然存在,想请教下有没有社区朋友遇到过类似情况,或者能给我一些排查方向?

问题概述

无论我怎么调整代码配置,甚至用完全隔离的最小化测试项目,调用Vertex AI的Gemini 1.5 Pro模型都会返回404错误。我尝试过强制指定模型支持的us-central1区域,但还是没能解决问题,而且最小化测试已经排除了主应用逻辑(比如音频处理)的影响。

错误详情

  • 错误信息:[VertexAI.ClientError]: got status: 404 Not Found
  • 项目ID:feeltone-ai-backend
  • 使用的服务账号:<project_id>-compute@developer.gserviceaccount.com
  • 函数部署区域:me-west1
  • 示例错误时间:2025-08-21T10:50:22Z

已完成的排查步骤

我已经逐一检查了常规配置项,包括:

  • 修改测试函数代码,强制指定us-central1区域发起API调用
  • 确认项目中Vertex AI API已启用,甚至尝试过禁用后重新启用
  • 确认服务账号已被授予Vertex AI User的IAM角色
  • 确认项目关联的账单账号状态正常,没有欠费或异常
  • 用完全隔离的最小化测试函数复现了错误,证明问题和主应用的业务逻辑(比如ffmpeg音频处理)无关

复现方式(最小化测试项目)

只需要以下两个文件和部署命令,就能100%复现这个404错误,进一步排除了其他应用逻辑的干扰:

package.json

{
  "name": "vertex-ai-404-test",
  "version": "1.0.0",
  "main": "index.js",
  "dependencies": {
    "@google-cloud/vertexai": "^1.0.0"
  }
}

index.js

const { VertexAI } = require('@google-cloud/vertexai');

exports.testVertex = async (req, res) => {
  try {
    console.log('Starting Vertex AI test with full model name...');
    const PROJECT_ID = 'feeltone-ai-backend';
    const LOCATION = 'us-central1';
    console.log(`Initializing client for Project: ${PROJECT_ID}, Location: ${LOCATION}`);
    
    const vertex_ai = new VertexAI({ project: PROJECT_ID, location: LOCATION });
    const generativeModel = vertex_ai.preview.getGenerativeModel({
      model: 'gemini-1.5-pro-002',
    });
    
    console.log('Sending test prompt to Gemini...');
    const result = await generativeModel.generateContent({
      contents: [{ role: 'user', parts: [{ text: 'Hello, world!' }] }],
    });
    
    const responseText = result.response.candidates[0].content.parts[0].text;
    console.log('Gemini responded successfully:', responseText);
    res.status(200).send(`Success! Gemini response: ${responseText}`);
  } catch (error) {
    console.error('VERTEX TEST FAILED:', error);
    res.status(500).send(`Error in test: ${error.message}`);
  }
};

部署命令

gcloud functions deploy testVertex --runtime nodejs18 --trigger-http --allow-unauthenticated --source . --entry-point testVertex --region me-west1

我的猜测

目前所有常规配置看起来都没有问题,我怀疑可能是项目内部的资源预配或者隐性配置出现了异常。有没有朋友遇到过类似的项目级别的Vertex AI配置问题?或者我还能做哪些进一步的排查?

内容来源于stack exchange

火山引擎 最新活动