summaryrefslogtreecommitdiffstats
path: root/docs/client.md
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2024-10-30 09:54:54 +0100
committerGitHub <noreply@github.com>2024-10-30 09:54:54 +0100
commit1c8061af5550a150b1319d04275771698b226cec (patch)
tree489d5d84e812bd9ba3e2c88c2322b45f016c766d /docs/client.md
parentre-include`AsyncClient` for backwards compatibility, with deprecationwarning. Use `Client` instead (diff)
parentUpdate (docs/async_client.md docs/client.md docs/interference-api.md g4f/client/client.py) (diff)
downloadgpt4free-1c8061af5550a150b1319d04275771698b226cec.tar
gpt4free-1c8061af5550a150b1319d04275771698b226cec.tar.gz
gpt4free-1c8061af5550a150b1319d04275771698b226cec.tar.bz2
gpt4free-1c8061af5550a150b1319d04275771698b226cec.tar.lz
gpt4free-1c8061af5550a150b1319d04275771698b226cec.tar.xz
gpt4free-1c8061af5550a150b1319d04275771698b226cec.tar.zst
gpt4free-1c8061af5550a150b1319d04275771698b226cec.zip
Diffstat (limited to 'docs/client.md')
-rw-r--r--docs/client.md42
1 files changed, 41 insertions, 1 deletions
diff --git a/docs/client.md b/docs/client.md
index 08445402..388b2e4b 100644
--- a/docs/client.md
+++ b/docs/client.md
@@ -7,6 +7,7 @@
- [Getting Started](#getting-started)
- [Switching to G4F Client](#switching-to-g4f-client)
- [Initializing the Client](#initializing-the-client)
+ - [Creating Chat Completions](#creating-chat-completions)
- [Configuration](#configuration)
- [Usage Examples](#usage-examples)
- [Text Completions](#text-completions)
@@ -56,6 +57,28 @@ client = Client(
# Add any other necessary parameters
)
```
+
+## Creating Chat Completions
+**Here’s an improved example of creating chat completions:**
+```python
+response = client.chat.completions.create(
+ model="gpt-3.5-turbo",
+ messages=[
+ {
+ "role": "user",
+ "content": "Say this is a test"
+ }
+ ]
+ # Add any other necessary parameters
+)
+```
+
+**This example:**
+ - Asks a specific question `Say this is a test`
+ - Configures various parameters like temperature and max_tokens for more control over the output
+ - Disables streaming for a complete response
+
+You can adjust these parameters based on your specific needs.
## Configuration
@@ -129,7 +152,7 @@ from g4f.client import Client
client = Client()
response = client.images.generate(
- model="dall-e-3",
+ model="flux",
prompt="a white siamese cat"
# Add any other necessary parameters
)
@@ -139,6 +162,23 @@ image_url = response.data[0].url
print(f"Generated image URL: {image_url}")
```
+
+#### Base64 Response Format
+```python
+from g4f.client import Client
+
+client = Client()
+
+response = client.images.generate(
+ model="flux",
+ prompt="a white siamese cat",
+ response_format="b64_json"
+)
+
+base64_text = response.data[0].b64_json
+print(base64_text)
+```
+
### Creating Image Variations