EdgeGPT is the reverse engineering API of Bing Chat AI.

set up

install module

python3 -m pip install EdgeGPT --upgrade

Require

  • python 3.8+
  • A Microsoft account that has passed the waitlist https://bing.com/chat (required)
  • You need to be in a country supported by New Bing (VPN is required in mainland China)

Check access permissions (required)

  • Install the latest version of Microsoft Edge
  • Alternatively, you can use any browser and set the user agent to that of Edge (egMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.51). You can use something like “User-Agent Switcher and Manager” Chrome and firefox An extension like this does this easily.
  • Open bing.com/chat
  • If you see chat, you’re all set

get authentication (required)

  • Install Chrome or firefox cookie editor extension
  • move to bing.com
  • Open the extension
  • Click “Export” in the lower right corner (this will save the contents to your clipboard)
  • Paste the contents of your clipboard into cookies.json in the file

image generation

$ python3 -m ImageGen -h
usage: ImageGen.py [-h] [-U U] [--cookie-file COOKIE_FILE] --prompt PROMPT [--output-dir OUTPUT_DIR] [--quiet] [--asyncio]

optional arguments:
  -h, --help            show this help message and exit
  -U U                  Auth cookie from browser
  --cookie-file COOKIE_FILE
                        File containing auth cookie
  --prompt PROMPT       Prompt to generate images for
  --output-dir OUTPUT_DIR
                        Output directory
  --quiet               Disable pipeline messages
  --asyncio             Run ImageGen using asyncio

development demo

from ImageGen import ImageGen
import argparse
import json

async def async_image_gen(args) -> None:
    async with ImageGenAsync(args.U, args.quiet) as image_generator:
        images = await image_generator.get_images(args.prompt)
        await image_generator.save_images(images, output_dir=args.output_dir)

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("-U", help="Auth cookie from browser", type=str)
    parser.add_argument("--cookie-file", help="File containing auth cookie", type=str)
    parser.add_argument(
        "--prompt",
        help="Prompt to generate images for",
        type=str,
        required=True,
    )
    parser.add_argument(
        "--output-dir",
        help="Output directory",
        type=str,
        default="./output",
    )
    args = parser.parse_args()
    # Load auth cookie
    with open(args.cookie_file, encoding="utf-8") as file:
        cookie_json = json.load(file)
        for cookie in cookie_json:
            if cookie.get("name") == "_U":
                args.U = cookie.get("value")
                break

    if args.U is None:
        raise Exception("Could not find auth cookie")

    if not args.asyncio:
        # Create image generator
        image_generator = ImageGen(args.U, args.quiet)
        image_generator.save_images(
            image_generator.get_images(args.prompt),
            output_dir=args.output_dir,
        )
    else:
        asyncio.run(async_image_gen(args))

#EdgeGPT #Homepage #Documentation #Downloads #Bing #Chat #Reverse #Engineering #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *