I am implementing this curl request in golang for connecting to vertexi generative AI models.
I am using the token generated by this command for authentication gcloud auth print-access-token
.
But the token doesn't last for more than 1 hour.
API_ENDPOINT="**-****-aiplatform.googleapis.com"
PROJECT_ID="******"
MODEL_ID="text-bison@001"
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": ""
}
],
"parameters": {
"temperature": 0.2,
"maxOutputTokens": 256,
"topP": 0.8,
"topK": 40
}
}'