@lizzard-solutions/node-red-contrib-openrouter
v0.0.2
Published
Node-RED nodes to interact with the OpenRouter API
Downloads
7
Maintainers
Readme
node-red-contrib-openrouter
A collection of Node-RED nodes for working with the OpenRouter API. This package centralizes model selection via a shared config node and provides chat, routing, ranking, evaluation, embeddings, memory, formatting, tools orchestration, and a simple in-memory vector store.
Features
- Shared config node (
openrouter-config) is the single source of truth for model and API key - Chat completions (
openrouter-chat) - Embeddings (
openrouter-embedding) - Router/classifier (
openrouter-router) - Ranker (
openrouter-ranker) - Evaluator/LLM-based scoring (
openrouter-evaluator) - Conversation memory with optional summarization (
openrouter-memory) - Cost tracker (
openrouter-cost-tracker) - Prompt templating (
openrouter-prompt) and content formatter (openrouter-formatter) - Multi-agent orchestrator (
openrouter-orchestrator) - Basic vector-store node (
openrouter-vector-store) for demos - Utilities (
openrouter-tools)
All nodes use the shared openrouter-config for the model. Per-node model inputs and defaults have been removed.
Installation
cd ~/.node-red
npm install node-red-contrib-openrouterRestart Node-RED after install. The nodes will appear under the "OpenRouter" category.
Repository layout
node-red-contrib-openrouter/
├─ src/ # All Node-RED nodes (html/js pairs)
│ ├─ openrouter-config.* # Shared config node (keep model/API key here)
│ ├─ openrouter-chat.*
│ ├─ openrouter-embedding.*
│ ├─ openrouter-router.*
│ ├─ openrouter-ranker.*
│ ├─ openrouter-evaluator.*
│ ├─ openrouter-memory.*
│ ├─ openrouter-orchestrator.*
│ ├─ openrouter-cost-tracker.*
│ ├─ openrouter-formatter.*
│ ├─ openrouter-prompt.*
│ ├─ openrouter-tools.*
│ └─ openrouter-vector-store.*
├─ examples/
│ └─ example_flow.json # Importable Node-RED flow
├─ package.json
└─ README.mdConfigure the shared config node
- Drag
openrouter-configinto your workspace (or open it from any node that references it). - Enter your OpenRouter API key.
- Set the model (e.g.,
openai/gpt-4o-mini). - Optionally set
siteUrlandsiteNameheaders for OpenRouter attribution.
If the model is not set in openrouter-config, runtime nodes will error with:
"No model specified. Set a model in the shared config"
Node overview
openrouter-chat: Chat completion. Input:msg.payload(string) ormsg.messages(array). Output:msg.payloadtext,msg.responseraw.openrouter-embedding: Embeddings for a string or array. Output:msg.embedding(single) ormsg.embeddings(array), plusmsg.usage.openrouter-router: Classifiesmsg.payloadinto one of N routes -> dynamic outputs based on descriptions you define.openrouter-ranker: Ranks candidate responses inmsg.candidatesand selects the best intomsg.payload.openrouter-evaluator: Evaluatesmsg.payloadwith criteria prompt and returns score/validation/JSON.openrouter-memory: Maintains per-session history buffer; optional summarization via shared model.openrouter-orchestrator: Chains/parallelizes multiple agent steps using the shared model.openrouter-cost-tracker: Estimates cost based on token usage; adjustable rates.openrouter-prompt: Simple templating helper.openrouter-formatter: Convert markdown to HTML, etc.openrouter-tools: Misc utilities used by other nodes.openrouter-vector-store: In-memory demo store withstore,retrieve, andclearactions.
Breaking changes in this version
- Removed per-node “Model” fields from all nodes. The shared
openrouter-confignode is now the only place to set the model. - Nodes validate at runtime and will error if the shared model is missing.
Environment variables
You can set the OpenRouter API key via Node-RED credentials UI on openrouter-config. If you prefer environment variables, wire that into the config UI using Node-RED’s built-in env usage patterns.
Development
- All node sources are in
src/. Each node has a.htmleditor file and a.jsruntime file. - After making changes, run Node-RED in development and reload the editor.
- Linting/formatting should follow repository settings.
Contributing
PRs welcome! Please include:
- Clear description and rationale
- Tests or flows showing the behavior
- Avoid reintroducing per-node model configuration
License
MIT
