summaryrefslogtreecommitdiffstats
path: root/README.md
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-02-09 05:53:47 +0100
committerGitHub <noreply@github.com>2024-02-09 05:53:47 +0100
commit999bc2d617a70ad70d185ba59c108d01794f9b5f (patch)
treed27a53d1549b352c8ab723680d51f01db6ae9d5c /README.md
parentMerge pull request #1554 from Masha/patch-1 (diff)
parentAdd example for Image Upload & Generation (diff)
downloadgpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar
gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.gz
gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.bz2
gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.lz
gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.xz
gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.tar.zst
gpt4free-999bc2d617a70ad70d185ba59c108d01794f9b5f.zip
Diffstat (limited to 'README.md')
-rw-r--r--README.md26
1 files changed, 25 insertions, 1 deletions
diff --git a/README.md b/README.md
index f136e206..91826b9a 100644
--- a/README.md
+++ b/README.md
@@ -316,7 +316,7 @@ For generating images with Bing and for the OpenAi Chat you need cookies or a t
```python
from g4f import set_cookies
-set_cookies(".bing", {
+set_cookies(".bing.com", {
"_U": "cookie value"
})
set_cookies("chat.openai.com", {
@@ -336,6 +336,30 @@ pip install browser_cookie3
pip install g4f[webdriver]
```
+##### Image Upload & Generation
+
+Image upload and generation are supported by three main providers:
+
+- **Bing & Other GPT-4 Providers:** Utilizes Microsoft's Image Creator.
+- **Google Gemini:** Available for free accounts with IP addresses outside Europe.
+- **OpenaiChat with GPT-4:** Accessible for users with a Plus subscription.
+
+```python
+import g4f
+
+# Setting up the request for image creation
+response = g4f.ChatCompletion.create(
+ model=g4f.models.default, # Using the default model
+ provider=g4f.Provider.Gemini, # Specifying the provider as Gemini
+ messages=[{"role": "user", "content": "Create an image like this"}],
+ image=open("images/g4f.png", "rb"), # Image input can be a data URI, bytes, PIL Image, or IO object
+ image_name="g4f.png" # Optional: specifying the filename
+)
+
+# Displaying the response
+print(response)
+```
+
##### Using Browser
Some providers using a browser to bypass the bot protection. They using the selenium webdriver to control the browser. The browser settings and the login data are saved in a custom directory. If the headless mode is enabled, the browser windows are loaded invisibly. For performance reasons, it is recommended to reuse the browser instances and close them yourself at the end: