summaryrefslogtreecommitdiffstats
path: root/g4f/api/__init__.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-29 14:44:51 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-29 14:44:51 +0100
commit3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b (patch)
treeafe2fd00ba7ef0abebce7d80f1d4d5568a3b7195 /g4f/api/__init__.py
parentAdd websocket support in OpenaiChat (diff)
downloadgpt4free-3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b.tar
gpt4free-3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b.tar.gz
gpt4free-3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b.tar.bz2
gpt4free-3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b.tar.lz
gpt4free-3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b.tar.xz
gpt4free-3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b.tar.zst
gpt4free-3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b.zip
Diffstat (limited to 'g4f/api/__init__.py')
-rw-r--r--g4f/api/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/g4f/api/__init__.py b/g4f/api/__init__.py
index f8d0b4af..d8e68bed 100644
--- a/g4f/api/__init__.py
+++ b/g4f/api/__init__.py
@@ -85,7 +85,9 @@ class Api:
if config.api_key is None and request is not None:
auth_header = request.headers.get("Authorization")
if auth_header is not None:
- config.api_key = auth_header.split(None, 1)[-1]
+ auth_header = auth_header.split(None, 1)[-1]
+ if auth_header and auth_header != "Bearer":
+ config.api_key = auth_header
response = self.client.chat.completions.create(
**config.dict(exclude_none=True),
ignored=self.list_ignored_providers