Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ from httpx import AsyncClient, RequestError, Timeout
|
|
| 11 |
from starlette.types import Receive, Scope, Send
|
| 12 |
|
| 13 |
API_KEYS = [line for line in environ['API_KEYS'].strip().split('\n') if line and line.startswith('sk-')]
|
|
|
|
| 14 |
COMPLETIONS_URL = 'https://openrouter.ai/api/v1/chat/completions'
|
| 15 |
app = FastAPI(title='reverse-proxy')
|
| 16 |
|
|
@@ -138,6 +139,7 @@ async def proxy_openai_api(request: Request):
|
|
| 138 |
return response
|
| 139 |
except AuthError:
|
| 140 |
print(f'ключ API {api_key} недействителен или превышен лимит отправки запросов')
|
|
|
|
| 141 |
raise HTTPException(status_code=401, detail='все ключи API использованы, доступ запрещен.')
|
| 142 |
|
| 143 |
|
|
|
|
| 11 |
from starlette.types import Receive, Scope, Send
|
| 12 |
|
| 13 |
API_KEYS = [line for line in environ['API_KEYS'].strip().split('\n') if line and line.startswith('sk-')]
|
| 14 |
+
print(f'всего ключей: {len(API_KEYS)}')
|
| 15 |
COMPLETIONS_URL = 'https://openrouter.ai/api/v1/chat/completions'
|
| 16 |
app = FastAPI(title='reverse-proxy')
|
| 17 |
|
|
|
|
| 139 |
return response
|
| 140 |
except AuthError:
|
| 141 |
print(f'ключ API {api_key} недействителен или превышен лимит отправки запросов')
|
| 142 |
+
continue
|
| 143 |
raise HTTPException(status_code=401, detail='все ключи API использованы, доступ запрещен.')
|
| 144 |
|
| 145 |
|