summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/BingCreateImages.py
diff options
context:
space:
mode:
Diffstat (limited to 'g4f/Provider/BingCreateImages.py')
-rw-r--r--g4f/Provider/BingCreateImages.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/g4f/Provider/BingCreateImages.py b/g4f/Provider/BingCreateImages.py
index 69bf1e92..9e5146cc 100644
--- a/g4f/Provider/BingCreateImages.py
+++ b/g4f/Provider/BingCreateImages.py
@@ -19,9 +19,13 @@ class BingCreateImages(AsyncGeneratorProvider, ProviderModelMixin):
needs_auth = True
image_models = ["dall-e"]
- def __init__(self, cookies: Cookies = None, proxy: str = None) -> None:
- self.cookies: Cookies = cookies
- self.proxy: str = proxy
+ def __init__(self, cookies: Cookies = None, proxy: str = None, api_key: str = None) -> None:
+ if api_key is not None:
+ if cookies is None:
+ cookies = {}
+ cookies["_U"] = api_key
+ self.cookies = cookies
+ self.proxy = proxy
@classmethod
async def create_async_generator(
@@ -33,9 +37,7 @@ class BingCreateImages(AsyncGeneratorProvider, ProviderModelMixin):
proxy: str = None,
**kwargs
) -> AsyncResult:
- if api_key is not None:
- cookies = {"_U": api_key}
- session = BingCreateImages(cookies, proxy)
+ session = BingCreateImages(cookies, proxy, api_key)
yield await session.create_async(messages[-1]["content"])
def create(self, prompt: str) -> Iterator[Union[ImageResponse, str]]: