File tree Expand file tree Collapse file tree
packages/openai-adapters/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { ChatCompletionCreateParams } from "openai/resources/index" ;
22
3+ import { OPENROUTER_HEADERS } from "@continuedev/openai-adapters" ;
4+
35import { LLMOptions } from "../../index.js" ;
46import { osModelsEditPrompt } from "../templates/edit.js" ;
57
@@ -18,6 +20,19 @@ class OpenRouter extends OpenAI {
1820 useLegacyCompletionsEndpoint : false ,
1921 } ;
2022
23+ constructor ( options : LLMOptions ) {
24+ super ( {
25+ ...options ,
26+ requestOptions : {
27+ ...options . requestOptions ,
28+ headers : {
29+ ...OPENROUTER_HEADERS ,
30+ ...options . requestOptions ?. headers ,
31+ } ,
32+ } ,
33+ } ) ;
34+ }
35+
2136 private isAnthropicModel ( model ?: string ) : boolean {
2237 if ( ! model ) return false ;
2338 const modelLower = model . toLowerCase ( ) ;
Original file line number Diff line number Diff line change @@ -10,9 +10,10 @@ export interface OpenRouterConfig extends OpenAIConfig {
1010
1111// TODO: Extract detailed error info from OpenRouter's error.metadata.raw to surface better messages
1212
13- const OPENROUTER_HEADERS : Record < string , string > = {
13+ export const OPENROUTER_HEADERS : Record < string , string > = {
1414 "HTTP-Referer" : "https://www.continue.dev/" ,
15- "X-Title" : "Continue" ,
15+ "X-OpenRouter-Title" : "Continue" ,
16+ "X-OpenRouter-Categories" : "ide-extension" ,
1617} ;
1718
1819export class OpenRouterApi extends OpenAIApi {
Original file line number Diff line number Diff line change @@ -243,4 +243,5 @@ export {
243243} from "./apis/AnthropicUtils.js" ;
244244
245245export { isResponsesModel } from "./apis/openaiResponses.js" ;
246+ export { OPENROUTER_HEADERS } from "./apis/OpenRouter.js" ;
246247export { extractBase64FromDataUrl , parseDataUrl } from "./util/url.js" ;
You can’t perform that action at this time.
0 commit comments