迁移至Vertex AI gemini-2.5-pro-preview-06-05时API返回HTML而非JSON求助
关于Vertex AI新版Gemini模型全局端点返回HTML导致Node.js客户端报错的问题
我正尝试将Node.js应用从gemini-2.5-pro-preview-05-06迁移至Google Vertex AI的新版gemini-2.5-pro-preview-06-05模型(旧版本将于2025年6月19日停止服务)。根据文档要求,新版06-05模型需调用全局地域端点,但请求生成内容时,API返回完整HTML文档而非JSON对象,导致客户端库报错:
Error: 5 FAILED_PRECONDITION: An internal error occurred. Please retry or report in https://cloud.google.com/support
根本原因是客户端库预期接收JSON格式响应,实际却收到HTML。
可复现的极简Node.js脚本
const { VertexAI } = require('@google-cloud/vertexai'); // --- Configuration --- // 使用新模型和全局地域时失败 const PROJECT_ID = 'your-gcp-project-id'; const LOCATION = 'global'; const MODEL_NAME = 'gemini-2.5-pro-preview-06-05'; // 使用旧模型和区域地域时可正常运行 // const LOCATION = 'us-central1'; // const MODEL_NAME = 'gemini-2.5-pro-preview-05-06'; async function runTest() { console.log(`Initializing Vertex AI for project '${PROJECT_ID}' in location '${LOCATION}'...`); // 初始化Vertex AI客户端 const vertexAI = new VertexAI({ project: PROJECT_ID, location: LOCATION }); console.log(`Loading model '${MODEL_NAME}'...`); // 获取生成式模型 const model = vertexAI.getGenerativeModel({ model: MODEL_NAME, }); try { console.log("Sending request to the API..."); const request = { contents: [{ role: 'user', parts: [{ text: 'Why is the sky blue?' }] }], }; // 此处执行失败 const result = await model.generateContent(request); console.log("--- API Response (SUCCESS) ---"); console.log(JSON.stringify(result, null, 2)); } catch (error) { console.error("\n--- An Error Occurred ---"); console.error(`Error Type: ${error.name}`); console.error(`Error Message: ${error.message}`); // 底层错误为API返回HTML而非JSON } } runTest();
已完成的排查步骤
- 跨网络测试:本地机器和DigitalOcean云服务器运行代码均出现相同错误
- 全新项目测试:创建全新Google Cloud项目,启用Vertex AI API,使用拥有Vertex AI User权限的服务账号,问题依旧
- 基准验证:切换地域为
us-central1、模型为旧版gemini-2.5-pro-preview-05-06时,代码可正常运行
以上验证说明问题出在Google Cloud API端,而非代码、网络或项目配置。
求助问题
是否有其他开发者遇到过Node.js客户端库因gemini-2.5-pro-preview-06-05模型的全局端点返回HTML而失败的情况?是否有已知的解决方法、未公开的IAM权限或特定项目设置可修复此问题?
注:暂无Google Cloud支持计划权限。
内容的提问来源于stack exchange,提问作者Dror Bengal
相关产品推荐
相关产品推荐

