Merge pull request #11991 from RomneyDa/feat/openrouter-headers-core-llm
This commit is contained in:
commit
a1ead04122
3 changed files with 19 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
import { ChatCompletionCreateParams } from "openai/resources/index";
|
||||
|
||||
import { OPENROUTER_HEADERS } from "@continuedev/openai-adapters";
|
||||
|
||||
import { LLMOptions } from "../../index.js";
|
||||
import { osModelsEditPrompt } from "../templates/edit.js";
|
||||
|
||||
|
|
@ -18,6 +20,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();
|
||||
|
|
|
|||
|
|
@ -10,9 +10,10 @@ export interface OpenRouterConfig extends OpenAIConfig {
|
|||
|
||||
// TODO: Extract detailed error info from OpenRouter's error.metadata.raw to surface better messages
|
||||
|
||||
const OPENROUTER_HEADERS: Record<string, string> = {
|
||||
export const OPENROUTER_HEADERS: Record<string, string> = {
|
||||
"HTTP-Referer": "https://www.continue.dev/",
|
||||
"X-Title": "Continue",
|
||||
"X-OpenRouter-Title": "Continue",
|
||||
"X-OpenRouter-Categories": "ide-extension",
|
||||
};
|
||||
|
||||
export class OpenRouterApi extends OpenAIApi {
|
||||
|
|
|
|||
|
|
@ -243,4 +243,5 @@ export {
|
|||
} from "./apis/AnthropicUtils.js";
|
||||
|
||||
export { isResponsesModel } from "./apis/openaiResponses.js";
|
||||
export { OPENROUTER_HEADERS } from "./apis/OpenRouter.js";
|
||||
export { extractBase64FromDataUrl, parseDataUrl } from "./util/url.js";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue