diff options
author | kqlio67 <kqlio67@users.noreply.github.com> | 2024-10-25 19:25:47 +0200 |
---|---|---|
committer | kqlio67 <kqlio67@users.noreply.github.com> | 2024-10-25 19:25:47 +0200 |
commit | 30f712779b2d405f6fb852e479162f2ac498f5e7 (patch) | |
tree | d958f702b8eab40f15e8368445b739b52f870071 /docs | |
parent | feat(README.md): update README with badges and links (diff) | |
download | gpt4free-30f712779b2d405f6fb852e479162f2ac498f5e7.tar gpt4free-30f712779b2d405f6fb852e479162f2ac498f5e7.tar.gz gpt4free-30f712779b2d405f6fb852e479162f2ac498f5e7.tar.bz2 gpt4free-30f712779b2d405f6fb852e479162f2ac498f5e7.tar.lz gpt4free-30f712779b2d405f6fb852e479162f2ac498f5e7.tar.xz gpt4free-30f712779b2d405f6fb852e479162f2ac498f5e7.tar.zst gpt4free-30f712779b2d405f6fb852e479162f2ac498f5e7.zip |
Diffstat (limited to '')
-rw-r--r-- | docs/async_client.md | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/docs/async_client.md b/docs/async_client.md index 0c296c09..05c7a0b8 100644 --- a/docs/async_client.md +++ b/docs/async_client.md @@ -3,13 +3,14 @@ The G4F async client API is a powerful asynchronous interface for interacting wi ## Compatibility Note -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. +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. ## Table of Contents - [Introduction](#introduction) - [Key Features](#key-features) - [Getting Started](#getting-started) - [Initializing the Client](#initializing-the-client) + - [Creating Chat Completions](#creating-chat-completions) - [Configuration](#configuration) - [Usage Examples](#usage-examples) - [Text Completions](#text-completions) @@ -51,6 +52,30 @@ client = Client( ) ``` + +## Creating Chat Completions +**Here’s an improved example of creating chat completions:** +```python +response = await async_client.chat.completions.create( + system="You are a helpful assistant.", + model="gpt-3.5-turbo", + messages=[ + { + "role": "user", + "content": "Say this is a test" + } + ] + # Add other parameters as needed +) +``` + +**This example:** + - Sets a system message to define the assistant's role + - 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 |