@inductiv/node-red-openai-api 1.103.0-patch.1 → 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 (57) hide show
  1. package/README.md +165 -100
  2. package/examples/responses/mcp.json +1 -1
  3. package/lib.js +6917 -13226
  4. package/locales/en-US/node.json +48 -1
  5. package/node.html +1513 -962
  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 +51 -1
  25. package/src/messages/help.html +1 -41
  26. package/src/models/help.html +1 -5
  27. package/src/moderations/help.html +1 -5
  28. package/src/node.html +126 -37
  29. package/src/realtime/help.html +129 -0
  30. package/src/realtime/methods.js +45 -0
  31. package/src/realtime/template.html +7 -0
  32. package/src/responses/help.html +203 -61
  33. package/src/responses/methods.js +49 -16
  34. package/src/responses/template.html +16 -1
  35. package/src/runs/help.html +1 -123
  36. package/src/skills/help.html +183 -0
  37. package/src/skills/methods.js +99 -0
  38. package/src/skills/template.html +13 -0
  39. package/src/threads/help.html +1 -15
  40. package/src/uploads/help.html +1 -21
  41. package/src/vector-store-file-batches/help.html +1 -27
  42. package/src/vector-store-file-batches/methods.js +1 -1
  43. package/src/vector-store-files/help.html +1 -25
  44. package/src/vector-store-files/methods.js +5 -2
  45. package/src/vector-stores/help.html +2 -31
  46. package/src/videos/help.html +113 -0
  47. package/src/videos/methods.js +50 -0
  48. package/src/videos/template.html +8 -0
  49. package/src/webhooks/help.html +61 -0
  50. package/src/webhooks/methods.js +40 -0
  51. package/src/webhooks/template.html +4 -0
  52. package/test/openai-methods-mapping.test.js +1220 -0
  53. package/test/openai-node-auth-routing.test.js +203 -0
  54. package/test/service-host-editor-template.test.js +53 -0
  55. package/test/service-host-node.test.js +182 -0
  56. package/test/services.test.js +147 -0
  57. package/test/utils.test.js +75 -0
@@ -1,7 +1,7 @@
1
1
  <section>
2
2
  <details>
3
3
  <summary style="font-weight: bold;">📑 Vector Store Files</summary>
4
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files" target="_blank">Official
4
+ <a href="https://developers.openai.com/api/reference/typescript/resources/vector_stores/files/" target="_blank">Official
5
5
  Documentation
6
6
  <i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
7
7
 
@@ -11,16 +11,12 @@
11
11
  <h4>msg.payload Properties</h4>
12
12
  <dt>
13
13
  vector_store_id
14
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/createFile#vector-stores-files-createfile-vector_store_id"
15
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
16
14
  <span class="property-type">string</span>
17
15
  </dt>
18
16
  <dd>The ID of the vector store for which to create a File.</dd>
19
17
 
20
18
  <dt>
21
19
  file_id
22
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/createFile#vector-stores-files-createfile-file_id"
23
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
24
20
  <span class="property-type">string</span>
25
21
  </dt>
26
22
  <dd>A File ID that the vector store should use. Useful for tools like file_search that can access files.
@@ -34,16 +30,12 @@
34
30
  <h4>msg.payload Properties</h4>
35
31
  <dt>
36
32
  vector_store_id
37
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles#vector-stores-files-listfiles-vector_store_id"
38
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
39
33
  <span class="property-type">string</span>
40
34
  </dt>
41
35
  <dd>The ID of the vector store that the files belong to.</dd>
42
36
 
43
37
  <dt class="optional">
44
38
  limit
45
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles#vector-stores-files-listfiles-limit"
46
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
47
39
  <span class="property-type">integer</span>
48
40
  </dt>
49
41
  <dd>A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is
@@ -51,8 +43,6 @@
51
43
 
52
44
  <dt class="optional">
53
45
  order
54
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles#vector-stores-files-listfiles-order"
55
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
56
46
  <span class="property-type">string</span>
