Merge pull request #4149 from arsaboo/openrouter

chore: Add HTTP-Referer and X-Title headers for OpenRouter
This commit is contained in:
Timothy Jaeryang Baek 2024-07-27 16:06:17 +02:00 committed by GitHub
commit 2e4de209fe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -462,6 +462,9 @@ async def generate_chat_completion(
headers = {}
headers["Authorization"] = f"Bearer {key}"
headers["Content-Type"] = "application/json"
if "openrouter.ai" in app.state.config.OPENAI_API_BASE_URLS[idx]:
headers["HTTP-Referer"] = "https://openwebui.com/"
headers["X-Title"] = "Open WebUI"
r = None
session = None