Use Google's Gemini AI in Laravel

Start using Google’s Gemini AI APIs in your Laravel application with the Gemini PHP package. This package for Laravel built around the Gemini PHP Client, providing a Facade to interact with the API and AI models available:

use Gemini\Laravel\Facades\Gemini;

$result = Gemini::geminiPro()->generateContent('Hello');

$result->text(); // Hello! How can I assist you today?

The Gemini AI also can work with both text, image, and video simultaneously via the Gemini Pro Vision model. Given the following picture from this project’s readme, we can ask questions about the picture, like "What is this picture?"

Feeding the above image to the Gemini Pro Vision API is easy with this package, using the following code:

$result = Gemini::geminiProVision()
  'What is this picture?',
  new Blob(
   mimeType: MimeType::IMAGE_JPEG,
   data: base64_encode(
The picture shows a table with a white tablecloth. On the table are two cups
of coffee, a bowl of blueberries, a silver spoon, and some flowers. There are
also some blueberry scones on the table.

This package also provides conveniences around streaming partial responses, testing fakes, and more. You can get started with this package on GitHub at google-gemini-php/laravel. Also, the official Gemini Docs and API Reference for Developers and are excellent references.

The post Use Google's Gemini AI in Laravel appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

Read more

© 2024 Extly, CB - All rights reserved.