57
47
  </dt>
58
48
  <dd>Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending
@@ -60,24 +50,18 @@
60
50
 
61
51
  <dt class="optional">
62
52
  before
63
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles#vector-stores-files-listfiles-before"
64
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
65
53
  <span class="property-type">string</span>
66
54
  </dt>
67
55
  <dd>A cursor for use in pagination. before is an object ID that defines your place in the list.</dd>
68
56
 
69
57
  <dt class="optional">
70
58
  after
71
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles#vector-stores-files-listfiles-after"
72
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
73
59
  <span class="property-type">string</span>
74
60
  </dt>
75
61
  <dd>A cursor for use in pagination. after is an object ID that defines your place in the list.</dd>
76
62
 
77
63
  <dt class="optional">
78
64
  filter
79
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles#vector-stores-files-listfiles-filter"
80
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
81
65
  <span class="property-type">string</span>
82
66
  </dt>
83
67
  <dd>Filter by file status. One of in_progress, completed, failed, cancelled.</dd>
@@ -90,16 +74,12 @@
90
74
  <h4>msg.payload Properties</h4>
91
75
  <dt>
92
76
  vector_store_id
93
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/getFile#vector-stores-files-getfile-vector_store_id"
94
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
95
77
  <span class="property-type">string</span>
96
78
  </dt>
97
79
  <dd>The ID of the vector store that the file belongs to.</dd>
98
80
 
99
81
  <dt>
100
82
  file_id
101
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/getFile#vector-stores-files-getfile-file_id"
102
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
103
83
  <span class="property-type">string</span>
104
84
  </dt>
105
85
  <dd>The ID of the file being retrieved.</dd>
@@ -112,16 +92,12 @@
112
92
  <h4>msg.payload Properties</h4>
113
93
  <dt>
114
94
  vector_store_id
115
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/deleteFile#vector-stores-files-deletefile-vector_store_id"
116
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
117
95
  <span class="property-type">string</span>
118
96
  </dt>
119
97
  <dd>The ID of the vector store that the file belongs to.</dd>
120
98
 
121
99
  <dt>
122
100
  file_id
123
- <a href="https://platform.openai.com/docs/api-reference/vector-stores-files/deleteFile#vector-stores-files-deletefile-file_id"
124
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
125
101
  <span class="property-type">string</span>
126
102
  </dt>
127
103
  <dd>The ID of the file to remove from the vector store.</dd>
@@ -26,7 +26,10 @@ async function retrieveVectorStoreFile(parameters) {
26
26
 
27
27
  const openai = new OpenAI(this.clientParams);
28
28
  const { vector_store_id, file_id } = parameters.payload;
29
- const response = openai.vectorStores.files.retrieve(vector_store_id, file_id);
29
+ const response = await openai.vectorStores.files.retrieve(
30
+ vector_store_id,
31
+ file_id
32
+ );
30
33
 
31
34
  return response;
32
35
  }
