@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.
Files changed (61) hide show
  1. package/README.md +165 -95
  2. package/examples/responses/mcp.json +1 -1
  3. package/lib.js +7035 -13298
  4. package/locales/en-US/node.json +49 -1
  5. package/node.html +1526 -981
  6. package/node.js +194 -54
  7. package/package.json +8 -7
  8. package/src/assistants/help.html +1 -77
  9. package/src/audio/help.html +1 -37
  10. package/src/batch/help.html +3 -17
  11. package/src/chat/help.html +11 -89
  12. package/src/container-files/help.html +1 -27
  13. package/src/containers/help.html +8 -18
  14. package/src/conversations/help.html +135 -0
  15. package/src/conversations/methods.js +73 -0
  16. package/src/conversations/template.html +10 -0
  17. package/src/embeddings/help.html +1 -11
  18. package/src/evals/help.html +249 -0
  19. package/src/evals/methods.js +114 -0
  20. package/src/evals/template.html +14 -0
  21. package/src/files/help.html +4 -17
  22. package/src/fine-tuning/help.html +1 -35
  23. package/src/images/help.html +1 -45
  24. package/src/lib.js +53 -1
  25. package/src/messages/help.html +19 -39
  26. package/src/messages/methods.js +13 -0
  27. package/src/messages/template.html +7 -18
  28. package/src/models/help.html +1 -5
  29. package/src/moderations/help.html +1 -5
  30. package/src/node.html +126 -37
  31. package/src/realtime/help.html +129 -0
  32. package/src/realtime/methods.js +45 -0
  33. package/src/realtime/template.html +7 -0
  34. package/src/responses/help.html +203 -61
  35. package/src/responses/methods.js +49 -16
  36. package/src/responses/template.html +16 -1
  37. package/src/runs/help.html +1 -123
  38. package/src/skills/help.html +183 -0
  39. package/src/skills/methods.js +99 -0
  40. package/src/skills/template.html +13 -0
  41. package/src/threads/help.html +1 -15
  42. package/src/uploads/help.html +1 -21
  43. package/src/vector-store-file-batches/help.html +1 -27
  44. package/src/vector-store-file-batches/methods.js +5 -5
  45. package/src/vector-store-files/help.html +1 -25
  46. package/src/vector-store-files/methods.js +4 -7
  47. package/src/vector-stores/help.html +2 -31
  48. package/src/vector-stores/methods.js +5 -11
  49. package/src/vector-stores/template.html +7 -22
  50. package/src/videos/help.html +113 -0
  51. package/src/videos/methods.js +50 -0
  52. package/src/videos/template.html +8 -0
  53. package/src/webhooks/help.html +61 -0
  54. package/src/webhooks/methods.js +40 -0
  55. package/src/webhooks/template.html +4 -0
  56. package/test/openai-methods-mapping.test.js +1220 -0
  57. package/test/openai-node-auth-routing.test.js +203 -0
  58. package/test/service-host-editor-template.test.js +53 -0
  59. package/test/service-host-node.test.js +182 -0
  60. package/test/services.test.js +147 -0
  61. 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
