diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-09 06:36:28 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2024-02-09 06:36:28 +0100 |
commit | 23e002f52ffaffbaf98fa4251ceca70e465db05a (patch) | |
tree | f2ba5b5bec6deccef02afd6b29c3502a97b831a5 /README.md | |
parent | Add example for Image Upload & Generation (diff) | |
download | gpt4free-23e002f52ffaffbaf98fa4251ceca70e465db05a.tar gpt4free-23e002f52ffaffbaf98fa4251ceca70e465db05a.tar.gz gpt4free-23e002f52ffaffbaf98fa4251ceca70e465db05a.tar.bz2 gpt4free-23e002f52ffaffbaf98fa4251ceca70e465db05a.tar.lz gpt4free-23e002f52ffaffbaf98fa4251ceca70e465db05a.tar.xz gpt4free-23e002f52ffaffbaf98fa4251ceca70e465db05a.tar.zst gpt4free-23e002f52ffaffbaf98fa4251ceca70e465db05a.zip |
Diffstat (limited to '')
-rw-r--r-- | README.md | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -358,6 +358,21 @@ response = g4f.ChatCompletion.create( # Displaying the response print(response) + +from g4f.image import ImageResponse + +# Get image links from response +for chunk in g4f.ChatCompletion.create( + model=g4f.models.default, # Using the default model + provider=g4f.Provider.OpenaiChat, # Specifying the provider as OpenaiChat + messages=[{"role": "user", "content": "Create images with dogs"}], + access_token="...", # Need a access token from a plus user + stream=True, + ignore_stream=True +): + if isinstance(chunk, ImageResponse): + print(chunk.images) # Print generated image links + print(chunk.alt) # Print used prompt for image generation ``` ##### Using Browser |