@aigne/open-router 0.6.2 → 0.6.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.6.4](https://github.com/AIGNE-io/aigne-framework/compare/open-router-v0.6.3...open-router-v0.6.4) (2025-07-14)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **deps:** update deps to latest version ([#247](https://github.com/AIGNE-io/aigne-framework/issues/247)) ([3972f88](https://github.com/AIGNE-io/aigne-framework/commit/3972f887a9abff20c26da6b51c1071cbd54c0bf1))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/openai bumped to 0.9.1
16
+ * devDependencies
17
+ * @aigne/core bumped to 1.33.1
18
+ * @aigne/test-utils bumped to 0.5.6
19
+
20
+ ## [0.6.3](https://github.com/AIGNE-io/aigne-framework/compare/open-router-v0.6.2...open-router-v0.6.3) (2025-07-10)
21
+
22
+
23
+ ### Dependencies
24
+
25
+ * The following workspace dependencies were updated
26
+ * dependencies
27
+ * @aigne/openai bumped to 0.9.0
28
+ * devDependencies
29
+ * @aigne/core bumped to 1.33.0
30
+ * @aigne/test-utils bumped to 0.5.5
31
+
3
32
  ## [0.6.2](https://github.com/AIGNE-io/aigne-framework/compare/open-router-v0.6.1...open-router-v0.6.2) (2025-07-09)
4
33
 
5
34
 
package/README.md CHANGED
@@ -6,8 +6,6 @@
6
6
  [![NPM Version](https://img.shields.io/npm/v/@aigne/open-router)](https://www.npmjs.com/package/@aigne/open-router)
7
7
  [![Elastic-2.0 licensed](https://img.shields.io/npm/l/@aigne/open-router)](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE.md)
8
8
 
9
- **English** | [中文](README.zh.md)
10
-
11
9
  AIGNE OpenRouter SDK for accessing multiple AI models through a unified API within the [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework).
12
10
 
13
11
  ## Introduction
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/open-router",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "AIGNE OpenRouter SDK for accessing multiple AI models through a unified API",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -32,16 +32,16 @@
32
32
  }
33
33
  },
34
34
  "dependencies": {
35
- "@aigne/openai": "^0.8.2"
35
+ "@aigne/openai": "^0.9.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/bun": "^1.2.17",
39
- "@types/node": "^24.0.10",
38
+ "@types/bun": "^1.2.18",
39
+ "@types/node": "^24.0.12",
40
40
  "npm-run-all": "^4.1.5",
41
41
  "rimraf": "^6.0.1",
42
42
  "typescript": "^5.8.3",
43
- "@aigne/core": "^1.32.2",
44
- "@aigne/test-utils": "^0.5.4"
43
+ "@aigne/core": "^1.33.1",
44
+ "@aigne/test-utils": "^0.5.6"
45
45
  },
46
46
  "scripts": {
47
47
  "lint": "tsc --noEmit",
package/README.zh.md DELETED
@@ -1,135 +0,0 @@
1
- # @aigne/open-router
2
-
3
- [![GitHub star chart](https://img.shields.io/github/stars/AIGNE-io/aigne-framework?style=flat-square)](https://star-history.com/#AIGNE-io/aigne-framework)
4
- [![Open Issues](https://img.shields.io/github/issues-raw/AIGNE-io/aigne-framework?style=flat-square)](https://github.com/AIGNE-io/aigne-framework/issues)
5
- [![codecov](https://codecov.io/gh/AIGNE-io/aigne-framework/graph/badge.svg?token=DO07834RQL)](https://codecov.io/gh/AIGNE-io/aigne-framework)
6
- [![NPM Version](https://img.shields.io/npm/v/@aigne/open-router)](https://www.npmjs.com/package/@aigne/open-router)
7
- [![Elastic-2.0 licensed](https://img.shields.io/npm/l/@aigne/open-router)](https://github.com/AIGNE-io/aigne-framework/blob/main/LICENSE.md)
8
-
9
- [English](README.md) | **中文**
10
-
11
- AIGNE OpenRouter SDK,用于在 [AIGNE 框架](https://github.com/AIGNE-io/aigne-framework) 中通过统一 API 访问多种 AI 模型。
12
-
13
- ## 简介
14
-
15
- `@aigne/open-router` 提供了 AIGNE 框架与 OpenRouter 统一 API 之间的无缝集成,用于访问各种 AI 模型。该包使开发者能够通过单一一致的接口轻松使用来自多个提供商(包括 OpenAI、Anthropic、Google 等)的模型,允许灵活的模型选择和备选方案。
16
-
17
- ## 特性
18
-
19
- * **OpenRouter API 集成**:直接连接到 OpenRouter 的 API 服务
20
- * **多提供商访问**:可访问来自 OpenAI、Anthropic、Claude、Google 等多家提供商的模型
21
- * **统一接口**:为所有模型提供一致的接口,无论其来源
22
- * **模型备选**:轻松配置不同模型之间的备选选项
23
- * **聊天完成**:支持所有可用模型的聊天完成 API
24
- * **流式响应**:支持流式响应,提供更高响应性的应用程序体验
25
- * **类型安全**:为所有 API 和模型提供全面的 TypeScript 类型定义
26
- * **一致接口**:兼容 AIGNE 框架的模型接口
27
- * **错误处理**:健壮的错误处理和重试机制
28
- * **完整配置**:丰富的配置选项用于微调行为
29
-
30
- ## 安装
31
-
32
- ### 使用 npm
33
-
34
- ```bash
35
- npm install @aigne/open-router @aigne/core
36
- ```
37
-
38
- ### 使用 yarn
39
-
40
- ```bash
41
- yarn add @aigne/open-router @aigne/core
42
- ```
43
-
44
- ### 使用 pnpm
45
-
46
- ```bash
47
- pnpm add @aigne/open-router @aigne/core
48
- ```
49
-
50
- ## 基本用法
51
-
52
- ```typescript file="test/open-router-chat-model.test.ts" region="example-openrouter-chat-model"
53
- import { OpenRouterChatModel } from "@aigne/open-router";
54
-
55
- const model = new OpenRouterChatModel({
56
- // Provide API key directly or use environment variable OPEN_ROUTER_API_KEY
57
- apiKey: "your-api-key", // Optional if set in env variables
58
- // Specify model (defaults to 'openai/gpt-4o')
59
- model: "anthropic/claude-3-opus",
60
- modelOptions: {
61
- temperature: 0.7,
62
- },
63
- });
64
-
65
- const result = await model.invoke({
66
- messages: [{ role: "user", content: "Which model are you using?" }],
67
- });
68
-
69
- console.log(result);
70
- /* Output:
71
- {
72
- text: "I'm powered by OpenRouter, using the Claude 3 Opus model from Anthropic.",
73
- model: "anthropic/claude-3-opus",
74
- usage: {
75
- inputTokens: 5,
76
- outputTokens: 14
77
- }
78
- }
79
- */
80
- ```
81
-
82
- ## 使用多模型备选
83
-
84
- ```typescript
85
- const modelWithFallbacks = new OpenRouterChatModel({
86
- apiKey: "your-api-key",
87
- model: "openai/gpt-4o",
88
- fallbackModels: ["anthropic/claude-3-opus", "google/gemini-1.5-pro"], // 备选顺序
89
- modelOptions: {
90
- temperature: 0.7,
91
- },
92
- });
93
-
94
- // 将首先尝试 gpt-4o,如果失败则尝试 claude-3-opus,如果再失败则尝试 gemini-1.5-pro
95
- const fallbackResult = await modelWithFallbacks.invoke({
96
- messages: [{ role: "user", content: "Which model are you using?" }],
97
- });
98
- ```
99
-
100
- ## 流式响应
101
-
102
- ```typescript file="test/open-router-chat-model.test.ts" region="example-openrouter-chat-model-streaming"
103
- import { isAgentResponseDelta } from "@aigne/core";
104
- import { OpenRouterChatModel } from "@aigne/open-router";
105
-
106
- const model = new OpenRouterChatModel({
107
- apiKey: "your-api-key",
108
- model: "anthropic/claude-3-opus",
109
- });
110
-
111
- const stream = await model.invoke(
112
- {
113
- messages: [{ role: "user", content: "Which model are you using?" }],
114
- },
115
- { streaming: true },
116
- );
117
-
118
- let fullText = "";
119
- const json = {};
120
-
121
- for await (const chunk of stream) {
122
- if (isAgentResponseDelta(chunk)) {
123
- const text = chunk.delta.text?.text;
124
- if (text) fullText += text;
125
- if (chunk.delta.json) Object.assign(json, chunk.delta.json);
126
- }
127
- }
128
-
129
- console.log(fullText); // Output: "I'm powered by OpenRouter, using the Claude 3 Opus model from Anthropic."
130
- console.log(json); // { model: "anthropic/claude-3-opus", usage: { inputTokens: 5, outputTokens: 14 } }
131
- ```
132
-
133
- ## 许可证
134
-
135
- Elastic-2.0