DEV Community

Cover image for php-bard-api
John Pinto
John Pinto

Posted on

php-bard-api

php-bard-api

A package that returns Response of Google Bard through API

Prerequisites

  • PHP 8.1
  • composer

Install

 composer require pj8912/php-bard-api
Enter fullscreen mode Exit fullscreen mode

Usage

<?php
require_once 'vendor/autoload.php';
use Pj8912\PhpBardApi\Bard;

$_ENV['_BARD_API_KEY'] = "Your Key";

$bard = new Bard();
$input_text = "Hello, Bard!";  // Input text for the conversation
$result = $bard->get_answer($input_text);  

// Access the result data
$conversation_id = $result["conversation_id"];
$response_id = $result["response_id"];
$factualityQueries = $result["factualityQueries"];
$textQuery = $result["textQuery"];
$choices = $result["choices"];

// reply for query 
$content = $result["content"];
print($content);
?>
Enter fullscreen mode Exit fullscreen mode

Github

https://github.com/pj8912/php-bard-api

Top comments (0)