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:
parent
d971363a7e
commit
43540d058c
2 changed files with 19 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue