https://github.com/khaledalam/bard-sdk-php
PHP SDK/API for Google Bard (experiment version) (unofficial)
https://github.com/khaledalam/bard-sdk-php
ai bard bard-ai bard-api chatbot google sdk sdk-php
Last synced: 3 months ago
JSON representation
PHP SDK/API for Google Bard (experiment version) (unofficial)
- Host: GitHub
- URL: https://github.com/khaledalam/bard-sdk-php
- Owner: khaledalam
- Created: 2023-05-19T22:28:45.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-01T08:48:00.000Z (over 2 years ago)
- Last Synced: 2025-07-25T20:16:29.146Z (4 months ago)
- Topics: ai, bard, bard-ai, bard-api, chatbot, google, sdk, sdk-php
- Language: PHP
- Homepage: https://bard.google.com/
- Size: 449 KB
- Stars: 7
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#
PHP SDK/API for Google Bard (experiment version) (unofficial)
[](https://packagist.org/packages/khaledalam/bard-sdk-php)
[](https://packagist.org/packages/khaledalam/bard-sdk-php)
[](https://packagist.org/packages/khaledalam/bard-sdk-php)
[](https://packagist.org/packages/khaledalam/bard-sdk-php)
[](https://packagist.org/packages/khaledalam/bard-sdk-php)

Reverse engineering of Google's Bard chatbot.
## Disclamer
- ApiKeyCookie.php implemented only for easing the access to Google Bard, any legal responsibilities lie with the user.
- Don't expose your `__Secure-1PSID` cookie value on the internet.
## Install
> $ composer require khaledalam/bard-sdk-php
## Test
> $ composer run test
## Auth
1. Navigate to https://bard.google.com/
2. Open "Developer Tools" from browser settings or click [F12] shortcut for console.
3. Go to Application tab => open "Cookies" from left tab => click "https://accounts.google.com" => Copy the value of `__Secure-1PSID` cookie.

## Simple Usage
Change `_YOUR_COOKIE_VALUE_`
```php
ask($question);
print_r($answer['content']);
/*
Output (May-2023):
The most recent stable version of Ubuntu LTS is Ubuntu 22.04 LTS, codenamed "Jammy Jellyfish." It was released on April 21, 2022, and will be supported with free security and maintenance updates for five years, until April 2027.
Ubuntu LTS releases are designed for use in enterprise and server environments, where reliability and stability are critical. They are also a good choice for home users who want a reliable and long-lasting operating system.
*/
} catch (Exception $e)
{
die("Error: " . $e->getMessage());
}
```
Output (May-2023):
```
The most recent stable version of Ubuntu LTS is Ubuntu 22.04 LTS, codenamed "Jammy Jellyfish." It was released on April 21, 2022, and will be supported with free security and maintenance updates for five years, until April 2027.
Ubuntu LTS releases are designed for use in enterprise and server environments, where reliability and stability are critical. They are also a good choice for home users who want a reliable and long-lasting operating system.
```
## Examples
Example1(world_datatime_ai):
> php examples/world_datetime_ai/main.php
Example2(docker)
## Technical
### Diagram

### TODOs:
- [x] Cookie
- [ ] Api key
- [ ] codecov
- [x] Testing
- [x] CI GitHub actions
### License
- [MIT](https://opensource.org/license/mit/)