update OpenAIComp to include additional headers for OpenRouter API requests. see #401

This commit is contained in:
Mic 2025-06-09 20:42:00 +02:00
parent 700b4d5878
commit ca29885aa4

View file

@ -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",