api网关配置文件来调用后台服务url

问题描述 投票:0回答:1

`我尝试从 API 网关调用 Vertex AI 端点,但在调用 API 网关 URL 时收到空响应。我有以下配置文件:

```
swagger: "2.0"

信息: 标题: 演示 版本:1.0.0 路径: /预测: 邮政: 摘要:使用 Vertex AI 进行预测 操作Id:predictWithVertexAI 描述:使用 Vertex AI 上托管的机器学习模型进行预测。 消耗: - 应用程序/json 产生: - 应用程序/json 参数: - 在:查询 名称:钥匙 描述:API密钥 必填:真实 类型:字符串 - 在:身体 名称:预测请求 描述:预测请求 必填:真实 架构: 类型:对象 特性: 实例: 类型:数组 项目: 类型:对象 特性: 字首: 类型:字符串 参数: 类型:对象 特性: 候选人数: 类型:整数 最大输出令牌数: 类型:整数 温度: 类型:数字 回应: “200”: 描述:成功预测响应 架构: 类型:对象 特性: 结果: 类型:字符串 安全性定义: api_key: 类型:apiKey 名称:钥匙 在:查询 x-谷歌后端: 地址:“https://us-central1-aiplatform.googleapis.com/v1/projects/resonant-feat-398408/locations/us-central1/publishers/google/models/text-bison@001:predict” # 替换为您的实际后端地址


    API_ENDPOINT="us-central1-aiplatform.googleapis.com"
PROJECT_ID="ID"
MODEL_ID="code-bison"

curl \
-X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict" -d \
$'{
    "instances": [
        {
            "prefix": "capital of Andhra Pradesh"
        }
    ],
    "parameters": {
        "candidateCount": 2,
        "maxOutputTokens": 1024,
        "temperature": 0.2
    }
}'


`


api swagger config gateway vertex
1个回答
0
投票

sry,代码没有正确粘贴,这是我的配置文件

swagger: "2.0"

信息: 标题: 演示 版本:1.0.0 路径: /预测: 邮政: 摘要:使用 Vertex AI 进行预测 操作Id:predictWithVertexAI 描述:使用 Vertex AI 上托管的机器学习模型进行预测。 消耗: - 应用程序/json 产生: - 应用程序/json 参数: - 在:查询 名称:钥匙 描述:API密钥 必填:真实 类型:字符串 - 在:身体 名称:预测请求 描述:预测请求 必填:真实 架构: 类型:对象 特性: 实例: 类型:数组 项目: 类型:对象 特性: 字首: 类型:字符串 参数: 类型:对象 特性: 候选人数: 类型:整数 最大输出令牌数: 类型:整数 温度: 类型:数字 回应: “200”: 描述:成功预测响应 架构: 类型:对象 特性: 结果: 类型:字符串 安全性定义: api_key: 类型:apiKey 名称:钥匙 在:查询 x-谷歌后端: 地址:“https://us-central1-aiplatform.googleapis.com/v1/projects/resonant-feat-398408/locations/us-central1/publishers/google/models/text-bison@001:predict” # 替换为您的实际后端地址

© www.soinside.com 2019 - 2024. All rights reserved.