summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-12 11:41:27 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-12 11:41:27 +0100
commitaba4b96f23ef38ca75195b3b78a88bb92035b4a9 (patch)
tree92575678f27d48e2258e823fa299ed21af6cbad2 /docs
parentImprove preview in image generation of Gemini (diff)
downloadgpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.gz
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.bz2
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.lz
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.xz
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.tar.zst
gpt4free-aba4b96f23ef38ca75195b3b78a88bb92035b4a9.zip
Diffstat (limited to 'docs')
-rw-r--r--docs/cat.jpegbin0 -> 8672 bytes
-rw-r--r--docs/client.md71
2 files changed, 71 insertions, 0 deletions
diff --git a/docs/cat.jpeg b/docs/cat.jpeg
new file mode 100644
index 00000000..56bbb159
--- /dev/null
+++ b/docs/cat.jpeg
Binary files differ
diff --git a/docs/client.md b/docs/client.md
new file mode 100644
index 00000000..1201a83d
--- /dev/null
+++ b/docs/client.md
@@ -0,0 +1,71 @@
+### Client API
+##### from g4f (beta)
+
+#### Start
+This new client could:
+
+```python
+from g4f.client import Client
+```
+replaces this:
+
+```python
+from openai import OpenAI
+```
+in your Python Code.
+
+New client have the same API as OpenAI.
+
+#### Client
+
+Create the client with custom providers:
+
+```python
+from g4f.client import Client
+from g4f.Provider import BingCreateImages, OpenaiChat, Gemini
+
+client = Client(
+ provider=OpenaiChat,
+ image_provider=Gemini,
+ proxies=None
+)
+```
+
+#### Examples
+
+Use the ChatCompletions:
+
+```python
+stream = client.chat.completions.create(
+ model="gpt-4",
+ messages=[{"role": "user", "content": "Say this is a test"}],
+ stream=True,
+)
+for chunk in stream:
+ if chunk.choices[0].delta.content is not None:
+ print(chunk.choices[0].delta.content, end="")
+```
+
+Or use it for creating a image:
+```python
+response = client.images.generate(
+ model="dall-e-3",
+ prompt="a white siamese cat",
+ ...
+)
+
+image_url = response.data[0].url
+```
+
+Also this works with the client:
+```python
+response = client.images.create_variation(
+ image=open('cat.jpg')
+ model="bing",
+ ...
+)
+
+image_url = response.data[0].url
+```
+
+[to Home](/docs/client.md)