0) { $predictions = []; foreach ($rawResponse['predictions'] as $prediction) { $predictions[] = new ImageGenerationPrediction($prediction['bytesBase64Encoded'], $prediction['mimeType']); } $this->predictions = $predictions; $this->error = null; } if (isset($rawResponse['error'])) { $error = $rawResponse['error']; $this->error = new APIError($error['message'], $error['code']); } if (!isset($this->predictions) && !isset($this->error)) { $this->error = new APIError('An unknown error occurred.', 0,); } } }