feat(openrouter): send HTTP-Referer and X-Title headers in core/llm OpenRouter class

Adds the same HTTP-Referer and X-Title headers from the openai-adapters
OpenRouter class (#11857) to the core/llm OpenRouter class, ensuring all
OpenRouter requests are identified as coming from Continue.dev.

Also updates X-Title from "Continue" to "Continue.dev" in both the
openai-adapters and core/llm OpenRouter classes.

User-configured requestOptions.headers take precedence over the defaults.
This commit is contained in:
Dallin Romney 2026-04-01 12:44:01 -07:00
parent d971363a7e
commit 43540d058c
2 changed files with 19 additions and 1 deletions

View file

@ -5,6 +5,11 @@ import { osModelsEditPrompt } from "../templates/edit.js";
import OpenAI from "./OpenAI.js";
const OPENROUTER_HEADERS: Record<string, string> = {
"HTTP-Referer": "https://www.continue.dev/",
"X-Title": "Continue.dev",
};
class OpenRouter extends OpenAI {
static providerName = "openrouter";
protected supportsReasoningField = true;
@ -18,6 +23,19 @@ class OpenRouter extends OpenAI {
useLegacyCompletionsEndpoint: false,
};
constructor(options: LLMOptions) {
super({
...options,
requestOptions: {
...options.requestOptions,
headers: {
...OPENROUTER_HEADERS,
...options.requestOptions?.headers,
},
},
});
}
private isAnthropicModel(model?: string): boolean {
if (!model) return false;
const modelLower = model.toLowerCase();

View file

@ -12,7 +12,7 @@ export interface OpenRouterConfig extends OpenAIConfig {
const OPENROUTER_HEADERS: Record<string, string> = {
"HTTP-Referer": "https://www.continue.dev/",
"X-Title": "Continue",
"X-Title": "Continue.dev",
};
export class OpenRouterApi extends OpenAIApi {