DedInc / bingart

bingart is an unofficial API wrapper for Bing Image Creator (based on DALL-E 3). It allows you to programmatically generate AI-powered images using Bing's image creation tool.

Home Page:https://pypi.org/project/bingart/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🎨 bingart

bingart is an unofficial 🀫 API wrapper for Bing Image Creator (based on DALL-E 3). It allows you to programmatically generate πŸ–ΌοΈ AI-powered images using Bing's image creation tool.

⚠️ Warning: The _U auth cookie should be changed every 2-4 weeks for working.

πŸ’‘ Description

This module uses web scraping and engineering techniques to interface with Bing's internal image creation APIs. It is not an official API client.

πŸ”‘ Key Features

  • πŸ–ΌοΈ Generate images by providing a text prompt
  • πŸ“Έ Get image URLs up to 4 generated images
  • πŸ” Authentication via saved Bing cookies or auto-fetched from browsers
  • ⚠️ Custom exceptions for common issues

πŸ’» Usage

Import and instantiate the BingArt class with a valid _U cookie value:

from bingart import BingArt

bing_art = BingArt(auth_cookie_U='...')

try:
    results = bing_art.generate_images('sunset')
    print(results)
finally:
    bing_art.close_session()

Sometimes an extra cookie called KievRPSSecAuth is required for it to work properly

bing_art = BingArt(auth_cookie_U='...', auth_cookie_KievRPSSecAuth='...')

Also, you can try the auto cookie search feature

bing_art = BingArt(auto=True)

Call generate_images() with your query text:

results = bing.generate_images("a cat painting in Picasso style")

The return value contains image URLs and original prompt:

{
  "images": [
    {"url": "https://..."}
  ],
  "prompt": "a cat painting in Picasso style"
}

🚨 Exceptions

  • AuthCookieError: Invalid authentication cookie
  • PromptRejectedError: Prompt rejected as unethical

🀝 Contributing

Pull requests welcome! Please open an issue to discuss major changes.

About

bingart is an unofficial API wrapper for Bing Image Creator (based on DALL-E 3). It allows you to programmatically generate AI-powered images using Bing's image creation tool.

https://pypi.org/project/bingart/

License:MIT License


Languages

Language:Python 100.0%