PHP Classes

How to Use a Google Gemini PHP Client to Retrieve Answers to Questions in Natural Language Using the Package Google Generative AI: Get answers to prompts using Google Gemini AI

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-01-07 (2 months ago) RSS 2.0 feedNot enough user ratingsTotal: 32 This week: 2All time: 11,115 This week: 27Up
Version License PHP version Categories
google-generative-ai 1.0.0MIT/X Consortium ...8Web services, Artificial intelligence, P...
Description 

Author

This package can get answers to prompts using Google Gemini AI.

It can send HTTP requests to the Google Gemini Web server to request answers to given prompt questions.

The package can retrieve the prompt answers as documents, images, audio, or video.

A PHP package for Google Generative AI service

Picture of Nahid Bin Azhar
  Performance   Level  
Innovation award
Innovation award
Nominee: 7x

Winner: 2x

 

Example

<?php

require_once __DIR__ . '/../vendor/autoload.php';

use
Nahid\GoogleGenerativeAI\GoogleGenAI;
use
Nahid\GoogleGenerativeAI\Prompts\Concerns\Functions\Func;
use
Nahid\GoogleGenerativeAI\Prompts\Concerns\Functions\Parameter;



$client = GoogleGenAI::client(getenv('GEMINI_API_KEY'))
    ->
make();

try {
   
$resp = $client->prompt()
        ->
generate("Best shopify product reviews app");
} catch (
Exception $e) {
   
dd($e->getMessage());
}


//->withAudio('/Users/nahid/Downloads/record.ogg')

dd($resp->getBody()->getContents());

/*->withFunctions(
    Func::create('topSellingProducts', 'List of top selling products')
        ->addParameter(Parameter::create('limit', 'number', 'Limit of products to return', true))
        ->addParameter(Parameter::create('category', 'string', 'Category of products to return', false)),
    Func::create('getProduct', 'Get a product by title')
        ->addParameter(Parameter::create('title', 'string', 'Product title', true)),
    Func::create('offerProducts', 'List of offered products')
        ->addParameter(Parameter::create('percents', 'number', 'Discount percents', true))
        ->addParameter(Parameter::create('limit', 'number', 'Limit of products to return'))
)*/


Details

google-generative-ai

A PHP package for Google Generative AI service


  Files folder image Files (40)  
File Role Description
Files folder image.idea (7 files, 1 directory)
Files folder imageexample (1 file)
Files folder imagesrc (3 files, 4 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:32
This week:2
All time:11,115
This week:27Up