From 3b96c27e3c7483f63d758d056ec5f0cd2fde0f8b Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Thu, 29 Feb 2024 14:44:51 +0100 Subject: Ignore empty auth header in api Add live token count in gui --- g4f/api/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'g4f/api') 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 -- cgit v1.2.3