@alisio/plugin-openrouter 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gustavo Gutiérrez
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # @alisio/plugin-openrouter
2
+
3
+ OpenRouter model provider for Alisio (`openrouter`). Install with `alisio install npm:@alisio/plugin-openrouter`, then connect with an API key or `OPENROUTER_API_KEY`; a stored key wins over the environment variable.
4
+
5
+ `openrouter/free` is the documented catalog and provider fallback. Alisio's host must still choose the active model: the SDK has no registration-level default selection. The plugin streams text, tools, usage, safe provider-visible reasoning, and preserves opaque `reasoning_details` for continuation.
6
+
7
+ It uses the fixed `https://openrouter.ai/api/v1` endpoint and sends no default attribution headers in v1 to preserve user privacy. Model inventory is an in-memory cache only.
8
+
9
+ ## License
10
+
11
+ MIT.
package/cover.svg ADDED
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="1600" height="900" viewBox="0 0 1600 900" role="img" aria-label="OpenRouter provider cover">
2
+ <defs><linearGradient id="a" x1="0" y1="0" x2="1" y2="1"><stop stop-color="#1f173d"/><stop offset="1" stop-color="#8250b8"/></linearGradient></defs>
3
+ <rect width="1600" height="900" fill="url(#a)"/><path d="M1060 250h360l-120 200 120 200h-360l120-200z" fill="none" stroke="#f0d6ff" stroke-width="32"/>
4
+ <text x="120" y="300" fill="#f0d6ff" font-family="system-ui" font-size="30" letter-spacing="8">ALISIO PLUGIN</text><text x="120" y="440" fill="white" font-family="system-ui" font-size="112" font-weight="700">OpenRouter</text><text x="120" y="520" fill="#f2e8fb" font-family="system-ui" font-size="40">OpenAI-compatible provider</text>
5
+ </svg>
@@ -0,0 +1,6 @@
1
+ import { type Plugin } from "@alisio/sdk";
2
+ export declare function createOpenRouterPlugin(): Plugin;
3
+ export { OpenRouterProvider } from "./provider.js";
4
+ declare const _default: Plugin;
5
+ export default _default;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAA8B,MAAM,aAAa,CAAC;AASpF,wBAAgB,sBAAsB,IAAI,MAAM,CAgD/C;AACD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ import { definePlugin } from "@alisio/sdk";
2
+ import { OpenRouterProvider } from "./provider.js";
3
+ import { VERSION } from "./version.js";
4
+ const DEFAULT_ENV = "OPENROUTER_API_KEY";
5
+ const envName = (request) => typeof request.profile.apiKeyEnv === "string" && request.profile.apiKeyEnv.trim()
6
+ ? request.profile.apiKeyEnv.trim()
7
+ : DEFAULT_ENV;
8
+ export function createOpenRouterPlugin() {
9
+ return definePlugin({
10
+ id: "openrouter",
11
+ name: "OpenRouter",
12
+ description: "OpenRouter OpenAI-compatible provider",
13
+ categories: ["model-provider"],
14
+ version: VERSION,
15
+ apiVersion: 1,
16
+ setup(api) {
17
+ api.providers.register({
18
+ id: "openrouter",
19
+ name: "OpenRouter",
20
+ description: "OpenRouter Chat Completions API",
21
+ fields: [
22
+ {
23
+ key: "apiKey",
24
+ label: "API key",
25
+ kind: "secret",
26
+ required: true,
27
+ description: "Stored only in the global credentials file",
28
+ },
29
+ {
30
+ key: "apiKeyEnv",
31
+ label: "API key environment variable",
32
+ kind: "text",
33
+ required: false,
34
+ defaultValue: DEFAULT_ENV,
35
+ description: "Used only when no stored API key exists",
36
+ },
37
+ ],
38
+ create(request) {
39
+ const name = envName(request);
40
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name))
41
+ throw new Error("API key environment variable name is invalid");
42
+ const apiKey = request.credentials.apiKey || process.env[name];
43
+ if (!apiKey)
44
+ throw new Error(`OpenRouter API key is required (set it in /connect or export ${name})`);
45
+ return new OpenRouterProvider({
46
+ apiKey,
47
+ model: typeof request.profile.model === "string" ? request.profile.model : "openrouter/free",
48
+ });
49
+ },
50
+ });
51
+ },
52
+ });
53
+ }
54
+ export { OpenRouterProvider } from "./provider.js";
55
+ export default createOpenRouterPlugin();
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA2C,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,WAAW,GAAG,oBAAoB,CAAC;AACzC,MAAM,OAAO,GAAG,CAAC,OAA8B,EAAE,EAAE,CACjD,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,KA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AAC;oBACJ,OAAO,IAAI,kBAAkB,CAAC;wBAC5B,MAAM;wBACN,KAAK,EACH,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB;qBACxF,CAAC,CAAC;gBACL,CAAC;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AACD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,eAAe,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ModelInfo, ModelProvider, ProviderEvent } from "@alisio/sdk";
2
+ import OpenAI from "openai";
3
+ export declare class OpenRouterProvider implements ModelProvider {
4
+ #private;
5
+ readonly id = "openrouter";
6
+ readonly model: string;
7
+ constructor(config: {
8
+ apiKey?: string;
9
+ model: string;
10
+ }, client?: OpenAI);
11
+ listModels(signal: AbortSignal): Promise<ModelInfo[]>;
12
+ stream(request: Parameters<ModelProvider["stream"]>[0]): AsyncIterable<ProviderEvent>;
13
+ }
14
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,SAAS,EACT,aAAa,EACb,aAAa,EAGd,MAAM,aAAa,CAAC;AACrB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAgC5B,qBAAa,kBAAmB,YAAW,aAAa;;IACtD,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAGvB,YAAY,MAAM,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,CAAC,EAAE,MAAM,EAMtE;IACK,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CA0B1D;IACM,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,CA2H3F;CACF"}
@@ -0,0 +1,173 @@
1
+ import OpenAI from "openai";
2
+ const BASE_URL = "https://openrouter.ai/api/v1";
3
+ const TTL = 5 * 60_000;
4
+ const FALLBACK = { id: "openrouter/free", name: "OpenRouter Free" };
5
+ const image = (a) => `data:${a.mimeType};base64,${a.data}`;
6
+ const stringify = (value) => JSON.stringify(value);
7
+ export class OpenRouterProvider {
8
+ id = "openrouter";
9
+ model;
10
+ #client;
11
+ #catalog;
12
+ constructor(config, client) {
13
+ this.model = config.model || "openrouter/free";
14
+ if (!client && !config.apiKey)
15
+ throw new Error("Missing OpenRouter API key");
16
+ this.#client =
17
+ client ??
18
+ new OpenAI({ apiKey: config.apiKey, baseURL: BASE_URL, maxRetries: 0, timeout: 120_000 });
19
+ }
20
+ async listModels(signal) {
21
+ if (this.#catalog && this.#catalog.expires > Date.now())
22
+ return this.#catalog.models;
23
+ try {
24
+ const result = [];
25
+ for await (const m of this.#client.models.list({ signal })) {
26
+ const x = m;
27
+ if (typeof x.id !== "string" || !x.id)
28
+ continue;
29
+ const modalities = Array.isArray(x.architecture?.input_modalities)
30
+ ? x.architecture.input_modalities.filter((v) => typeof v === "string")
31
+ : undefined;
32
+ result.push({
33
+ id: x.id,
34
+ ...(typeof x.name === "string" ? { name: x.name } : {}),
35
+ ...(typeof x.context_length === "number" && x.context_length > 0
36
+ ? { contextWindow: x.context_length }
37
+ : {}),
38
+ ...(modalities?.length ? { inputModalities: modalities } : {}),
39
+ });
40
+ if (result.length >= 1000)
41
+ break;
42
+ }
43
+ if (!result.some((m) => m.id === FALLBACK.id))
44
+ result.unshift(FALLBACK);
45
+ this.#catalog = { expires: Date.now() + TTL, models: result };
46
+ return result;
47
+ }
48
+ catch {
49
+ return this.#catalog?.models ?? [FALLBACK];
50
+ }
51
+ }
52
+ async *stream(request) {
53
+ const messages = [
54
+ { role: "system", content: request.instructions },
55
+ ];
56
+ for (const m of request.messages) {
57
+ if (m.role === "user")
58
+ messages.push(m.attachments?.length
59
+ ? {
60
+ role: "user",
61
+ content: [
62
+ { type: "text", text: m.text },
63
+ ...m.attachments.map((a) => ({
64
+ type: "image_url",
65
+ image_url: { url: image(a) },
66
+ })),
67
+ ],
68
+ }
69
+ : { role: "user", content: m.text });
70
+ else if (m.role === "tool")
71
+ messages.push({ role: "tool", tool_call_id: m.callId, content: stringify(m.result) });
72
+ else {
73
+ const assistant = {
74
+ role: "assistant",
75
+ content: m.text || null,
76
+ ...(m.calls.length
77
+ ? {
78
+ tool_calls: m.calls.map((c) => ({
79
+ id: c.id,
80
+ type: "function",
81
+ function: { name: c.name, arguments: c.arguments },
82
+ })),
83
+ }
84
+ : {}),
85
+ ...(m.providerData?.length ? { reasoning_details: m.providerData } : {}),
86
+ };
87
+ messages.push(assistant);
88
+ }
89
+ }
90
+ const stream = await this.#client.chat.completions.create({
91
+ model: request.model || this.model,
92
+ messages,
93
+ stream: true,
94
+ stream_options: { include_usage: true },
95
+ max_completion_tokens: request.maxOutputTokens,
96
+ ...(request.tools.length
97
+ ? {
98
+ tools: request.tools.map((t) => ({
99
+ type: "function",
100
+ function: { name: t.name, description: t.description, parameters: t.inputSchema },
101
+ })),
102
+ }
103
+ : {}),
104
+ }, { signal: request.signal });
105
+ let text = "", finish = null, usage;
106
+ const calls = new Map();
107
+ const reasoning = [];
108
+ for await (const rawChunk of stream) {
109
+ const chunk = rawChunk;
110
+ if (chunk?.error)
111
+ throw new Error(typeof chunk.error.message === "string"
112
+ ? `OpenRouter stream error: ${chunk.error.message}`
113
+ : "OpenRouter stream error");
114
+ const chunkUsage = chunk.usage;
115
+ if (chunkUsage &&
116
+ Number.isFinite(chunkUsage.prompt_tokens) &&
117
+ Number.isFinite(chunkUsage.completion_tokens)) {
118
+ const cachedInput = chunkUsage.prompt_tokens_details?.cached_tokens;
119
+ usage = {
120
+ input: chunkUsage.prompt_tokens,
121
+ output: chunkUsage.completion_tokens,
122
+ ...(typeof cachedInput === "number" && Number.isFinite(cachedInput)
123
+ ? { cachedInput }
124
+ : {}),
125
+ };
126
+ }
127
+ const choice = chunk?.choices?.[0];
128
+ if (!choice)
129
+ continue;
130
+ if (typeof choice.delta?.content === "string") {
131
+ text += choice.delta.content;
132
+ yield { type: "text_delta", delta: choice.delta.content };
133
+ }
134
+ if (typeof choice.delta?.reasoning === "string")
135
+ yield { type: "reasoning_delta", delta: choice.delta.reasoning };
136
+ if (Array.isArray(choice.delta?.reasoning_details))
137
+ reasoning.push(...choice.delta.reasoning_details);
138
+ if (choice.delta?.refusal)
139
+ throw new Error("OpenRouter provider refusal");
140
+ for (const part of choice.delta?.tool_calls ?? []) {
141
+ const call = calls.get(part.index) ?? { id: "", name: "", arguments: "" };
142
+ if (typeof part.id === "string")
143
+ call.id = part.id;
144
+ if (typeof part.function?.name === "string")
145
+ call.name += part.function.name;
146
+ if (typeof part.function?.arguments === "string")
147
+ call.arguments += part.function.arguments;
148
+ calls.set(part.index, call);
149
+ }
150
+ if (typeof choice.finish_reason === "string")
151
+ finish = choice.finish_reason;
152
+ }
153
+ if (!["stop", "tool_calls", "length"].includes(finish ?? ""))
154
+ throw new Error(`OpenRouter response incomplete: ${finish ?? "stream ended"}`);
155
+ const complete = [...calls.entries()].sort(([a], [b]) => a - b).map(([, c]) => c);
156
+ if (complete.some((c) => !c.id || !c.name))
157
+ throw new Error("Incomplete tool call");
158
+ if (finish === "length" && !text.trim())
159
+ throw new Error("OpenRouter response cut off before usable content");
160
+ yield {
161
+ type: "completed",
162
+ message: {
163
+ role: "assistant",
164
+ text,
165
+ calls: complete,
166
+ ...(reasoning.length ? { providerData: reasoning } : {}),
167
+ ...(finish === "length" ? { truncated: true } : {}),
168
+ },
169
+ ...(usage ? { usage } : {}),
170
+ };
171
+ }
172
+ }
173
+ //# sourceMappingURL=provider.js.map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I,EAAE,WAAW;gBACjB,IAAI;gBACJ,KAAK,EAAE,QAAQ;gBACf,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxD,GAAG,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpD;YACD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare const VERSION = "0.1.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,OAAO,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ // Updated by scripts/sync-versions.mjs.
2
+ export const VERSION = "0.1.0";
3
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@alisio/plugin-openrouter",
3
+ "version": "0.1.0",
4
+ "description": "OpenRouter OpenAI-compatible model provider for Alisio.",
5
+ "keywords": [
6
+ "alisio-plugin",
7
+ "openrouter",
8
+ "model-provider"
9
+ ],
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/GustavoGutierrez/alisio-plugins.git",
14
+ "directory": "packages/plugin-openrouter"
15
+ },
16
+ "homepage": "https://github.com/GustavoGutierrez/alisio-plugins/tree/main/packages/plugin-openrouter#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/GustavoGutierrez/alisio-plugins/issues"
19
+ },
20
+ "type": "module",
21
+ "engines": {
22
+ "node": ">=22.16"
23
+ },
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "README.md",
33
+ "LICENSE",
34
+ "cover.svg"
35
+ ],
36
+ "dependencies": {
37
+ "openai": "7.23.0"
38
+ },
39
+ "peerDependencies": {
40
+ "@alisio/sdk": ">=0.1.0-alpha.10 <0.2.0"
41
+ },
42
+ "devDependencies": {
43
+ "@alisio/sdk": "0.1.0-alpha.11",
44
+ "typescript": "7.0.2",
45
+ "vitest": "5.0.1"
46
+ },
47
+ "scripts": {
48
+ "build": "tsc -p tsconfig.json",
49
+ "typecheck": "tsc -p tsconfig.json --noEmit",
50
+ "test": "vitest run"
51
+ }
52
+ }