google-cloud-vertex-aigoogle-ai-platform

Why do I get a 404 for googleapis.com/v1/projects chat-bison@001:predict?


I'm using the example curl I get from:

https://console.cloud.google.com/vertex-ai/generative/language/my-prompts/create/text?authuser=2&project=my-app

curl

https://us-central1-aiplatform.googleapis.com/v1/projects/my-app/locations/us-central1/publishers/google/chat-bison@001:predict

but I get a 404 everytime. I have the right Bearer auth token. Everything seems to be correct but 404!


Solution

  • 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