返回提交历史
Modified
docs/async_client.md
+26
-1
XFEstudio/gpt4free
docs(docs/async_client.md): update guide with Anthropic compatibility and improved chat completions example
30f71277
代码差异
1 个文件
+26
-1
@@ -3,13 +3,14 @@ The G4F async client API is a powerful asynchronous interface for interacting wi
3
3
4
4
5
5
## Compatibility Note
6
The G4F async client API is designed to be compatible with the OpenAI API, making it easy for developers familiar with OpenAI's interface to transition to G4F.
6
The G4F async client API is designed to be compatible with the OpenAI and Anthropic API, making it easy for developers familiar with OpenAI's or Anthropic's interface to transition to G4F.
7
7
8
8
## Table of Contents
9
9
- [Introduction](#introduction)
10
10
- [Key Features](#key-features)
11
11
- [Getting Started](#getting-started)
12
12
- [Initializing the Client](#initializing-the-client)
13
- [Creating Chat Completions](#creating-chat-completions)
13
14
- [Configuration](#configuration)
14
15
- [Usage Examples](#usage-examples)
15
16
- [Text Completions](#text-completions)
@@ -51,6 +52,30 @@ client = Client(
51
52
)
52
53
```
53
54
55
56
## Creating Chat Completions
57
**Here’s an improved example of creating chat completions:**
58
```python
59
response = await async_client.chat.completions.create(
60
system="You are a helpful assistant.",
61
model="gpt-3.5-turbo",
62
messages=[
63
{
64
"role": "user",
65
"content": "Say this is a test"
66
}
67
]
68
# Add other parameters as needed
69
)
70
```
71
72
**This example:**
73
- Sets a system message to define the assistant's role
74
- Asks a specific question `Say this is a test`
75
- Configures various parameters like temperature and max_tokens for more control over the output
76
- Disables streaming for a complete response
77
78
You can adjust these parameters based on your specific needs.
54
79
55
80
56
81
### Configuration