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 (Yesterday) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
google-generative-ai 1.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  
Name: Nahid Bin Azhar <contact>
Classes: 25 packages by
Country: United States United States
Innovation award
Innovation award
Nominee: 6x

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

  Files folder image Files (40)  /  .idea  
File Role Description
Files folder imagerunConfigurations (1 file)
  Accessible without login Plain text file google-generative-ai.iml Data Auxiliary data
  Accessible without login Plain text file misc.xml Data Auxiliary data
  Accessible without login Plain text file modules.xml Data Auxiliary data
  Accessible without login Plain text file php-test-framework.xml Data Auxiliary data
  Accessible without login Plain text file php.xml Data Auxiliary data
  Accessible without login Plain text file phpspec.xml Data Auxiliary data
  Accessible without login Plain text file vcs.xml Data Auxiliary data

  Files folder image Files (40)  /  .idea  /  runConfigurations  
File Role Description
  Accessible without login Plain text file Run_GenAI.xml Data Auxiliary data

  Files folder image Files (40)  /  example  
File Role Description
  Accessible without login Plain text file index.php Example Example script

  Files folder image Files (40)  /  src  
File Role Description
Files folder imageContracts (2 files)
Files folder imageEnums (1 file, 1 directory)
Files folder imageHttp (1 file, 1 directory)
Files folder imagePrompts (2 files, 2 directories)
  Plain text file Client.php Class Class source
  Plain text file GoogleFileManager.php Class Class source
  Plain text file GoogleGenAI.php Class Class source

  Files folder image Files (40)  /  src  /  Contracts  
File Role Description
  Plain text file Arrayable.php Class Class source
  Plain text file UploadableContract.php Class Class source

  Files folder image Files (40)  /  src  /  Enums  
File Role Description
Files folder imageHttp (3 files)
  Accessible without login Plain text file RunType.php Aux. Configuration script

  Files folder image Files (40)  /  src  /  Enums  /  Http  
File Role Description
  Accessible without login Plain text file ContentType.php Aux. Configuration script
  Accessible without login Plain text file Method.php Aux. Configuration script
  Accessible without login Plain text file RequestType.php Aux. Configuration script

  Files folder image Files (40)  /  src  /  Http  
File Role Description
Files folder imageValues (5 files)
  Plain text file Transporter.php Class Class source

  Files folder image Files (40)  /  src  /  Http  /  Values  
File Role Description
  Plain text file BaseUri.php Class Class source
  Plain text file Headers.php Class Class source
  Plain text file Parameters.php Class Class source
  Plain text file Payload.php Class Class source
  Plain text file QueryParams.php Class Class source

  Files folder image Files (40)  /  src  /  Prompts  
File Role Description
Files folder imageConcerns (5 files, 1 directory)
Files folder imageDTOs (3 files)
  Plain text file Prompt.php Class Class source
  Plain text file Uploadable.php Class Class source

  Files folder image Files (40)  /  src  /  Prompts  /  Concerns  
File Role Description
Files folder imageFunctions (2 files)
  Plain text file Audio.php Class Class source
  Plain text file Document.php Class Class source
  Plain text file GoogleSearch.php Class Class source
  Plain text file Image.php Class Class source
  Plain text file Video.php Class Class source

  Files folder image Files (40)  /  src  /  Prompts  /  Concerns  /  Functions  
File Role Description
  Plain text file Func.php Class Class source
  Plain text file Parameter.php Class Class source

  Files folder image Files (40)  /  src  /  Prompts  /  DTOs  
File Role Description
  Plain text file CredentialsDTO.php Class Class source
  Plain text file FileDataDTO.php Class Class source
  Plain text file FileInfoDTO.php Class Class source

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  
 100%
Total:0
This week:0