@inductiv/node-red-openai-api 1.103.0 → 6.22.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/README.md +165 -95
- package/examples/responses/mcp.json +1 -1
- package/lib.js +7035 -13298
- package/locales/en-US/node.json +49 -1
- package/node.html +1526 -981
- package/node.js +194 -54
- package/package.json +8 -7
- package/src/assistants/help.html +1 -77
- package/src/audio/help.html +1 -37
- package/src/batch/help.html +3 -17
- package/src/chat/help.html +11 -89
- package/src/container-files/help.html +1 -27
- package/src/containers/help.html +8 -18
- package/src/conversations/help.html +135 -0
- package/src/conversations/methods.js +73 -0
- package/src/conversations/template.html +10 -0
- package/src/embeddings/help.html +1 -11
- package/src/evals/help.html +249 -0
- package/src/evals/methods.js +114 -0
- package/src/evals/template.html +14 -0
- package/src/files/help.html +4 -17
- package/src/fine-tuning/help.html +1 -35
- package/src/images/help.html +1 -45
- package/src/lib.js +53 -1
- package/src/messages/help.html +19 -39
- package/src/messages/methods.js +13 -0
- package/src/messages/template.html +7 -18
- package/src/models/help.html +1 -5
- package/src/moderations/help.html +1 -5
- package/src/node.html +126 -37
- package/src/realtime/help.html +129 -0
- package/src/realtime/methods.js +45 -0
- package/src/realtime/template.html +7 -0
- package/src/responses/help.html +203 -61
- package/src/responses/methods.js +49 -16
- package/src/responses/template.html +16 -1
- package/src/runs/help.html +1 -123
- package/src/skills/help.html +183 -0
- package/src/skills/methods.js +99 -0
- package/src/skills/template.html +13 -0
- package/src/threads/help.html +1 -15
- package/src/uploads/help.html +1 -21
- package/src/vector-store-file-batches/help.html +1 -27
- package/src/vector-store-file-batches/methods.js +5 -5
- package/src/vector-store-files/help.html +1 -25
- package/src/vector-store-files/methods.js +4 -7
- package/src/vector-stores/help.html +2 -31
- package/src/vector-stores/methods.js +5 -11
- package/src/vector-stores/template.html +7 -22
- package/src/videos/help.html +113 -0
- package/src/videos/methods.js +50 -0
- package/src/videos/template.html +8 -0
- package/src/webhooks/help.html +61 -0
- package/src/webhooks/methods.js +40 -0
- package/src/webhooks/template.html +4 -0
- package/test/openai-methods-mapping.test.js +1220 -0
- package/test/openai-node-auth-routing.test.js +203 -0
- package/test/service-host-editor-template.test.js +53 -0
- package/test/service-host-node.test.js +182 -0
- package/test/services.test.js +147 -0
- package/test/utils.test.js +75 -0
package/README.md
CHANGED
|
@@ -1,125 +1,195 @@
|
|
|
1
1
|
# @inductiv/node-red-openai-api
|
|
2
2
|
|
|
3
|
-

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
Node-RED node for calling the OpenAI API (and OpenAI-compatible APIs) through a single configurable node.
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
<img width="265" alt="node-red-openai-api-node" src="https://github.com/allanbunch/node-red-openai-api/assets/4503640/ee954c8e-fbf4-4812-a38a-f047cecd1982">
|
|
9
|
-
</a>
|
|
10
|
-
<br>
|
|
9
|
+
This package currently targets `openai` Node SDK `^6.22.0`.
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
## What You Get
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
- One `OpenAI API` node with method selection across major API families.
|
|
14
|
+
- One `Service Host` config node for base URL, auth, and org settings.
|
|
15
|
+
- Typed input support for key config fields: `str`, `env`, `msg`, `flow`, `global` (plus `cred` for API key).
|
|
16
|
+
- Backward compatibility handling for older API key storage patterns.
|
|
17
|
+
- Built-in examples for common flows.
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
## Requirements
|
|
20
|
+
|
|
21
|
+
- Node.js `>=18.0.0`
|
|
22
|
+
- Node-RED `>=3.0.0`
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
### Node-RED Palette Manager
|
|
17
27
|
|
|
18
28
|
```text
|
|
19
29
|
@inductiv/node-red-openai-api
|
|
20
30
|
```
|
|
21
31
|
|
|
22
|
-
###
|
|
32
|
+
### npm
|
|
23
33
|
|
|
24
34
|
```bash
|
|
25
|
-
cd $HOME/.node-red
|
|
35
|
+
cd $HOME/.node-red
|
|
26
36
|
npm i @inductiv/node-red-openai-api
|
|
27
37
|
```
|
|
28
38
|
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
After installation, find your node in the **AI** palette category labeled "OpenAI API". Here's how you can start integrating AI into your IoT projects:
|
|
32
|
-
|
|
33
|
-
1. Configure the node with your AI platform's API key (if required).
|
|
34
|
-
2. Send [OpenAI documented](https://platform.openai.com/docs/api-reference/) API service configuration paramaters to the node using the default `msg.payload` property, or confiure your desired incoming object property reference on the node itself.
|
|
35
|
-
3. Explore the [examples](./examples/) directory for sample implementations.
|
|
36
|
-
|
|
37
|
-
## Core Features
|
|
38
|
-
|
|
39
|
-
- **Seamless Integration**: Connect directly with OpenAI API compatible services without the hassle of complex coding or setup. Ideal for rapid prototyping and deployment in IoT contexts.
|
|
40
|
-
- **Configurable and Flexible**: Adapt to a wide range of project requirements, making it easy to integrate AI into your IoT solutions.
|
|
41
|
-
- **Powerful Combinations**: Utilize Node-RED's diverse nodes to build complex, AI-driven IoT workflows with ease.
|
|
42
|
-
|
|
43
|
-
## Release Notes (v1.103.0)
|
|
44
|
-
|
|
45
|
-
### Ehancements
|
|
46
|
-
|
|
47
|
-
- Upgraded the OpenAI API Library dependency from [v4.89.0](https://github.com/openai/openai-node/releases/tag/v4.89.0) to [v4.103.0](https://github.com/openai/openai-node/releases/tag/v4.103.0)
|
|
48
|
-
|
|
49
|
-
### Notable Features & Changes
|
|
39
|
+
## Quick Start
|
|
50
40
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
-
|
|
41
|
+
1. Drop an `OpenAI API` node onto your flow.
|
|
42
|
+
2. In the node editor, use the `Service Host` field to either select an existing config node or create one with the `+` button.
|
|
43
|
+
3. In that `Service Host` config, set `API Base` (default: `https://api.openai.com/v1`).
|
|
44
|
+
4. Set `API Key`:
|
|
45
|
+
- `cred` type for a masked credential value, or
|
|
46
|
+
- `env/msg/flow/global` and provide a reference name.
|
|
47
|
+
5. Back in the `OpenAI API` node, select your method (for example `create model response`).
|
|
48
|
+
6. Send request params in `msg.payload` (or change the input property on the node).
|
|
56
49
|
|
|
57
|
-
|
|
50
|
+
Example `msg.payload` for `create model response`:
|
|
58
51
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## OpenAI API Compatible Servers
|
|
67
|
-
|
|
68
|
-
Node-RED OpenAI API Works with your favorite OpenAI API compatible servers, including:
|
|
69
|
-
|
|
70
|
-
- [Baseten](https://www.baseten.co/)
|
|
71
|
-
- [Cloudflare Workers AI](https://developers.cloudflare.com/workers-ai/)
|
|
72
|
-
- [gpt4all](https://github.com/nomic-ai/gpt4all)
|
|
73
|
-
- [Google AI Studio](https://ai.google.dev/gemini-api/docs/openai#node.js)
|
|
74
|
-
- [Groq](https://groq.com/)
|
|
75
|
-
- [Hugging Face Inference API](https://huggingface.co/docs/api-inference/tasks/chat-completion)
|
|
76
|
-
- [Jan](https://jan.ai/)
|
|
77
|
-
- [Lightning AI](https://lightning.ai/)
|
|
78
|
-
- [LiteLLM](https://www.litellm.ai/)
|
|
79
|
-
- [llama.cpp](https://github.com/ggerganov/llama.cpp?tab=readme-ov-file)
|
|
80
|
-
- [llamafile](https://github.com/Mozilla-Ocho/llamafile)
|
|
81
|
-
- [LlamaIndex](https://www.llamaindex.ai/)
|
|
82
|
-
- [LM Studio](https://lmstudio.ai/)
|
|
83
|
-
- [LMDeploy](https://github.com/InternLM/lmdeploy)
|
|
84
|
-
- [LocalAI](https://localai.io/)
|
|
85
|
-
- [Mistral AI](https://mistral.ai/)
|
|
86
|
-
- [Ollama](https://ollama.com/)
|
|
87
|
-
- [OpenRouter](https://openrouter.ai/)
|
|
88
|
-
- [Titan ML](https://www.titanml.co/)
|
|
89
|
-
- [Vllm](https://docs.vllm.ai/en/v0.6.0/index.html)
|
|
90
|
-
- and many more...
|
|
91
|
-
|
|
92
|
-
## Contribute
|
|
93
|
-
|
|
94
|
-
I value community contributions that help enhance this Node-RED node and expand its capabilities in AIoT applications. Whether you're fixing bugs, adding new features, or improving documentation, your help is welcome!
|
|
95
|
-
|
|
96
|
-
### How to Contribute
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"model": "gpt-5-nano",
|
|
55
|
+
"input": "Write a one-line status summary."
|
|
56
|
+
}
|
|
57
|
+
```
|
|
97
58
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
59
|
+
Node output is written to `msg.payload`.
|
|
60
|
+
|
|
61
|
+
## Service Host Configuration
|
|
62
|
+
|
|
63
|
+
### API Key
|
|
64
|
+
|
|
65
|
+
- `cred` keeps the value in Node-RED credentials (masked in the editor).
|
|
66
|
+
- `env/msg/flow/global` treats the field as a reference, not a literal key.
|
|
67
|
+
- Existing flows with older key storage formats are still handled.
|
|
68
|
+
|
|
69
|
+
### Auth Header
|
|
70
|
+
|
|
71
|
+
- Default value is `Authorization`.
|
|
72
|
+
- You can override it for OpenAI-compatible providers that use a different header name.
|
|
73
|
+
|
|
74
|
+
### Organization ID
|
|
75
|
+
|
|
76
|
+
- Optional.
|
|
77
|
+
- Supports typed input (`str/env/msg/flow/global`) like other service fields.
|
|
78
|
+
|
|
79
|
+
### Environment Variables
|
|
80
|
+
|
|
81
|
+
You can source values from:
|
|
82
|
+
|
|
83
|
+
- OS-level environment variables.
|
|
84
|
+
- Node-RED editor environment variables (`User Settings -> Environment`).
|
|
85
|
+
|
|
86
|
+
## Supported API Families
|
|
87
|
+
|
|
88
|
+
The method dropdown includes operations across:
|
|
89
|
+
|
|
90
|
+
- Assistants
|
|
91
|
+
- Audio
|
|
92
|
+
- Batch
|
|
93
|
+
- Chat Completions
|
|
94
|
+
- Container Files
|
|
95
|
+
- Containers
|
|
96
|
+
- Conversations
|
|
97
|
+
- Embeddings
|
|
98
|
+
- Evals
|
|
99
|
+
- Files
|
|
100
|
+
- Fine-tuning
|
|
101
|
+
- Images
|
|
102
|
+
- Messages
|
|
103
|
+
- Models
|
|
104
|
+
- Moderations
|
|
105
|
+
- Realtime
|
|
106
|
+
- Responses
|
|
107
|
+
- Runs
|
|
108
|
+
- Skills
|
|
109
|
+
- Threads
|
|
110
|
+
- Uploads
|
|
111
|
+
- Vector Store File Batches
|
|
112
|
+
- Vector Store Files
|
|
113
|
+
- Vector Stores
|
|
114
|
+
- Videos
|
|
115
|
+
- Webhooks
|
|
116
|
+
|
|
117
|
+
`Graders` are supported through Evals payloads (`testing_criteria`) in the same way the official SDK models them.
|
|
118
|
+
|
|
119
|
+
See the in-editor node help for method-specific payload fields and links to official API docs.
|
|
120
|
+
|
|
121
|
+
## Recent Additions
|
|
122
|
+
|
|
123
|
+
- Added environment variable support for service host configuration values.
|
|
124
|
+
- OpenAI Node SDK upgraded from `4.103.0` to `6.22.0`.
|
|
125
|
+
- Added `responses.cancel`.
|
|
126
|
+
- Added `responses.compact`.
|
|
127
|
+
- Added `responses.input_tokens` counting support.
|
|
128
|
+
- Added Conversations API support:
|
|
129
|
+
- create/retrieve/modify/delete conversation
|
|
130
|
+
- create/retrieve/list/delete conversation items
|
|
131
|
+
- Added Containers and Container Files support.
|
|
132
|
+
- Added MCP tool use example flow at `examples/responses/mcp.json`.
|
|
133
|
+
- Added Skills API support:
|
|
134
|
+
- list/create/retrieve/modify/delete skills
|
|
135
|
+
- retrieve skill content
|
|
136
|
+
- list/create/retrieve/delete skill versions
|
|
137
|
+
- retrieve skill version content
|
|
138
|
+
- Added Evals API support:
|
|
139
|
+
- list/create/retrieve/modify/delete evals
|
|
140
|
+
- list/create/retrieve/cancel/delete eval runs
|
|
141
|
+
- list/retrieve eval run output items
|
|
142
|
+
- Added Realtime API support:
|
|
143
|
+
- create client secret
|
|
144
|
+
- accept/hangup/refer/reject SIP calls
|
|
145
|
+
- Added Videos API support:
|
|
146
|
+
- list/create/retrieve/delete videos
|
|
147
|
+
- download video content
|
|
148
|
+
- remix videos
|
|
149
|
+
- Added Webhooks utility support:
|
|
150
|
+
- unwrap signed webhook payloads
|
|
151
|
+
- verify webhook signatures
|
|
152
|
+
- Service Host auth routing now applies `Auth Header` configuration at request time.
|
|
153
|
+
|
|
154
|
+
## Examples
|
|
155
|
+
|
|
156
|
+
Import-ready example flows are available in `examples/`:
|
|
157
|
+
|
|
158
|
+
- [`examples/assistants.json`](examples/assistants.json)
|
|
159
|
+
- [`examples/audio.json`](examples/audio.json)
|
|
160
|
+
- [`examples/chat.json`](examples/chat.json)
|
|
161
|
+
- [`examples/embeddings.json`](examples/embeddings.json)
|
|
162
|
+
- [`examples/files.json`](examples/files.json)
|
|
163
|
+
- [`examples/fine-tuning.json`](examples/fine-tuning.json)
|
|
164
|
+
- [`examples/images.json`](examples/images.json)
|
|
165
|
+
- [`examples/messages.json`](examples/messages.json)
|
|
166
|
+
- [`examples/models.json`](examples/models.json)
|
|
167
|
+
- [`examples/moderations.json`](examples/moderations.json)
|
|
168
|
+
- [`examples/runs.json`](examples/runs.json)
|
|
169
|
+
- [`examples/threads.json`](examples/threads.json)
|
|
170
|
+
- [`examples/responses/mcp.json`](examples/responses/mcp.json)
|
|
171
|
+
|
|
172
|
+
## Development
|
|
104
173
|
|
|
105
|
-
|
|
174
|
+
```bash
|
|
175
|
+
npm install
|
|
176
|
+
npm run build
|
|
177
|
+
npm test
|
|
178
|
+
```
|
|
106
179
|
|
|
107
|
-
|
|
108
|
-
- Include unit tests for new features to confirm they work as expected.
|
|
109
|
-
- Update documentation to reflect any changes or additions made.
|
|
180
|
+
Build output files are generated from `src/`:
|
|
110
181
|
|
|
111
|
-
|
|
182
|
+
- `node.html` (from `src/node.html`)
|
|
183
|
+
- `lib.js` (from `src/lib.js`)
|
|
112
184
|
|
|
113
|
-
|
|
185
|
+
## Contributing
|
|
114
186
|
|
|
115
|
-
|
|
116
|
-
- **Feedback and Issues**: If you encounter any issues or have suggestions, please [raise an issue](https://github.com/allanbunch/node-red-openai-api/issues) directly on GitHub.
|
|
117
|
-
- **Contributing**: Your contributions are invaluable to us. See the [How to Contribute](#contribute) section for more details on how to get involved.
|
|
187
|
+
PRs are welcome. Please include:
|
|
118
188
|
|
|
119
|
-
|
|
189
|
+
- clear scope and rationale,
|
|
190
|
+
- tests for behavior changes,
|
|
191
|
+
- doc updates when user-facing behavior changes.
|
|
120
192
|
|
|
121
193
|
## License
|
|
122
194
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
Thank you for being part of the Node-RED community!
|
|
195
|
+
[MIT](./LICENSE)
|