trying to do a call with the following code and always I get back the same response
$PROJECT_ID = "test123";
$LOCATION = "us-central1";
//$MODEL = "gemini-1.5-pro-preview-0409";
$MODEL = "claude-3-haiku@20240307";
$formattedEndpoint = PredictionServiceClient::projectLocationPublisherModelName($PROJECT_ID, $LOCATION, 'anthropic', $MODEL);
Log::info($formattedEndpoint);
$predictionServiceClient = new PredictionServiceClient([
'apiEndpoint' => $LOCATION.'-aiplatform.googleapis.com',
]);
$payload = [
"anthropic_version" => "vertex-2023-10-16",
"messages" => [["role" => "user", "content" => "Send me a recipe for banana bread."]],
"max_tokens" => 1000,
"stream" => false,
//"temperature" => floatval(env('CLAUDE_TEMPERATURE')),
];
$httpBody = new HttpBody();
$httpBody->setContentType('application/json; charset=utf-8');
$httpBody->setData(json_encode($payload));
$request = (new RawPredictRequest)
->setEndpoint($formattedEndpoint)
->setHttpBody($httpBody);
$response = $predictionServiceClient->rawPredict($request);
I also tried creating a new Struct()
with the entire payload there but I always get the same validation error:
{
"message": "messages: Field required",
"code": 400,
"status": "UNRECOGNIZED_STATUS",
"details": []
}
Tried all kind of ways to send that messages
parameter but always same result. I must be missing something simple here.