{"id":22887623,"url":"https://github.com/dedinc/bingart","last_synced_at":"2026-02-07T09:05:35.492Z","repository":{"id":210482944,"uuid":"726678577","full_name":"DedInc/bingart","owner":"DedInc","description":"bingart is an unofficial API wrapper for Bing Image \u0026 Video Creator. It allows you to programmatically generate AI-powered images using Bing's image creation tool.","archived":false,"fork":false,"pushed_at":"2026-01-22T06:27:54.000Z","size":19,"stargazers_count":49,"open_issues_count":0,"forks_count":11,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-22T21:16:31.564Z","etag":null,"topics":["ai-art","ai-art-generator","ai-generated-images","ai-generation","ai-video-generator","bing-api","bingart","dall-e","dall-e-3","dalle-3","dalle3","video-generation"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/bingart/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DedInc.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-03T03:40:02.000Z","updated_at":"2026-01-22T06:29:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"4ff1fd2c-4dfc-408c-831b-797c74c09682","html_url":"https://github.com/DedInc/bingart","commit_stats":null,"previous_names":["dedinc/bingart"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/DedInc/bingart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fbingart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fbingart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fbingart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fbingart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DedInc","download_url":"https://codeload.github.com/DedInc/bingart/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DedInc%2Fbingart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29190842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-art","ai-art-generator","ai-generated-images","ai-generation","ai-video-generator","bing-api","bingart","dall-e","dall-e-3","dalle-3","dalle3","video-generation"],"created_at":"2024-12-13T20:37:20.294Z","updated_at":"2026-02-07T09:05:35.486Z","avatar_url":"https://github.com/DedInc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bingart\n\nbingart is an unofficial async API wrapper for Bing Image \u0026 Video Creator. It allows you to programmatically generate AI-powered images and videos using Bing's creation tools with support for multiple models and aspect ratios.\n\n\u003e **Warning:** The `_U` auth cookie should be changed every 2-4 weeks for proper functionality.\n\n## Description\n\nThis module uses web scraping and engineering techniques to interface with Bing's internal image and video creation APIs. It is not an official API client.\n\n### Key Features\n\n- **Fully asynchronous** — built on `curl_cffi` `AsyncSession` and `asyncio`\n- **Generate images** with multiple AI models (DALL-E, GPT-4O, MAI1)\n- **Generate videos** from text prompts\n- **Custom aspect ratios** (Square, Landscape, Portrait)\n- **Get image URLs** — up to 4 generated images per request\n- **Flexible authentication** via cookies or auto-fetched from browsers\n- **Enhanced prompts** — get AI-improved versions of your prompts\n- **Async context manager** support (`async with`)\n- **Custom exceptions** for common error handling\n\n## Installation\n\n```bash\npip install bingart\n```\n\n## Usage\n\n### Basic Setup\n\nImport and instantiate the `BingArt` class with a valid `_U` cookie value:\n\n```python\nimport asyncio\nfrom bingart import BingArt\n\nasync def main():\n    bing_art = BingArt(auth_cookie_U='your_cookie_value_here')\n    try:\n        result = await bing_art.generate('sunset over mountains')\n        print(result)\n    finally:\n        await bing_art.close()\n\nasyncio.run(main())\n```\n\n### Using Async Context Manager (Recommended)\n\n```python\nimport asyncio\nfrom bingart import BingArt\n\nasync def main():\n    async with BingArt(auth_cookie_U='your_cookie_value_here') as bing_art:\n        result = await bing_art.generate('sunset over mountains')\n        print(result)\n\nasyncio.run(main())\n```\n\n### Auto Cookie Detection\n\nLet bingart automatically fetch cookies from your installed browsers:\n\n```python\nfrom bingart import BingArt\n\n# Auto-fetch cookies from Chrome, Edge, Firefox, Brave, Opera, Vivaldi, or Chromium\nbing_art = BingArt(auto=True)\n```\n\nSupported browsers for auto-detection:\n- Chrome\n- Edge\n- Firefox\n- Brave\n- Opera\n- Vivaldi\n- Chromium\n\n### Advanced Usage with Models and Aspect Ratios\n\n```python\nimport asyncio\nfrom bingart import BingArt, Model, Aspect\n\nasync def main():\n    async with BingArt(auth_cookie_U='your_cookie_value') as bing_art:\n        # Generate with GPT-4O model in portrait aspect\n        result = await bing_art.generate(\n            'a futuristic cityscape',\n            model=Model.GPT4O,\n            aspect=Aspect.PORTRAIT\n        )\n        print(result)\n\n        # Generate with MAI1 model in landscape aspect\n        result = await bing_art.generate(\n            'serene mountain landscape',\n            model=Model.MAI1,\n            aspect=Aspect.LANDSCAPE\n        )\n        print(result)\n\n        # Generate with DALL-E (default) in square aspect\n        result = await bing_art.generate(\n            'abstract art composition',\n            model=Model.DALLE,\n            aspect=Aspect.SQUARE\n        )\n        print(result)\n\nasyncio.run(main())\n```\n\n### Available Models\n\n```python\nfrom bingart import Model\n\nModel.DALLE    # DALL-E 3 (default)\nModel.GPT4O    # GPT-4O image generation\nModel.MAI1     # MAI1 model\n```\n\n### Available Aspect Ratios\n\n```python\nfrom bingart import Aspect\n\nAspect.SQUARE      # 1:1 (default)\nAspect.LANDSCAPE   # 7:4 (wide)\nAspect.PORTRAIT    # 4:7 (tall)\n```\n\n### Video Generation\n\n```python\nimport asyncio\nfrom bingart import BingArt\n\nasync def main():\n    async with BingArt(auth_cookie_U='your_cookie_value') as bing_art:\n        result = await bing_art.generate(\n            'a dancing robot in a futuristic city',\n            content_type='video'\n        )\n        print(result)\n\nasyncio.run(main())\n```\n\n## Output Format\n\n### Image Generation Response\n\n```json\n{\n  \"images\": [\n    {\"url\": \"https://th.bing.com/th/id/OIG.xxx?pid=ImgGn\"},\n    {\"url\": \"https://th.bing.com/th/id/OIG.yyy?pid=ImgGn\"},\n    {\"url\": \"https://th.bing.com/th/id/OIG.zzz?pid=ImgGn\"},\n    {\"url\": \"https://th.bing.com/th/id/OIG.www?pid=ImgGn\"}\n  ],\n  \"prompt\": \"enhanced version of your original prompt\",\n  \"model\": \"GPT4O\",\n  \"aspect\": \"PORTRAIT\"\n}\n```\n\n### Video Generation Response\n\n```json\n{\n  \"video\": {\n    \"video_url\": \"https://...\"\n  },\n  \"prompt\": \"your original prompt\"\n}\n```\n\n## Exception Handling\n\n```python\nimport asyncio\nfrom bingart import BingArt, AuthCookieError, PromptRejectedError\n\nasync def main():\n    try:\n        async with BingArt(auth_cookie_U='your_cookie_value') as bing_art:\n            result = await bing_art.generate('your prompt here')\n            print(result)\n    except AuthCookieError:\n        print(\"Invalid authentication cookie or session expired\")\n    except PromptRejectedError:\n        print(\"Prompt was rejected due to content policy violation\")\n\nasyncio.run(main())\n```\n\n### Available Exceptions\n\n- `AuthCookieError`: Raised when authentication cookie is invalid or expired\n- `PromptRejectedError`: Raised when prompt violates content policy or is rejected as unethical\n\n## Getting Your Cookie\n\n1. Open your browser and go to [Bing Image Creator](https://www.bing.com/images/create)\n2. Log in with your Microsoft account\n3. Open Developer Tools (F12)\n4. Go to Application/Storage → Cookies → `https://www.bing.com`\n5. Find the `_U` cookie and copy its value\n\n## Complete Example\n\n```python\nimport asyncio\nfrom bingart import BingArt, Model, Aspect, AuthCookieError, PromptRejectedError\n\nasync def main():\n    try:\n        async with BingArt(auto=True) as bing_art:\n            # Generate multiple images with different settings\n            prompts = [\n                {\n                    \"query\": \"cyberpunk cityscape at night\",\n                    \"model\": Model.GPT4O,\n                    \"aspect\": Aspect.LANDSCAPE\n                },\n                {\n                    \"query\": \"portrait of a mystical wizard\",\n                    \"model\": Model.DALLE,\n                    \"aspect\": Aspect.PORTRAIT\n                },\n                {\n                    \"query\": \"abstract geometric patterns\",\n                    \"model\": Model.MAI1,\n                    \"aspect\": Aspect.SQUARE\n                }\n            ]\n\n            for config in prompts:\n                print(f\"\\nGenerating: {config['query']}\")\n                result = await bing_art.generate(\n                    config['query'],\n                    model=config['model'],\n                    aspect=config['aspect']\n                )\n\n                print(f\"Model: {result['model']}\")\n                print(f\"Aspect: {result['aspect']}\")\n                print(f\"Enhanced prompt: {result['prompt']}\")\n                print(f\"Generated {len(result['images'])} images\")\n\n                for idx, img in enumerate(result['images'], 1):\n                    print(f\"  Image {idx}: {img['url']}\")\n\n            # Generate a video\n            print(\"\\nGenerating video...\")\n            video_result = await bing_art.generate(\n                'a cat playing piano',\n                content_type='video'\n            )\n            print(f\"Video URL: {video_result['video']['video_url']}\")\n\n    except AuthCookieError as e:\n        print(f\"Authentication error: {e}\")\n    except PromptRejectedError as e:\n        print(f\"Prompt rejected: {e}\")\n\nasyncio.run(main())\n```\n\n## Requirements\n\n- Python \u003e= 3.6\n- curl_cffi\n- rookiepy\n\n## Contributing\n\nPull requests are welcome! Please open an issue to discuss major changes before submitting.\n\n## License\n\nMIT License - see LICENSE file for details\n\n## Disclaimer\n\nThis is an unofficial API wrapper and is not affiliated with Microsoft or Bing. Use responsibly and in accordance with Bing's terms of service.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdedinc%2Fbingart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdedinc%2Fbingart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdedinc%2Fbingart/lists"}