@memberjunction/ai-openrouter 5.38.0 → 5.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
import { ChatParams } from "@memberjunction/ai";
|
|
1
2
|
import { OpenAILLM } from "@memberjunction/ai-openai";
|
|
2
3
|
/**
|
|
3
|
-
* OpenRouter implementation is just a sub-class of the OpenAILLM that overrides the base url
|
|
4
|
+
* OpenRouter implementation is just a sub-class of the OpenAILLM that overrides the base url.
|
|
5
|
+
*
|
|
6
|
+
* OpenRouter routes the same model across many upstream providers at varying prices and returns the
|
|
7
|
+
* authoritative dollar cost of each call directly in the response — but only when usage accounting
|
|
8
|
+
* is explicitly requested. We opt in here so the inherited OpenAILLM usage normalization surfaces
|
|
9
|
+
* `usage.cost` as `ModelUsage.cost`; the prompt-cost pipeline then uses that verbatim and skips
|
|
10
|
+
* rate-table estimation. This means OpenRouter-routed models need no `AIModelCost` rows at all.
|
|
4
11
|
*/
|
|
5
12
|
export declare class OpenRouterLLM extends OpenAILLM {
|
|
6
13
|
constructor(apiKey: string);
|
|
14
|
+
/**
|
|
15
|
+
* Request OpenRouter's usage accounting so the response includes `usage.cost` and
|
|
16
|
+
* `usage.cost_details`. The OpenAI SDK forwards this extra body param unchanged.
|
|
17
|
+
* @see https://openrouter.ai/docs/use-cases/usage-accounting
|
|
18
|
+
*/
|
|
19
|
+
protected getProviderRequestExtras(params: ChatParams): Record<string, unknown>;
|
|
7
20
|
}
|
|
8
21
|
//# sourceMappingURL=openRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openRouter.d.ts","sourceRoot":"","sources":["../../src/models/openRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"openRouter.d.ts","sourceRoot":"","sources":["../../src/models/openRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAItD;;;;;;;;GAQG;AACH,qBACa,aAAc,SAAQ,SAAS;gBAC5B,MAAM,EAAE,MAAM;IAI1B;;;;OAIG;cACgB,wBAAwB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG3F"}
|
|
@@ -12,12 +12,26 @@ import { RegisterClass } from '@memberjunction/global';
|
|
|
12
12
|
import { OpenAILLM } from "@memberjunction/ai-openai";
|
|
13
13
|
const __openRouterURL = 'https://openrouter.ai/api/v1';
|
|
14
14
|
/**
|
|
15
|
-
* OpenRouter implementation is just a sub-class of the OpenAILLM that overrides the base url
|
|
15
|
+
* OpenRouter implementation is just a sub-class of the OpenAILLM that overrides the base url.
|
|
16
|
+
*
|
|
17
|
+
* OpenRouter routes the same model across many upstream providers at varying prices and returns the
|
|
18
|
+
* authoritative dollar cost of each call directly in the response — but only when usage accounting
|
|
19
|
+
* is explicitly requested. We opt in here so the inherited OpenAILLM usage normalization surfaces
|
|
20
|
+
* `usage.cost` as `ModelUsage.cost`; the prompt-cost pipeline then uses that verbatim and skips
|
|
21
|
+
* rate-table estimation. This means OpenRouter-routed models need no `AIModelCost` rows at all.
|
|
16
22
|
*/
|
|
17
23
|
let OpenRouterLLM = class OpenRouterLLM extends OpenAILLM {
|
|
18
24
|
constructor(apiKey) {
|
|
19
25
|
super(apiKey, __openRouterURL);
|
|
20
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Request OpenRouter's usage accounting so the response includes `usage.cost` and
|
|
29
|
+
* `usage.cost_details`. The OpenAI SDK forwards this extra body param unchanged.
|
|
30
|
+
* @see https://openrouter.ai/docs/use-cases/usage-accounting
|
|
31
|
+
*/
|
|
32
|
+
getProviderRequestExtras(params) {
|
|
33
|
+
return { usage: { include: true } };
|
|
34
|
+
}
|
|
21
35
|
};
|
|
22
36
|
OpenRouterLLM = __decorate([
|
|
23
37
|
RegisterClass(BaseLLM, 'OpenRouterLLM'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openRouter.js","sourceRoot":"","sources":["../../src/models/openRouter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"openRouter.js","sourceRoot":"","sources":["../../src/models/openRouter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,OAAO,EAAc,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,MAAM,eAAe,GAAW,8BAA8B,CAAA;AAE9D;;;;;;;;GAQG;AAEI,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,SAAS;IACxC,YAAY,MAAc;QACtB,KAAK,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACgB,wBAAwB,CAAC,MAAkB;QAC1D,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;IACxC,CAAC;CACJ,CAAA;AAbY,aAAa;IADzB,aAAa,CAAC,OAAO,EAAE,eAAe,CAAC;;GAC3B,aAAa,CAazB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memberjunction/ai-openrouter",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.39.0",
|
|
5
5
|
"description": "MemberJunction Wrapper for OpenRouter AI inference services",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"typescript": "^5.9.3"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@memberjunction/ai": "5.
|
|
24
|
-
"@memberjunction/ai-openai": "5.
|
|
25
|
-
"@memberjunction/global": "5.
|
|
23
|
+
"@memberjunction/ai": "5.39.0",
|
|
24
|
+
"@memberjunction/ai-openai": "5.39.0",
|
|
25
|
+
"@memberjunction/global": "5.39.0"
|
|
26
26
|
},
|
|
27
27
|
"repository": {
|
|
28
28
|
"type": "git",
|