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

初始化GemmaVertexAIModelGarden失败:端点名称无效排查求助

问题

按照Colab官方教程《Get started with Gemma and LangChain》部署Model Garden中的模型,填入获取到的项目ID、端点ID和位置参数后,运行代码触发InvalidArgument错误,提示端点名称无效。

运行代码

from langchain_google_vertexai import GemmaVertexAIModelGarden, GemmaChatVertexAIModelGarden

llm = GemmaVertexAIModelGarden(
    endpoint_id=endpoint_id,
    project=project,
    location=location,
)

output = llm.invoke("What is the meaning of life?")
print(output)

报错栈

_InactiveRpcError                         Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     75         try:
---> 76             return callable_(*args, **kwargs)
     77         except grpc.RpcError as exc:

11 frames
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.INVALID_ARGUMENT
    details = "Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy."
    debug_error_string = "UNKNOWN:Error received from peer ipv4:173.194.215.95:443 {created_time:"2024-08-02T15:38:59.269976555+00:00", grpc_status:3, grpc_message:"Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy."}"
>

The above exception was the direct cause of the following exception:

InvalidArgument                           Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     76             return callable_(*args, **kwargs)
     77         except grpc.RpcError as exc:
---> 78             raise exceptions.from_grpc_error(exc) from exc
     79 
     80     return error_remapped_callable

InvalidArgument: 400 Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy.

问题原因与解决方法

  • 核心原因:传入的endpoint_id参数错误,你用了模型的部署名称google_gemma-1_1-2b-it-mg-one-click-deploy,但Vertex AI要求端点ID是一串纯数字的标识符,而非模型名称。
  • 解决步骤:
    1. 打开Google Cloud控制台,进入Vertex AI -> 端点页面
    2. 找到你部署的Gemma模型对应的端点,复制其纯数字格式的端点ID
    3. 将代码中的endpoint_id参数替换为这串数字ID
    4. 重新运行代码验证

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 02:55:08