英文:
Why do I get a 404 for googleapis.com/v1/projects chat-bison@001:predict?
问题
I'm using the example curl I get from:
但是每次都返回404错误。我有正确的Bearer授权令牌。似乎一切都正确,但为什么会出现404错误?
英文:
I'm using the example curl I get from:
but I get a 404 everytime. I have the right Bearer auth token. Everything seems to be correct but 404!
答案1
得分: 3
以下是已翻译的内容:
构建的URL显然不正确。
- 模型应该是
text-bison
(不带@001
) - URL "template" 应该是
https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict
(缺少了/models
)
总之:
API_ENDPOINT="us-central1-aiplatform.googleapis.com"
PROJECT_ID="<projectID>"
MODEL_ID="text-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": [
{
"content": "Write a short poem:"
}
],
"parameters": {
"temperature": 0.2,
"maxOutputTokens": 256,
"topP": 0.8,
"topK": 40
}
}'
来源:https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/api-quickstart
英文:
The built URL apparently is incorrect.
- The model is supposed to be
text-bison
(without the@001
) - The URL "template" is supposed to be
https://${API_ENDPOINT}/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict
(/models
was missing)
All in all:
API_ENDPOINT="us-central1-aiplatform.googleapis.com"
PROJECT_ID="<projectID>"
MODEL_ID="text-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": [
{
"content": "Write a short poem:"
}
],
"parameters": {
"temperature": 0.2,
"maxOutputTokens": 256,
"topP": 0.8,
"topK": 40
}
}'
Source: https://cloud.google.com/vertex-ai/docs/generative-ai/start/quickstarts/api-quickstart
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论