PHP code example of yunusasuroglu / laravel-gemini-ai
1. Go to this page and download the library: Download yunusasuroglu/laravel-gemini-ai library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yunusasuroglu / laravel-gemini-ai example snippets
$geminiService = new GeminiService();
$text = "The text to be sent to the API will come here";
$apiKey = env('GEMINI_API_KEY');
try {
$result = $geminiService->create($text, $apiKey);
echo $result['text']; // Prints the response returned by the API to the screen
} catch (\Exception $e) {
echo 'Error: ' . $e->getMessage();
}