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

能否为Vertex AI Endpoint关联人类可读名称并用于预测请求?

用人类可读名称关联Vertex AI Endpoint并用于预测的可行方案

你可以通过以下几种方案实现用人类可读名称关联Endpoint并发起预测请求:

1. 自建映射表做请求转发

在你的应用服务层维护一个displayName到Endpoint完整URL的映射关系(可存在数据库、配置文件或缓存中)。当调用方传入displayName时,先从映射表中匹配到对应的官方Endpoint URL,再转发预测请求到Vertex AI接口。

示例伪代码:

# 缓存中的displayName与Endpoint URL映射
endpoint_map = {
    "product-review-sentiment": "https://us-central1-aiplatform.googleapis.com/v1/projects/my-gcp-project/locations/us-central1/endpoints/9876543210"
}

def handle_predict_request(display_name, payload):
    target_url = endpoint_map.get(display_name)
    if not target_url:
        return {"error": "不存在匹配的Endpoint"}
    # 发起预测请求
    response = requests.post(target_url, json=payload, headers={"Authorization": "Bearer YOUR_TOKEN"})
    return response.json()

2. 用中间服务自动查询映射

借助Cloud Functions或Cloud Run搭建轻量中间服务,接收带displayName的请求后,先调用Vertex AI的ListEndpoints接口,通过过滤displayName字段匹配到对应的Endpoint ID,再拼接成官方预测URL发起请求。为提升性能,建议对查询结果做短期缓存。

3. 自定义域名+Cloud Endpoints路由配置

配置自定义域名指向Cloud Endpoints,在Endpoints中定义路由规则,将包含displayName的请求路径(如/predict/{display_name})映射到对应的Vertex AI Endpoint。中间路由服务负责解析displayName并完成URL转换与请求转发。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 21:10:25