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

LangChain中Google ChatVertexAI模型地域设置无效,求正确配置方法

解决LangChain中ChatVertexAI地域设置不生效的问题
  • 直接在ChatVertexAI构造参数顶层设置location参数不会生效,正确的方式是将地域配置嵌套在clientOptions中传递。
  • 修正后的可用代码:
import { ChatVertexAI } from "@langchain/google-vertexai";

const model = new ChatVertexAI({
  model: 'gemini-1.0-pro',
  temperature: 0.01,
  clientOptions: {
    location: 'northamerica-northeast1'
  }
});
  • 另一种可选方式:通过apiEndpoint直接指定对应地域的API端点(适用于新版包):
import { ChatVertexAI } from "@langchain/google-vertexai";

const model = new ChatVertexAI({
  model: 'gemini-1.0-pro',
  temperature: 0.01,
  apiEndpoint: 'northamerica-northeast1-aiplatform.googleapis.com'
});

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.25 10:56:12