@elizaos/plugin-openrouter 1.3.1 → 1.5.13
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 +32 -0
- package/dist/browser/index.browser.js +981 -0
- package/dist/browser/index.browser.js.map +20 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.node.cjs +643 -0
- package/dist/cjs/index.node.js.map +19 -0
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.node.d.ts +2 -0
- package/dist/init.d.ts +6 -0
- package/dist/models/image.d.ts +14 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/object.d.ts +9 -0
- package/dist/models/text.d.ts +17 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/{index.js → node/index.node.js} +192 -119
- package/dist/node/index.node.js.map +19 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/openrouter.d.ts +8 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/utils/config.d.ts +64 -0
- package/dist/utils/events.d.ts +6 -0
- package/dist/utils/helpers.d.ts +29 -0
- package/dist/utils/image-storage.d.ts +8 -0
- package/dist/utils/index.d.ts +2 -0
- package/package.json +34 -20
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ The plugin requires the OpenRouter API key and can be configured via environment
|
|
|
24
24
|
"OPENROUTER_LARGE_MODEL": "google/gemini-pro", // Optional: Overrides default large model
|
|
25
25
|
"OPENROUTER_IMAGE_MODEL": "x-ai/grok-2-vision-1212", // Optional: Overrides default image model
|
|
26
26
|
"OPENROUTER_IMAGE_GENERATION_MODEL": "google/gemini-2.5-flash-image-preview", // Optional: Overrides default image generation model
|
|
27
|
+
"OPENROUTER_BROWSER_BASE_URL": "https://your-proxy.example.com/openrouter"
|
|
27
28
|
// Fallbacks if specific OPENROUTER models are not set
|
|
28
29
|
"SMALL_MODEL": "google/gemini-flash",
|
|
29
30
|
"LARGE_MODEL": "google/gemini-pro",
|
|
@@ -42,6 +43,8 @@ OPENROUTER_SMALL_MODEL=google/gemini-flash
|
|
|
42
43
|
OPENROUTER_LARGE_MODEL=google/gemini-pro
|
|
43
44
|
OPENROUTER_IMAGE_MODEL=x-ai/grok-2-vision-1212
|
|
44
45
|
OPENROUTER_IMAGE_GENERATION_MODEL=google/gemini-2.5-flash-image-preview
|
|
46
|
+
# Browser proxy (frontend builds only)
|
|
47
|
+
OPENROUTER_BROWSER_BASE_URL=https://your-proxy.example.com/openrouter
|
|
45
48
|
# Fallbacks if specific OPENROUTER models are not set
|
|
46
49
|
SMALL_MODEL=google/gemini-flash
|
|
47
50
|
LARGE_MODEL=google/gemini-pro
|
|
@@ -53,6 +56,35 @@ IMAGE_GENERATION_MODEL=google/gemini-2.5-flash-image-preview
|
|
|
53
56
|
|
|
54
57
|
- `OPENROUTER_API_KEY` (required): Your OpenRouter API key.
|
|
55
58
|
- `OPENROUTER_BASE_URL`: Custom API endpoint (default: https://openrouter.ai/api/v1).
|
|
59
|
+
- `OPENROUTER_BROWSER_BASE_URL`: Browser-only base URL to a proxy endpoint that forwards requests to OpenRouter without exposing keys.
|
|
60
|
+
### Browser mode and proxying
|
|
61
|
+
|
|
62
|
+
When bundled for the browser, this plugin avoids sending Authorization headers. Set `OPENROUTER_BROWSER_BASE_URL` to a server-side proxy you control that injects the OpenRouter API key. This prevents exposing secrets in frontend builds.
|
|
63
|
+
|
|
64
|
+
Example minimal proxy (Express):
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import express from 'express';
|
|
68
|
+
import fetch from 'node-fetch';
|
|
69
|
+
|
|
70
|
+
const app = express();
|
|
71
|
+
app.use(express.json());
|
|
72
|
+
|
|
73
|
+
app.post('/openrouter/*', async (req, res) => {
|
|
74
|
+
const url = `https://openrouter.ai/api/v1/${req.params[0]}`;
|
|
75
|
+
const r = await fetch(url, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: {
|
|
78
|
+
'Authorization': `Bearer ${process.env.OPENROUTER_API_KEY}`,
|
|
79
|
+
'Content-Type': 'application/json',
|
|
80
|
+
},
|
|
81
|
+
body: JSON.stringify(req.body),
|
|
82
|
+
});
|
|
83
|
+
res.status(r.status).set(Object.fromEntries(r.headers)).send(await r.text());
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
app.listen(3000);
|
|
87
|
+
```
|
|
56
88
|
- `OPENROUTER_SMALL_MODEL`: Specific model to use for `TEXT_SMALL` and `OBJECT_SMALL`. Overrides `SMALL_MODEL` if set.
|
|
57
89
|
- `OPENROUTER_LARGE_MODEL`: Specific model to use for `TEXT_LARGE` and `OBJECT_LARGE`. Overrides `LARGE_MODEL` if set.
|
|
58
90
|
- `OPENROUTER_IMAGE_MODEL`: Specific model to use for `IMAGE_DESCRIPTION`. Overrides `IMAGE_MODEL` if set.
|