- ![NPM Version](https://img.shields.io/npm/v/%40inductiv%2Fnode-red-openai-api) ![GitHub Release Date](https://img.shields.io/github/release-date/allanbunch/node-red-openai-api) ![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/allanbunch/node-red-openai-api) ![GitHub Repo stars](https://img.shields.io/github/stars/allanbunch/node-red-openai-api)
3
+ ![NPM Version](https://img.shields.io/npm/v/%40inductiv%2Fnode-red-openai-api)
4
+ ![GitHub Issues](https://img.shields.io/github/issues/allanbunch/node-red-openai-api)
5
+ ![GitHub Stars](https://img.shields.io/github/stars/allanbunch/node-red-openai-api)
4
6
 
5
- This library provides convenient access to the OpenAI Node API Library from Node-RED.
7
+ Node-RED node for calling the OpenAI API (and OpenAI-compatible APIs) through a single configurable node.
6
8
 
7
- <a href="https://github.com/allanbunch/node-red-openai-api">
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
- Node-RED OpenAI API is a versatile and configurable Node-RED node designed for seamless integration with any OpenAI API compatible platform. This node empowers innovators and developers to effortlessly connect and orchestrate complex AI and AIoT workflows, leveraging Node-RED's sophisticated ecosystem. Ideal for enhancing IoT operations with advanced AI capabilities, this node serves as your gateway to applying the latest AI technology in an IoT context, facilitating innovative applications across diverse environments.
11
+ ## What You Get
13
12
 
14
- ## Installation
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
- ### Via Node-RED Palette Manager
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
- ### Via NPM
32
+ ### npm
23
33
 
24
34
  ```bash
25
- cd $HOME/.node-red # or the location of your Node-RED configuration directory.
35
+ cd $HOME/.node-red
26
36
  npm i @inductiv/node-red-openai-api
27
37
  ```
28
38
 
29
- ## Usage
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
- - Full Model Context Protocol (MCP) tool support for the `responses` API.
52
- - Added support for the new `container` endpoint.
53
- - Added support for the new `containerFiles` endpoint.
54
- - Added a simple MCP tool use example flow to the `examples` directory. See: [MCP Example](./examples/responses/mcp.json).
55
- - Refactored code to greatly improve maintainability and stability.
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
- ### Important Notice Regarding Compatibility
50
+ Example `msg.payload` for `create model response`:
58
51
 
59
- - **Backward Incompatible Changes**: Please be aware that v1.0 includes breaking changes that may affect existing implementations (v0.x.x instllations) due to the updated OpenAI NodeJS package:
60
- - The API call structure and parameters have been refined to align with the latest OpenAI specifications.
61
- - Some functions and settings from previous versions may no longer be compatible with this update.
62
- - List responses now exist at the top level of the `msg.payload` object; previously `msg.payload.data`.
63
-
64
- I recommend reviewing existing flows and testing them with this new version in a development environment before updating to ensure a smooth transition. This will help you take full advantage of the enhanced features while managing any necessary adjustments in your existing applications.
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
- 1. **Fork the Repository**: Start by forking the [repository](https://github.com/allanbunch/node-red-openai-api) to your GitHub account.
99
- 2. **Clone Your Fork**: Clone your fork to your local machine for development.
100
- 3. **Create a Feature Branch**: Create a branch in your forked repository where you can make your changes.
101
- 4. **Commit Your Changes**: Make your changes in your feature branch and commit them with clear, descriptive messages.
102
- 5. **Push to Your Fork**: Push your changes to your fork on GitHub.
103
- 6. **Submit a Pull Request**: Go to the original repository and submit a pull request from your feature branch. Please provide a clear description of the changes and reference any related issues.
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
- ### Guidelines
174
+ ```bash
175
+ npm install
176
+ npm run build
177
+ npm test
178
+ ```
106
179
 
107
- - Ensure your code adheres to or enhances the project's style and quality standards.
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
- ## Community and Support
182
+ - `node.html` (from `src/node.html`)
183
+ - `lib.js` (from `src/lib.js`)
112
184
 
113
- Engage with the Node-RED OpenAI API community to share your experiences, get support, and discuss your ideas. Whether you're using the node or contributing to its development, I'm here to help and look forward to your feedback and contributions.
185
+ ## Contributing
114
186
 
115
- - **Community Discussions**: For any questions, help with setting up, or to connect with other users and contributors, please visit our [Community Discussions](https://github.com/allanbunch/node-red-openai-api/discussions).
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
- Thank you for being part of our innovative community!
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
- This project is licensed under the [MIT License](./LICENSE).
124
-
125
- Thank you for being part of the Node-RED community!
195
+ [MIT](./LICENSE)
@@ -49,7 +49,7 @@
49
49
  "props": [
50
50
  {
51
51
  "p": "ai.model",
52
- "v": "gpt-4o-mini",
52
+ "v": "gpt-5-nano",
53
53
  "vt": "str"
54
54
  },
55
55
  {