From ca29885aa4cd30de4515352509904ea08a4474a9 Mon Sep 17 00:00:00 2001 From: Mic Date: Mon, 9 Jun 2025 20:42:00 +0200 Subject: [PATCH] update OpenAIComp to include additional headers for OpenRouter API requests. see #401 --- js/api/openai_comp.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/api/openai_comp.js b/js/api/openai_comp.js index 459f968f..a0ba14ec 100644 --- a/js/api/openai_comp.js +++ b/js/api/openai_comp.js @@ -41,6 +41,11 @@ export class OpenAIComp { "Content-Type": "application/json", }; if(this.apiKey !== '') curr_headers["Authorization"] = "Bearer "+ this.apiKey; + + if(this.host.includes('openrouter.ai')) { + curr_headers['HTTP-Referer'] = 'https://micz.it/thunderbird-addon-thunderai/'; + curr_headers['X-Title'] = 'ThunderAI'; + } const response = await fetch(this.host + (this.use_v1 ? "/v1" : "") + "/models", { method: "GET",