Browse Source

Add HTTP-Referer and X-Title headers for OpenRouter

Alok Saboo 9 months ago
parent
commit
287147687e
1 changed files with 3 additions and 0 deletions
  1. 3 0
      backend/apps/openai/main.py

+ 3 - 0
backend/apps/openai/main.py

@@ -459,6 +459,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