PHPackages                             maximerenou/bing-ai - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. maximerenou/bing-ai

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

maximerenou/bing-ai
===================

Bing AI adapter

1.2(2y ago)401.7k↓50%12[1 issues](https://github.com/maximerenou/php-bing-ai/issues)PHPPHP &gt;=7.1

Since Feb 15Pushed 2y ago3 watchersCompare

[ Source](https://github.com/maximerenou/php-bing-ai)[ Packagist](https://packagist.org/packages/maximerenou/bing-ai)[ RSS](/packages/maximerenou-bing-ai/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (13)Used By (0)

**New feature: send images in chat 🔥**

[![Bing + PHP](logo.png)](logo.png)

Bing AI client
==============

[](#bing-ai-client)

[![License](https://camo.githubusercontent.com/850eae1099d2b05f53383473d7cd51f9bc1ab09b7d0d9e5122f1dd930efdcc6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d6173686170652f6170697374617475732e737667)](https://opensource.org/licenses/MIT)[![Latest Stable Version](https://camo.githubusercontent.com/90001d78f82e150e8996fc31f37cccfe969b7b92f031c2156a184e8e5dc36934/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d6178696d6572656e6f752f7068702d62696e672d6169)](https://packagist.org/packages/maximerenou/bing-ai)[![PHP version](https://camo.githubusercontent.com/0fc8f5da22a045d8ccad210681b230a508ee14f386dffd15c1afedfeb5298928/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6d6178696d6572656e6f752f62696e672d61692f706870)](https://packagist.org/packages/maximerenou/bing-ai)[![cURL extension required](https://camo.githubusercontent.com/e70e82ea1632d82c902c309cef3c595f7b54935e67d72ef7e6dce860a116f40a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6d6178696d6572656e6f752f62696e672d61692f6578742d6375726c)](https://packagist.org/packages/maximerenou/bing-ai)

This is an unofficial PHP client for **Bing AI**, including **Chat (GPT-4)** and **Image Creator (DALL-E)**.

Installation
------------

[](#installation)

```
composer require maximerenou/bing-ai

```

Demo
----

[](#demo)

This demo program uses both Chat and Image Creator:

[![Demo](examples/demo.gif)](examples/demo.gif)

Source: `examples/multi.php`.

Usage
-----

[](#usage)

- [Chat AI](#chat-ai)
- [Image Creator AI](#image-creator)

First, you need to sign in on bing.com and get your `_U` cookie.

> ❗ Make sure you send a first message to Bing Chat before using your cookie (CAPTCHA bypass)

 How to get this cookie?1. Navigate to bing.com
2. Sign in using your Microsoft account
3. Back on bing.com, go to Bing Chat page and send a message (CAPTCHA verification occurs sometimes)
4. Then, right-click and select "Inspect" - the browser console appears
5. Go to "Application" tab
6. Select "Cookies" &gt; "" in the sidebar
7. Search for "\_U" cookie
8. Copy its content

  How to check if my cookie is working properly?```
use MaximeRenou\BingAI\BingAI;

// $cookie - your "_U" cookie from bing.com
$ai = new BingAI($cookie);
$valid = $ai->checkCookie();
```

---

### Chat AI

[](#chat-ai)

**Demo**: clone this repo, edit and run `examples/chat.php`.

```
use MaximeRenou\BingAI\BingAI;
use MaximeRenou\BingAI\Chat\Prompt;

// $cookie - your "_U" cookie from bing.com
$ai = new BingAI($cookie);

$conversation = $ai->createChatConversation();

// $text - Text-only version of Bing's answer
// $cards - Message objects array
list($text, $cards) = $conversation->ask(new Prompt("Hello World"));
```

> `$cards` contains all "messages" exchanged with Bing AI. It can be text (prompt or answer), signals, suggestions, image generation requests, etc. Check `Message.php` to learn more about its format.

 🔥 Image analysisYou may attach an image to your message:

```
$prompt = new Prompt("How cute is this animal?");
$prompt->withImage('/path/to/panda.png');
//or: $prompt->withImage($raw_image_data, true);

$conversation->ask($prompt, ...);
```

> **Try it!** Type *`$image`* at the end of your message with `examples/chat.php`.

  Real-time / progressive answerYou may pass a function as second argument to get real-time progression:

```
// $text - Incomplete text version
// $cards - Incomplete messages fleet
list($final_text, $final_cards) = $conversation->ask($prompt, function ($text, $cards) {
    echo $text;
});
```

  Locale and location preferences```
$conversation = $ai->createChatConversation()
    ->withLocation($latitude, $longitude, $radius) // Optional
    ->withPreferences('fr-FR', 'fr-FR', 'FR'); // Optional
```

  Tone choice```
use MaximeRenou\BingAI\Chat\Tone;

$conversation = $ai->createChatConversation()
    ->withTone(Tone::Creative); // Optional

// Choices:
// Tone::Balanced (default)
// Tone::Creative
// Tone::Precise
```

  Resume a conversationIf you want to resume a previous conversation, you can retrieve its identifiers:

```
// Get current identifiers
$identifiers = $conversation->getIdentifiers();

// ...
// Resume conversation with $identifiers parameter, and number of previous questions asked
$conversation = $ai->resumeChatConversation($identifiers, 1);
```

  Text generation```
$subject = "Internet memes";
$tone = 'funny';
$type = 'blog post';
$length = 'short';

$prompt = new Prompt("Please write a *$length* *$type* in a *$tone* style about `$subject`. Please wrap the $type in a markdown codeblock.");

$conversation->ask($prompt->withoutCache(), ...)
```

> To prevent answers like "I have already written \[...\]", you can disable cache for your prompt with `withoutCache()`.

 Handle throttling and kicksBing is limiting messages count per conversations. You can monitor it by calling `getRemainingMessages()` after every interaction.

```
$remaining = $conversation->getRemainingMessages();

if ($remaining === 0) {
    // You reached the limit
}
```

After every interaction, you should also check if you have been kicked from the conversation:

```
if ($conversation->kicked()) {
    // You have been kicked, you should start a new conversation
}
```

You may combine both checks with:

```
if ($conversation->ended()) {
    // You reached the limit or have been kicked
}
```

---

### Image Creator

[](#image-creator)

**Demo**: clone this repo, edit and run `examples/images.php`.

```
use MaximeRenou\BingAI\BingAI;

// $cookie - your "_U" cookie from bing.com
$ai = new BingAI($cookie);

$creator = $ai->createImages("A 3D teddy bear");

$creator->wait();

// Finally, get images URLs
if (! $creator->hasFailed()) {
    $images = $creator->getImages();
}
```

> Image generation can become slower after consuming all of your "boosts". Check the section below to stay aware of your remaining boosts.

 Check remaining boosts```
$creator = $ai->getImageCreator();

$remaining_boosts = $creator->getRemainingBoosts();
```

 Asynchronous generationYou may quit after calling `createImages()` and check generation later using its ID: ```
$prompt = "A 3D teddy bear";
$creator = $ai->createImages($prompt);
$generation_id = $creator->getGenerationId();

// ...

$creator = $ai->getImageCreator();
$creator->resume($generation_id, $prompt);
```

 Manually waitInstead of calling `$creator-&gt;wait();` you can loop by yourself: ```
do {
    sleep(1);
} while ($creator->isGenerating());
```

---

#### Disclaimer

[](#disclaimer)

Using Bing AI outside bing.com may violate Bing terms. Use it at your own risk. Bing is a trademark of Microsoft.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~17 days

Recently: every ~29 days

Total

12

Last Release

1001d ago

Major Versions

0.9 → 1.02023-05-02

PHP version history (2 changes)0.1PHP &gt;=8.1

0.8PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/80bcf6ed37c089e47d02a7210fefb2ecd4ebc38c05491f72c0ef2a55fb0536f0?d=identicon)[maximerenou](/maintainers/maximerenou)

---

Top Contributors

[![maximerenou](https://avatars.githubusercontent.com/u/4728191?v=4)](https://github.com/maximerenou "maximerenou (21 commits)")

---

Tags

aibingchatchatgptdall-e2imagecreatorphp

### Embed Badge

![Health badge](/badges/maximerenou-bing-ai/health.svg)

```
[![Health](https://phpackages.com/badges/maximerenou-bing-ai/health.svg)](https://phpackages.com/packages/maximerenou-bing-ai)
```

###  Alternatives

[alexwight/php-signalr-client

Signal R Client

2329.3k](/packages/alexwight-php-signalr-client)[millerphp/laravel-browserless

This is my package laravel-browserless

1212.0k](/packages/millerphp-laravel-browserless)[afaya/edge-tts

Edge TTS is a PHP package that allows access to the online text-to-speech service used by Microsoft Edge without the need for Microsoft Edge, Windows, or an API key.

151.0k1](/packages/afaya-edge-tts)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