@@ -36,7 +39,7 @@ async function deleteVectorStoreFile(parameters) {
36
39
 
37
40
  const openai = new OpenAI(this.clientParams);
38
41
  const { vector_store_id, file_id, ...params } = parameters.payload;
39
- const response = openai.vectorStores.files.del(
42
+ const response = await openai.vectorStores.files.del(
40
43
  vector_store_id,
41
44
  file_id,
42
45
  params
@@ -1,7 +1,7 @@
1
1
  <section>
2
2
  <details>
3
3
  <summary style="font-weight: bold;">🗃️ Vector Stores</summary>
4
- <a href="https://platform.openai.com/docs/api-reference/vector-stores" target="_blank">Official Documentation
4
+ <a href="https://developers.openai.com/api/reference/typescript/resources/vector_stores/" target="_blank">Official Documentation
5
5
  <i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
6
6
  <h4 style="font-weight: bolder;"> ⋙ Create Vector Store</h4>
7
7
  <p>Create a vector store.</p>
@@ -9,8 +9,7 @@
9
9
  <h4>msg.payload Properties</h4>
10
10
  <dt class="optional">
11
11
  file_ids
12
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/create" target="_blank"><i
13
- class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
12
+
14
13
  <span class="property-type">array</span>
15
14
  </dt>
16
15
  <dd>A list of File IDs that the vector store should use. Useful for tools like file_search that can access
@@ -18,32 +17,24 @@
18
17
 
19
18
  <dt class="optional">
20
19
  name
21
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/create#vector-stores-create-name"
22
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
23
20
  <span class="property-type">string</span>
24
21
  </dt>
25
22
  <dd>The name of the vector store.</dd>
26
23
 
27
24
  <dt class="optional">
28
25
  expires_after
29
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/create#vector-stores-create-expires_after"
30
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
31
26
  <span class="property-type">object</span>
32
27
  </dt>
33
28
  <dd>The expiration policy for a vector store.</dd>
34
29
 
35
30
  <dt class="optional">
36
31
  chunking_strategy
37
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/create#vector-stores-create-chunking_strategy"
38
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
39
32
  <span class="property-type">object</span>
40
33
  </dt>
41
34
  <dd>The chunking strategy used to chunk the file(s).</dd>
42
35
 
43
36
  <dt class="optional">
44
37
  metadata
45
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/create#vector-stores-create-metadata"
46
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
47
38
  <span class="property-type">object</span>
48
39
  </dt>
49
40
  <dd>Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional
@@ -58,8 +49,6 @@
58
49
 
59
50
  <dt class="optional">
60
51
  limit
61
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/list#vector-stores-list-limit"
62
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
63
52
  <span class="property-type">integer</span>
64
53
  </dt>
65
54
  <dd>A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is
@@ -67,8 +56,6 @@
67
56
 
68
57
  <dt class="optional">
69
58
  order
70
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/list#vector-stores-list-order"
71
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
72
59
  <span class="property-type">string</span>
73
60
  </dt>
74
61
  <dd>Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending
@@ -76,16 +63,12 @@
76
63
 
77
64
  <dt class="optional">
78
65
  after
79
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/list#vector-stores-list-after"
80
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
81
66
  <span class="property-type">string</span>
82
67
  </dt>
83
68
  <dd>A cursor for use in pagination. after is an object ID that defines your place in the list.</dd>
84
69
 
85
70
  <dt class="optional">
86
71
  before
87
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/list#vector-stores-list-before"
88
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
89
72
  <span class="property-type">string</span>
90
73
  </dt>
91
74
  <dd>A cursor for use in pagination. before is an object ID that defines your place in the list.</dd>
@@ -98,8 +81,6 @@
98
81
 
99
82
  <dt>
100
83
  vector_store_id
101
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/retrieve#vector-stores-retrieve-vector_store_id"
102
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
103
84
  <span class="property-type">string</span>
104
85
  </dt>
105
86
  <dd>The ID of the vector store to retrieve.</dd>
@@ -112,32 +93,24 @@
112
93
 
113
94
  <dt>
114
95
  vector_store_id
115
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/modify#vector-stores-modify-vector_store_id"
116
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
117
96
  <span class="property-type">string</span>
118
97
  </dt>
119
98
  <dd>The ID of the vector store to modify.</dd>
120
99
 
121
100
  <dt class="optional">
122
101
  name
123
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/modify#vector-stores-modify-name"
124
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
125
102
  <span class="property-type">string</span>
126
103
  </dt>
127
104
  <dd>The name of the vector store.</dd>
128
105
 
129
106
  <dt class="optional">
130
107
  expires_after
131
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/modify#vector-stores-modify-expires_after"
132
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
133
108
  <span class="property-type">object</span>
134
109
  </dt>
135
110
  <dd>The expiration policy for a vector store.</dd>
136
111
 
137
112
  <dt class="optional">
138
113
  metadata
139
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/modify#vector-stores-modify-metadata"
140
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
141
114
  <span class="property-type">object</span>
142
115
  </dt>
143
116
  <dd>Set of 16 key-value pairs that can be attached to an object.</dd>
@@ -150,8 +123,6 @@
150
123
 
151
124
  <dt>
152
125
  vector_store_id
153
- <a href="https://platform.openai.com/docs/api-reference/vector-stores/delete#vector-stores-delete-vector_store_id"
154
- target="_blank"><i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
155
126
  <span class="property-type">string</span>
156
127
  </dt>
157
128
  <dd>The ID of the vector store to delete.</dd>
@@ -0,0 +1,113 @@
1
+ <section>
2
+ <details>
3
+ <summary style="font-weight: bold;">🎬 Videos</summary>
4
+ <a href="https://developers.openai.com/api/reference/typescript/resources/videos/" target="_blank">Official Documentation
5
+ <i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
6
+
7
+ <h4 style="font-weight: bolder;"> ⋙ List Videos</h4>
8
+ <p>List generated videos.</p>
9
+ <dl class="message-properties">
10
+ <h4>msg.payload Properties</h4>
11
+ <dt class="optional">
12
+ after
13
+ <span class="property-type">string</span>
14
+ </dt>
15
+ <dd>Pagination cursor for items after this id.</dd>
16
+ <dt class="optional">
17
+ limit
18
+ <span class="property-type">integer</span>
19
+ </dt>
20
+ <dd>Maximum number of videos to return.</dd>
21
+ <dt class="optional">
22
+ order
23
+ <span class="property-type">string</span>
24
+ </dt>
25
+ <dd>Sort order by creation time. Use <code>asc</code> or <code>desc</code>.</dd>
26
+ </dl>
27
+
28
+ <h4 style="font-weight: bolder;"> ⋙ Create Video</h4>
29
+ <p>Create a new video generation job.</p>
30
+ <dl class="message-properties">
31
+ <h4>msg.payload Properties</h4>
32
+ <dt>
33
+ prompt
34
+ <span class="property-type">string</span>
35
+ </dt>
36
+ <dd>Prompt describing the video output.</dd>
37
+ <dt class="optional">
38
+ input_reference
39
+ <span class="property-type">file</span>
40
+ </dt>
41
+ <dd>Optional reference image upload.</dd>
42
+ <dt class="optional">
43
+ model
44
+ <span class="property-type">string</span>
45
+ </dt>
46
+ <dd>Video model id.</dd>
47
+ <dt class="optional">
48
+ seconds
49
+ <span class="property-type">string</span>
50
+ </dt>
51
+ <dd>Clip length in seconds.</dd>
52
+ <dt class="optional">
53
+ size
54
+ <span class="property-type">string</span>
55
+ </dt>
56
+ <dd>Video resolution.</dd>
57
+ </dl>
58
+
59
+ <h4 style="font-weight: bolder;"> ⋙ Retrieve Video</h4>
60
+ <p>Retrieve one video job by id.</p>
61
+ <dl class="message-properties">
62
+ <h4>msg.payload Properties</h4>
63
+ <dt>
64
+ video_id
65
+ <span class="property-type">string</span>
66
+ </dt>
67
+ <dd>The video id.</dd>
68
+ </dl>
69
+
70
+ <h4 style="font-weight: bolder;"> ⋙ Delete Video</h4>
71
+ <p>Delete one video job by id.</p>
72
+ <dl class="message-properties">
73
+ <h4>msg.payload Properties</h4>
74
+ <dt>
75
+ video_id
76
+ <span class="property-type">string</span>
77
+ </dt>
78
+ <dd>The video id.</dd>
79
+ </dl>
80
+
81
+ <h4 style="font-weight: bolder;"> ⋙ Download Video Content</h4>
82
+ <p>Download rendered video content or related assets.</p>
83
+ <dl class="message-properties">
84
+ <h4>msg.payload Properties</h4>
85
+ <dt>
86
+ video_id
87
+ <span class="property-type">string</span>
88
+ </dt>
89
+ <dd>The video id.</dd>
90
+ <dt class="optional">
91
+ variant
92
+ <span class="property-type">string</span>
93
+ </dt>
94
+ <dd>Asset variant: <code>video</code>, <code>thumbnail</code>, or <code>spritesheet</code>.</dd>
95
+ </dl>
96
+
97
+ <h4 style="font-weight: bolder;"> ⋙ Remix Video</h4>
98
+ <p>Create a remix from an existing video id.</p>
99
+ <dl class="message-properties">
100
+ <h4>msg.payload Properties</h4>
101
+ <dt>
102
+ video_id
103
+ <span class="property-type">string</span>
104
+ </dt>
105
+ <dd>The source video id.</dd>
106
+ <dt>
107
+ prompt
108
+ <span class="property-type">string</span>
109
+ </dt>
110
+ <dd>Prompt describing remix changes.</dd>
111
+ </dl>
112
+ </details>
113
+ </section>
@@ -0,0 +1,50 @@
1
+ const OpenAI = require("openai").OpenAI;
2
+
3
+ async function createVideo(parameters) {
4
+ const openai = new OpenAI(this.clientParams);
5
+ const response = await openai.videos.create(parameters.payload);
6
+ return response;
7
+ }
8
+
9
+ async function getVideo(parameters) {
10
+ const openai = new OpenAI(this.clientParams);
11
+ const { video_id, ...params } = parameters.payload;
12
+ const response = await openai.videos.retrieve(video_id, params);
13
+ return response;
14
+ }
15
+
16
+ async function listVideos(parameters) {
17
+ const openai = new OpenAI(this.clientParams);
18
+ const list = await openai.videos.list(parameters.payload);
19
+ return [...list.data];
20
+ }
21
+
22
+ async function deleteVideo(parameters) {
23
+ const openai = new OpenAI(this.clientParams);
24
+ const { video_id, ...params } = parameters.payload;
25
+ const response = await openai.videos.delete(video_id, params);
26
+ return response;
27
+ }
28
+
29
+ async function downloadVideoContent(parameters) {
30
+ const openai = new OpenAI(this.clientParams);
31
+ const { video_id, ...params } = parameters.payload;
32
+ const response = await openai.videos.downloadContent(video_id, params);
33
+ return response;
34
+ }
35
+
36
+ async function remixVideo(parameters) {
37
+ const openai = new OpenAI(this.clientParams);
38
+ const { video_id, ...body } = parameters.payload;
39
+ const response = await openai.videos.remix(video_id, body);
40
+ return response;
41
+ }
42
+
43
+ module.exports = {
44
+ createVideo,
45
+ getVideo,
46
+ listVideos,
47
+ deleteVideo,
48
+ downloadVideoContent,
49
+ remixVideo,
50
+ };
@@ -0,0 +1,8 @@
1
+ <optgroup style="font-style: normal;" label="🎬 Videos">
2
+ <option value="listVideos" data-i18n="OpenaiApi.parameters.listVideos"></option>
3
+ <option value="createVideo" data-i18n="OpenaiApi.parameters.createVideo"></option>
4
+ <option value="getVideo" data-i18n="OpenaiApi.parameters.getVideo"></option>
5
+ <option value="deleteVideo" data-i18n="OpenaiApi.parameters.deleteVideo"></option>
6
+ <option value="downloadVideoContent" data-i18n="OpenaiApi.parameters.downloadVideoContent"></option>
7
+ <option value="remixVideo" data-i18n="OpenaiApi.parameters.remixVideo"></option>
8
+ </optgroup>
@@ -0,0 +1,61 @@
1
+ <section>
2
+ <details>
3
+ <summary style="font-weight: bold;">🪝 Webhooks</summary>
4
+ <a href="https://developers.openai.com/api/reference/typescript/resources/webhooks/" target="_blank">Official Documentation
5
+ <i class="fa fa-external-link fa-sm" aria-hidden="true"></i></a>
6
+
7
+ <h4 style="font-weight: bolder;"> ⋙ Unwrap Webhook Event</h4>
8
+ <p>Validate signature and parse the webhook payload into an event object.</p>
9
+ <dl class="message-properties">
10
+ <h4>msg.payload Properties</h4>
11
+ <dt>
12
+ payload
13
+ <span class="property-type">string</span>
14
+ </dt>
15
+ <dd>Raw webhook request body string.</dd>
16
+ <dt>
17
+ headers
18
+ <span class="property-type">object</span>
19
+ </dt>
20
+ <dd>Request headers containing webhook signature fields.</dd>
21
+ <dt class="optional">
22
+ secret
23
+ <span class="property-type">string</span>
24
+ </dt>
25
+ <dd>Webhook secret. If omitted, SDK-level webhook secret is used.</dd>
26
+ <dt class="optional">
27
+ tolerance
28
+ <span class="property-type">integer</span>
29
+ </dt>
30
+ <dd>Maximum webhook age in seconds. Default is <code>300</code>.</dd>
31
+ </dl>
32
+
33
+ <h4 style="font-weight: bolder;"> ⋙ Verify Webhook Signature</h4>
34
+ <p>Validate a webhook signature without parsing the event body.</p>
35
+ <dl class="message-properties">
36
+ <h4>msg.payload Properties</h4>
37
+ <dt>
38
+ payload
39
+ <span class="property-type">string</span>
40
+ </dt>
41
+ <dd>Raw webhook request body string.</dd>
42
+ <dt>
43
+ headers
44
+ <span class="property-type">object</span>
45
+ </dt>
46
+ <dd>Request headers containing webhook signature fields.</dd>
47
+ <dt class="optional">
48
+ secret
49
+ <span class="property-type">string</span>
50
+ </dt>
51
+ <dd>Webhook secret. If omitted, SDK-level webhook secret is used.</dd>
52
+ <dt class="optional">
53
+ tolerance
54
+ <span class="property-type">integer</span>
55
+ </dt>
56
+ <dd>Maximum webhook age in seconds. Default is <code>300</code>.</dd>
57
+ </dl>
58
+
59
+ <p>The verify method returns <code>{ verified: true }</code> on success.</p>
60
+ </details>
61
+ </section>
@@ -0,0 +1,40 @@
1
+ const OpenAI = require("openai").OpenAI;
2
+
3
+ async function unwrapWebhookEvent(parameters) {
4
+ const openai = new OpenAI(this.clientParams);
5
+ const {
6
+ payload: webhookPayload,
7
+ headers,
8
+ secret,
9
+ tolerance,
10
+ } = parameters.payload;
11
+ const response = await openai.webhooks.unwrap(
12
+ webhookPayload,
13
+ headers,
14
+ secret,
15
+ tolerance
16
+ );
17
+ return response;
18
+ }
19
+
20
+ async function verifyWebhookSignature(parameters) {
21
+ const openai = new OpenAI(this.clientParams);
22
+ const {
23
+ payload: webhookPayload,
24
+ headers,
25
+ secret,
26
+ tolerance,
27
+ } = parameters.payload;
28
+ await openai.webhooks.verifySignature(
29
+ webhookPayload,
30
+ headers,
31
+ secret,
32
+ tolerance
33
+ );
34
+ return { verified: true };
35
+ }
36
+
37
+ module.exports = {
38
+ unwrapWebhookEvent,
39
+ verifyWebhookSignature,
40
+ };
@@ -0,0 +1,4 @@
1
+ <optgroup style="font-style: normal;" label="🪝 Webhooks">
2
+ <option value="unwrapWebhookEvent" data-i18n="OpenaiApi.parameters.unwrapWebhookEvent"></option>
3
+ <option value="verifyWebhookSignature" data-i18n="OpenaiApi.parameters.verifyWebhookSignature"></option>
4
+ </optgroup>