@aigne/open-router 0.7.63-beta → 1.74.0-beta.1
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.
- package/README.md +11 -11
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +3 -0
- package/dist/open-router-chat-model.cjs +34 -0
- package/{lib/dts/open-router-chat-model.d.ts → dist/open-router-chat-model.d.cts} +9 -4
- package/dist/open-router-chat-model.d.cts.map +1 -0
- package/{lib/esm/open-router-chat-model.d.ts → dist/open-router-chat-model.d.mts} +9 -4
- package/dist/open-router-chat-model.d.mts.map +1 -0
- package/dist/open-router-chat-model.mjs +35 -0
- package/dist/open-router-chat-model.mjs.map +1 -0
- package/package.json +29 -30
- package/CHANGELOG.md +0 -2448
- package/lib/cjs/index.d.ts +0 -1
- package/lib/cjs/index.js +0 -17
- package/lib/cjs/open-router-chat-model.d.ts +0 -21
- package/lib/cjs/open-router-chat-model.js +0 -33
- package/lib/cjs/package.json +0 -3
- package/lib/dts/index.d.ts +0 -1
- package/lib/esm/index.d.ts +0 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/open-router-chat-model.js +0 -29
- package/lib/esm/package.json +0 -3
package/README.md
CHANGED
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<picture>
|
|
5
|
-
<source srcset="https://raw.githubusercontent.com/
|
|
6
|
-
<source srcset="https://raw.githubusercontent.com/
|
|
7
|
-
<img src="https://raw.githubusercontent.com/
|
|
5
|
+
<source srcset="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/logo-dark.svg" media="(prefers-color-scheme: dark)">
|
|
6
|
+
<source srcset="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/logo.svg" media="(prefers-color-scheme: light)">
|
|
7
|
+
<img src="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/logo.svg" alt="AIGNE Logo" width="400" />
|
|
8
8
|
</picture>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
[](https://star-history.com/#ArcBlock/aigne-framework)
|
|
12
|
+
[](https://github.com/ArcBlock/aigne-framework/issues)
|
|
13
|
+
[](https://codecov.io/gh/ArcBlock/aigne-framework)
|
|
14
14
|
[](https://www.npmjs.com/package/@aigne/open-router)
|
|
15
|
-
[](https://github.com/
|
|
15
|
+
[](https://github.com/ArcBlock/aigne-framework/blob/main/LICENSE.md)
|
|
16
16
|
|
|
17
|
-
AIGNE OpenRouter SDK for accessing multiple AI models through a unified API within the [AIGNE Framework](https://github.com/
|
|
17
|
+
AIGNE OpenRouter SDK for accessing multiple AI models through a unified API within the [AIGNE Framework](https://github.com/ArcBlock/aigne-framework).
|
|
18
18
|
|
|
19
19
|
## Introduction
|
|
20
20
|
|
|
21
21
|
`@aigne/open-router` provides a seamless integration between the AIGNE Framework and OpenRouter's unified API for accessing a wide variety of AI models. This package enables developers to easily leverage models from multiple providers (including OpenAI, Anthropic, Google, and more) through a single consistent interface, allowing for flexible model selection and fallback options.
|
|
22
22
|
|
|
23
23
|
<picture>
|
|
24
|
-
<source srcset="https://raw.githubusercontent.com/
|
|
25
|
-
<source srcset="https://raw.githubusercontent.com/
|
|
26
|
-
<img src="https://raw.githubusercontent.com/
|
|
24
|
+
<source srcset="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/assets/aigne-openrouter-dark.png" media="(prefers-color-scheme: dark)">
|
|
25
|
+
<source srcset="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/assets/aigne-openrouter.png" media="(prefers-color-scheme: light)">
|
|
26
|
+
<img src="https://raw.githubusercontent.com/ArcBlock/aigne-framework/main/aigne-openrouter.png" alt="AIGNE Arch" />
|
|
27
27
|
</picture>
|
|
28
28
|
|
|
29
29
|
## Features
|
package/dist/index.cjs
ADDED
package/dist/index.d.cts
ADDED
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
let _aigne_openai = require("@aigne/openai");
|
|
2
|
+
|
|
3
|
+
//#region src/open-router-chat-model.ts
|
|
4
|
+
const OPEN_ROUTER_DEFAULT_CHAT_MODEL = "openai/gpt-4o";
|
|
5
|
+
const OPEN_ROUTER_BASE_URL = "https://openrouter.ai/api/v1";
|
|
6
|
+
/**
|
|
7
|
+
* Implementation of the ChatModel interface for OpenRouter service
|
|
8
|
+
*
|
|
9
|
+
* OpenRouter provides access to a variety of large language models through a unified API.
|
|
10
|
+
* This implementation uses the OpenAI-compatible interface to connect to OpenRouter's service.
|
|
11
|
+
*
|
|
12
|
+
* Default model: 'openai/gpt-4o'
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* Here's how to create and use an OpenRouter chat model:
|
|
16
|
+
* {@includeCode ../test/open-router-chat-model.test.ts#example-openrouter-chat-model}
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* Here's an example with streaming response:
|
|
20
|
+
* {@includeCode ../test/open-router-chat-model.test.ts#example-openrouter-chat-model-streaming}
|
|
21
|
+
*/
|
|
22
|
+
var OpenRouterChatModel = class extends _aigne_openai.OpenAIChatModel {
|
|
23
|
+
constructor(options) {
|
|
24
|
+
super({
|
|
25
|
+
...options,
|
|
26
|
+
model: options?.model || OPEN_ROUTER_DEFAULT_CHAT_MODEL,
|
|
27
|
+
baseURL: options?.baseURL || OPEN_ROUTER_BASE_URL
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
apiKeyEnvName = "OPEN_ROUTER_API_KEY";
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.OpenRouterChatModel = OpenRouterChatModel;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { OpenAIChatModel,
|
|
1
|
+
import { OpenAIChatModel, OpenAIChatModelOptions } from "@aigne/openai";
|
|
2
|
+
|
|
3
|
+
//#region src/open-router-chat-model.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Implementation of the ChatModel interface for OpenRouter service
|
|
4
6
|
*
|
|
@@ -15,7 +17,10 @@ import { OpenAIChatModel, type OpenAIChatModelOptions } from "@aigne/openai";
|
|
|
15
17
|
* Here's an example with streaming response:
|
|
16
18
|
* {@includeCode ../test/open-router-chat-model.test.ts#example-openrouter-chat-model-streaming}
|
|
17
19
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
declare class OpenRouterChatModel extends OpenAIChatModel {
|
|
21
|
+
constructor(options?: OpenAIChatModelOptions);
|
|
22
|
+
protected apiKeyEnvName: string;
|
|
21
23
|
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { OpenRouterChatModel };
|
|
26
|
+
//# sourceMappingURL=open-router-chat-model.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-router-chat-model.d.cts","names":[],"sources":["../src/open-router-chat-model.ts"],"mappings":";;;;AAqBA;;;;;;;;;;;;;;;cAAa,mBAAA,SAA4B,eAAA;EAAA,YAAA,OAAA,GACjB,sBAAA;EAAA,UAAA,aAAA;AAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { OpenAIChatModel,
|
|
1
|
+
import { OpenAIChatModel, OpenAIChatModelOptions } from "@aigne/openai";
|
|
2
|
+
|
|
3
|
+
//#region src/open-router-chat-model.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Implementation of the ChatModel interface for OpenRouter service
|
|
4
6
|
*
|
|
@@ -15,7 +17,10 @@ import { OpenAIChatModel, type OpenAIChatModelOptions } from "@aigne/openai";
|
|
|
15
17
|
* Here's an example with streaming response:
|
|
16
18
|
* {@includeCode ../test/open-router-chat-model.test.ts#example-openrouter-chat-model-streaming}
|
|
17
19
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
declare class OpenRouterChatModel extends OpenAIChatModel {
|
|
21
|
+
constructor(options?: OpenAIChatModelOptions);
|
|
22
|
+
protected apiKeyEnvName: string;
|
|
21
23
|
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { OpenRouterChatModel };
|
|
26
|
+
//# sourceMappingURL=open-router-chat-model.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-router-chat-model.d.mts","names":[],"sources":["../src/open-router-chat-model.ts"],"mappings":";;;;AAqBA;;;;;;;;;;;;;;;cAAa,mBAAA,SAA4B,eAAA;EAAA,YAAA,OAAA,GACjB,sBAAA;EAAA,UAAA,aAAA;AAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { OpenAIChatModel } from "@aigne/openai";
|
|
2
|
+
|
|
3
|
+
//#region src/open-router-chat-model.ts
|
|
4
|
+
const OPEN_ROUTER_DEFAULT_CHAT_MODEL = "openai/gpt-4o";
|
|
5
|
+
const OPEN_ROUTER_BASE_URL = "https://openrouter.ai/api/v1";
|
|
6
|
+
/**
|
|
7
|
+
* Implementation of the ChatModel interface for OpenRouter service
|
|
8
|
+
*
|
|
9
|
+
* OpenRouter provides access to a variety of large language models through a unified API.
|
|
10
|
+
* This implementation uses the OpenAI-compatible interface to connect to OpenRouter's service.
|
|
11
|
+
*
|
|
12
|
+
* Default model: 'openai/gpt-4o'
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* Here's how to create and use an OpenRouter chat model:
|
|
16
|
+
* {@includeCode ../test/open-router-chat-model.test.ts#example-openrouter-chat-model}
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* Here's an example with streaming response:
|
|
20
|
+
* {@includeCode ../test/open-router-chat-model.test.ts#example-openrouter-chat-model-streaming}
|
|
21
|
+
*/
|
|
22
|
+
var OpenRouterChatModel = class extends OpenAIChatModel {
|
|
23
|
+
constructor(options) {
|
|
24
|
+
super({
|
|
25
|
+
...options,
|
|
26
|
+
model: options?.model || OPEN_ROUTER_DEFAULT_CHAT_MODEL,
|
|
27
|
+
baseURL: options?.baseURL || OPEN_ROUTER_BASE_URL
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
apiKeyEnvName = "OPEN_ROUTER_API_KEY";
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { OpenRouterChatModel };
|
|
35
|
+
//# sourceMappingURL=open-router-chat-model.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-router-chat-model.mjs","names":[],"sources":["../src/open-router-chat-model.ts"],"sourcesContent":["import { OpenAIChatModel, type OpenAIChatModelOptions } from \"@aigne/openai\";\n\nconst OPEN_ROUTER_DEFAULT_CHAT_MODEL = \"openai/gpt-4o\";\nconst OPEN_ROUTER_BASE_URL = \"https://openrouter.ai/api/v1\";\n\n/**\n * Implementation of the ChatModel interface for OpenRouter service\n *\n * OpenRouter provides access to a variety of large language models through a unified API.\n * This implementation uses the OpenAI-compatible interface to connect to OpenRouter's service.\n *\n * Default model: 'openai/gpt-4o'\n *\n * @example\n * Here's how to create and use an OpenRouter chat model:\n * {@includeCode ../test/open-router-chat-model.test.ts#example-openrouter-chat-model}\n *\n * @example\n * Here's an example with streaming response:\n * {@includeCode ../test/open-router-chat-model.test.ts#example-openrouter-chat-model-streaming}\n */\nexport class OpenRouterChatModel extends OpenAIChatModel {\n constructor(options?: OpenAIChatModelOptions) {\n super({\n ...options,\n model: options?.model || OPEN_ROUTER_DEFAULT_CHAT_MODEL,\n baseURL: options?.baseURL || OPEN_ROUTER_BASE_URL,\n });\n }\n\n protected override apiKeyEnvName = \"OPEN_ROUTER_API_KEY\";\n}\n"],"mappings":";;;AAEA,MAAM,iCAAiC;AACvC,MAAM,uBAAuB;;;;;;;;;;;;;;;;;AAkB7B,IAAa,sBAAb,cAAyC,gBAAgB;CACvD,YAAY,SAAkC;AAC5C,QAAM;GACJ,GAAG;GACH,OAAO,SAAS,SAAS;GACzB,SAAS,SAAS,WAAW;GAC9B,CAAC;;CAGJ,AAAmB,gBAAgB"}
|
package/package.json
CHANGED
|
@@ -1,57 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/open-router",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.74.0-beta.1",
|
|
4
4
|
"description": "AIGNE OpenRouter SDK for accessing multiple AI models through a unified API",
|
|
5
|
+
"license": "Elastic-2.0",
|
|
5
6
|
"publishConfig": {
|
|
6
7
|
"access": "public"
|
|
7
8
|
},
|
|
8
9
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
9
10
|
"homepage": "https://www.aigne.io/framework",
|
|
10
|
-
"license": "Elastic-2.0",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "git+https://github.com/
|
|
13
|
+
"url": "git+https://github.com/ArcBlock/aigne-framework"
|
|
14
14
|
},
|
|
15
15
|
"bugs": {
|
|
16
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/ArcBlock/aigne-framework/issues"
|
|
17
|
+
},
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/index.cjs",
|
|
20
|
+
"module": "./dist/index.mjs",
|
|
21
|
+
"types": "./dist/index.d.cts",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": {
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
|
+
"import": "./dist/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./*": "./*"
|
|
17
28
|
},
|
|
18
29
|
"files": [
|
|
19
|
-
"
|
|
20
|
-
"lib/dts",
|
|
21
|
-
"lib/esm",
|
|
30
|
+
"dist",
|
|
22
31
|
"LICENSE",
|
|
23
32
|
"README.md",
|
|
24
33
|
"CHANGELOG.md"
|
|
25
34
|
],
|
|
26
|
-
"type": "module",
|
|
27
|
-
"main": "./lib/cjs/index.js",
|
|
28
|
-
"module": "./lib/esm/index.js",
|
|
29
|
-
"types": "./lib/dts/index.d.ts",
|
|
30
|
-
"exports": {
|
|
31
|
-
".": {
|
|
32
|
-
"import": "./lib/esm/index.js",
|
|
33
|
-
"require": "./lib/cjs/index.js",
|
|
34
|
-
"types": "./lib/dts/index.d.ts"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
35
|
"dependencies": {
|
|
38
|
-
"@aigne/openai": "^
|
|
36
|
+
"@aigne/openai": "^1.74.0-beta.1"
|
|
39
37
|
},
|
|
40
38
|
"devDependencies": {
|
|
41
|
-
"@types/bun": "^1.
|
|
42
|
-
"@types/node": "^24.5.1",
|
|
39
|
+
"@types/bun": "^1.3.6",
|
|
43
40
|
"npm-run-all": "^4.1.5",
|
|
44
|
-
"rimraf": "^6.
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"@aigne/
|
|
41
|
+
"rimraf": "^6.1.2",
|
|
42
|
+
"tsdown": "0.20.0-beta.3",
|
|
43
|
+
"typescript": "5.9.2",
|
|
44
|
+
"@aigne/core": "1.74.0-beta.1",
|
|
45
|
+
"@aigne/scripts": "0.0.0",
|
|
46
|
+
"@aigne/typescript-config": "0.0.0",
|
|
47
|
+
"@aigne/utils": "1.74.0-beta.1"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"clean": "rimraf
|
|
50
|
+
"build": "tsdown",
|
|
51
|
+
"check-types": "tsc --noEmit",
|
|
52
|
+
"clean": "rimraf dist coverage",
|
|
53
53
|
"test": "bun test",
|
|
54
|
-
"test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text"
|
|
55
|
-
"postbuild": "node ../../scripts/post-build-lib.mjs"
|
|
54
|
+
"test:coverage": "bun test --coverage --coverage-reporter=lcov --coverage-reporter=text"
|
|
56
55
|
}
|
|
57
56
|
}
|