1 Answers1

3

The built URL apparently is incorrect.

  1. The model is supposed to be text-bison (without the @001)
  2. 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

fiws
  • 136
  • 1
  • 6
  • This is a summarization and classification model, not the chat model. Is there any clarifications on how to call chat model via REST API? – huksley May 16 '23 at 18:55
  • @huksley just use the model `chat-bison` as in: `"https://${endPoint}/v1/projects/${projectId}/locations/us-central1/publishers/google/models/chat-bison:predict"` – Johann May 18 '23 at 09:13