n8n-nodes-pollinations-v2 1.1.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.
@@ -0,0 +1,237 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.imageGenerationOperation = void 0;
4
+ exports.executeImageGeneration = executeImageGeneration;
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ exports.imageGenerationOperation = [
7
+ {
8
+ displayName: 'Prompt',
9
+ name: 'prompt',
10
+ type: 'string',
11
+ default: '',
12
+ required: true,
13
+ displayOptions: {
14
+ show: {
15
+ operation: ['imageGeneration'],
16
+ },
17
+ },
18
+ description: 'Text description of the image to generate',
19
+ },
20
+ {
21
+ displayName: 'Model',
22
+ name: 'model',
23
+ type: 'options',
24
+ displayOptions: {
25
+ show: {
26
+ operation: ['imageGeneration'],
27
+ },
28
+ },
29
+ loadOptionsMethod: 'getImageModels',
30
+ default: '',
31
+ description: 'AI model to use for image generation',
32
+ },
33
+ {
34
+ displayName: 'Width',
35
+ name: 'width',
36
+ type: 'number',
37
+ displayOptions: {
38
+ show: {
39
+ operation: ['imageGeneration'],
40
+ },
41
+ },
42
+ default: 1024,
43
+ description: 'Image width in pixels (16-2048)',
44
+ typeOptions: {
45
+ minValue: 16,
46
+ maxValue: 2048,
47
+ },
48
+ },
49
+ {
50
+ displayName: 'Height',
51
+ name: 'height',
52
+ type: 'number',
53
+ displayOptions: {
54
+ show: {
55
+ operation: ['imageGeneration'],
56
+ },
57
+ },
58
+ default: 1024,
59
+ description: 'Image height in pixels (16-2048)',
60
+ typeOptions: {
61
+ minValue: 16,
62
+ maxValue: 2048,
63
+ },
64
+ },
65
+ {
66
+ displayName: 'Additional Options',
67
+ name: 'additionalOptions',
68
+ type: 'collection',
69
+ placeholder: 'Add Option',
70
+ default: {},
71
+ displayOptions: {
72
+ show: {
73
+ operation: ['imageGeneration'],
74
+ },
75
+ },
76
+ options: [
77
+ {
78
+ displayName: 'Enhance Prompt',
79
+ name: 'enhance',
80
+ type: 'boolean',
81
+ default: false,
82
+ description: 'Whether to use AI to improve the prompt',
83
+ },
84
+ {
85
+ displayName: 'Image Count',
86
+ name: 'count',
87
+ type: 'number',
88
+ default: 1,
89
+ description: 'Number of images to generate (1-4, premium models only)',
90
+ typeOptions: {
91
+ minValue: 1,
92
+ maxValue: 4,
93
+ },
94
+ },
95
+ {
96
+ displayName: 'Input Image URL',
97
+ name: 'imageUrl',
98
+ type: 'string',
99
+ default: '',
100
+ description: 'URL of input image(s) for image-to-image/edit. Comma/pipe separated for multiple.',
101
+ },
102
+ {
103
+ displayName: 'Negative Prompt',
104
+ name: 'negative_prompt',
105
+ type: 'string',
106
+ default: 'worst quality, blurry',
107
+ description: 'What to avoid in the generated image',
108
+ },
109
+ {
110
+ displayName: 'No Logo',
111
+ name: 'nologo',
112
+ type: 'boolean',
113
+ default: false,
114
+ description: 'Whether to remove the Pollinations logo from the image',
115
+ },
116
+ {
117
+ displayName: 'Private',
118
+ name: 'private',
119
+ type: 'boolean',
120
+ default: false,
121
+ description: 'Whether to keep the generation private',
122
+ },
123
+ {
124
+ displayName: 'Quality',
125
+ name: 'quality',
126
+ type: 'options',
127
+ options: [
128
+ { name: 'Low', value: 'low' },
129
+ { name: 'Medium', value: 'medium' },
130
+ { name: 'High', value: 'high' },
131
+ { name: 'HD', value: 'hd' },
132
+ ],
133
+ default: 'medium',
134
+ description: 'Image quality level (gptimage only)',
135
+ },
136
+ {
137
+ displayName: 'Safe Mode',
138
+ name: 'safe',
139
+ type: 'boolean',
140
+ default: false,
141
+ description: 'Whether to enable strict NSFW content filtering',
142
+ },
143
+ {
144
+ displayName: 'Seed',
145
+ name: 'seed',
146
+ type: 'number',
147
+ default: -1,
148
+ description: 'Random seed for reproducible results (-1 for random)',
149
+ },
150
+ {
151
+ displayName: 'Transparent Background',
152
+ name: 'transparent',
153
+ type: 'boolean',
154
+ default: false,
155
+ description: 'Whether to generate image with transparent background (gptimage only)',
156
+ },
157
+ ],
158
+ },
159
+ ];
160
+ async function executeImageGeneration(itemIndex) {
161
+ const prompt = this.getNodeParameter('prompt', itemIndex);
162
+ const model = this.getNodeParameter('model', itemIndex);
163
+ const width = this.getNodeParameter('width', itemIndex);
164
+ const height = this.getNodeParameter('height', itemIndex);
165
+ const additionalOptions = this.getNodeParameter('additionalOptions', itemIndex, {});
166
+ const queryParams = {
167
+ model,
168
+ width: width.toString(),
169
+ height: height.toString(),
170
+ };
171
+ if (additionalOptions.seed !== undefined && additionalOptions.seed !== -1) {
172
+ queryParams.seed = additionalOptions.seed.toString();
173
+ }
174
+ if (additionalOptions.nologo)
175
+ queryParams.nologo = 'true';
176
+ if (additionalOptions.private)
177
+ queryParams.private = 'true';
178
+ if (additionalOptions.safe)
179
+ queryParams.safe = 'true';
180
+ if (additionalOptions.enhance)
181
+ queryParams.enhance = 'true';
182
+ if (additionalOptions.transparent)
183
+ queryParams.transparent = 'true';
184
+ if (additionalOptions.count && additionalOptions.count > 1) {
185
+ queryParams.count = additionalOptions.count.toString();
186
+ }
187
+ if (additionalOptions.imageUrl) {
188
+ queryParams.image = additionalOptions.imageUrl;
189
+ }
190
+ if (additionalOptions.negative_prompt) {
191
+ queryParams.negative_prompt = additionalOptions.negative_prompt;
192
+ }
193
+ if (additionalOptions.quality) {
194
+ queryParams.quality = additionalOptions.quality;
195
+ }
196
+ const headers = {};
197
+ try {
198
+ const credentials = await this.getCredentials('pollinationsApi');
199
+ if (credentials === null || credentials === void 0 ? void 0 : credentials.apiKey) {
200
+ headers['Authorization'] = `Bearer ${credentials.apiKey}`;
201
+ }
202
+ }
203
+ catch {
204
+ }
205
+ const queryString = new URLSearchParams(queryParams).toString();
206
+ const url = `https://gen.pollinations.ai/image/${encodeURIComponent(prompt)}?${queryString}`;
207
+ try {
208
+ const response = await this.helpers.httpRequest({
209
+ method: 'GET',
210
+ url,
211
+ headers,
212
+ encoding: 'arraybuffer',
213
+ returnFullResponse: true,
214
+ });
215
+ const contentType = response.headers['content-type'];
216
+ const mimeType = (contentType === null || contentType === void 0 ? void 0 : contentType.split(';')[0]) || 'image/jpeg';
217
+ const fileExtension = mimeType.split('/')[1] || 'jpg';
218
+ const binaryData = await this.helpers.prepareBinaryData(Buffer.from(response.body), `image_${itemIndex}.${fileExtension}`, mimeType);
219
+ return {
220
+ json: {
221
+ prompt,
222
+ model,
223
+ width,
224
+ height,
225
+ ...additionalOptions,
226
+ },
227
+ binary: {
228
+ data: binaryData,
229
+ },
230
+ pairedItem: { item: itemIndex },
231
+ };
232
+ }
233
+ catch (error) {
234
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to generate image: ${error.message}`, { itemIndex });
235
+ }
236
+ }
237
+ //# sourceMappingURL=imageGeneration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageGeneration.js","sourceRoot":"","sources":["../../../../nodes/Pollinations/operations/imageGeneration.ts"],"names":[],"mappings":";;;AA+JA,wDAuGC;AArQD,+CAAkD;AAErC,QAAA,wBAAwB,GAAsB;IAC1D;QACC,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,IAAI;QACd,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,SAAS,EAAE,CAAC,iBAAiB,CAAC;aAC9B;SACD;QACD,WAAW,EAAE,2CAA2C;KACxD;IACA;QACA,WAAW,EAAE,OAAO;QACpB,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,SAAS;QACf,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,SAAS,EAAE,CAAC,iBAAiB,CAAC;aAC9B;SACD;QACD,iBAAiB,EAAE,gBAAgB;QACnC,OAAO,EAAE,EAAE;QACX,WAAW,EAAE,sCAAsC;KAExB;IAC5B;QACC,WAAW,EAAE,OAAO;QACpB,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,QAAQ;QACd,cAAc,EAAE;YACf,IAA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CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,KAAI,YAAY,CAAC;QAC5D,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;QAEtD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CACtD,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAmB,CAAC,EACzC,SAAS,SAAS,IAAI,aAAa,EAAE,EACrC,QAAQ,CACR,CAAC;QAEF,OAAO;YACN,IAAI,EAAE;gBACL,MAAM;gBACN,KAAK;gBACL,KAAK;gBACL,MAAM;gBACN,GAAG,iBAAiB;aACpB;YACD,MAAM,EAAE;gBACP,IAAI,EAAE,UAAU;aAChB;YACD,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAC/B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,IAAI,iCAAkB,CAC3B,IAAI,CAAC,OAAO,EAAE,EACd,6BAA6B,KAAK,CAAC,OAAO,EAAE,EAC5C,EAAE,SAAS,EAAE,CACb,CAAC;IACH,CAAC;AACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
2
+ export declare const textGenerationOperation: INodeProperties[];
3
+ export declare function executeTextGeneration(this: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData>;
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.textGenerationOperation = void 0;
4
+ exports.executeTextGeneration = executeTextGeneration;
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ exports.textGenerationOperation = [
7
+ {
8
+ displayName: 'Generation Type',
9
+ name: 'textGenerationType',
10
+ type: 'options',
11
+ displayOptions: {
12
+ show: {
13
+ operation: ['textGeneration'],
14
+ },
15
+ },
16
+ options: [
17
+ {
18
+ name: 'Simple Text',
19
+ value: 'simple',
20
+ description: 'Quick text generation from a prompt',
21
+ },
22
+ {
23
+ name: 'Chat Completion',
24
+ value: 'chat',
25
+ description: 'OpenAI-compatible chat completions with advanced features',
26
+ },
27
+ ],
28
+ default: 'simple',
29
+ description: 'Type of text generation to use',
30
+ },
31
+ {
32
+ displayName: 'Prompt',
33
+ name: 'textPrompt',
34
+ type: 'string',
35
+ default: '',
36
+ required: true,
37
+ displayOptions: {
38
+ show: {
39
+ operation: ['textGeneration'],
40
+ textGenerationType: ['simple'],
41
+ },
42
+ },
43
+ description: 'Text prompt for generation',
44
+ },
45
+ {
46
+ displayName: 'Model',
47
+ name: 'textModel',
48
+ type: 'options',
49
+ displayOptions: {
50
+ show: {
51
+ operation: ['textGeneration'],
52
+ textGenerationType: ['chat'],
53
+ },
54
+ },
55
+ loadOptionsMethod: 'getTextModels',
56
+ default: '',
57
+ description: 'AI model to use for text generation',
58
+ },
59
+ {
60
+ displayName: 'Messages',
61
+ name: 'messages',
62
+ type: 'fixedCollection',
63
+ typeOptions: {
64
+ multipleValues: true,
65
+ },
66
+ default: { messageValues: [{ role: 'user', content: '' }] },
67
+ displayOptions: {
68
+ show: {
69
+ operation: ['textGeneration'],
70
+ textGenerationType: ['chat'],
71
+ },
72
+ },
73
+ options: [
74
+ {
75
+ name: 'messageValues',
76
+ displayName: 'Message',
77
+ values: [
78
+ {
79
+ displayName: 'Role',
80
+ name: 'role',
81
+ type: 'options',
82
+ options: [
83
+ { name: 'System', value: 'system' },
84
+ { name: 'User', value: 'user' },
85
+ { name: 'Assistant', value: 'assistant' },
86
+ ],
87
+ default: 'user',
88
+ },
89
+ {
90
+ displayName: 'Content',
91
+ name: 'content',
92
+ type: 'string',
93
+ default: '',
94
+ typeOptions: {
95
+ rows: 4,
96
+ },
97
+ },
98
+ ],
99
+ },
100
+ ],
101
+ description: 'Messages for the chat completion',
102
+ },
103
+ {
104
+ displayName: 'Additional Options',
105
+ name: 'textAdditionalOptions',
106
+ type: 'collection',
107
+ placeholder: 'Add Option',
108
+ default: {},
109
+ displayOptions: {
110
+ show: {
111
+ operation: ['textGeneration'],
112
+ textGenerationType: ['chat'],
113
+ },
114
+ },
115
+ options: [
116
+ {
117
+ displayName: 'JSON Mode',
118
+ name: 'jsonMode',
119
+ type: 'boolean',
120
+ default: false,
121
+ description: 'Whether to enable JSON mode (response_format: json_object)',
122
+ },
123
+ {
124
+ displayName: 'Max Tokens',
125
+ name: 'max_tokens',
126
+ type: 'number',
127
+ default: 1000,
128
+ description: 'Maximum number of tokens to generate',
129
+ },
130
+ {
131
+ displayName: 'Reasoning Effort',
132
+ name: 'reasoning_effort',
133
+ type: 'options',
134
+ options: [
135
+ { name: 'High', value: 'high' },
136
+ { name: 'Low', value: 'low' },
137
+ { name: 'Medium', value: 'medium' },
138
+ { name: 'Minimal', value: 'minimal' },
139
+ { name: 'None', value: 'none' },
140
+ ],
141
+ default: 'medium',
142
+ description: 'Reasoning effort for o1/o3/deepseek-r1 models',
143
+ },
144
+ {
145
+ displayName: 'Seed',
146
+ name: 'seed',
147
+ type: 'number',
148
+ default: -1,
149
+ description: 'Random seed for reproducible results (-1 for random)',
150
+ },
151
+ {
152
+ displayName: 'Temperature',
153
+ name: 'temperature',
154
+ type: 'number',
155
+ default: 1,
156
+ description: 'Controls randomness (0-2)',
157
+ typeOptions: {
158
+ minValue: 0,
159
+ maxValue: 2,
160
+ numberPrecision: 1,
161
+ },
162
+ },
163
+ {
164
+ displayName: 'Thinking Budget Tokens',
165
+ name: 'thinking_budget',
166
+ type: 'number',
167
+ default: 0,
168
+ description: 'Token budget for reasoning (thinking) models (0 to disable)',
169
+ },
170
+ {
171
+ displayName: 'Top P',
172
+ name: 'top_p',
173
+ type: 'number',
174
+ default: 1,
175
+ description: 'Nucleus sampling parameter (0-1)',
176
+ typeOptions: {
177
+ minValue: 0,
178
+ maxValue: 1,
179
+ numberPrecision: 2,
180
+ },
181
+ },
182
+ ],
183
+ },
184
+ ];
185
+ async function executeTextGeneration(itemIndex) {
186
+ var _a, _b, _c;
187
+ const generationType = this.getNodeParameter('textGenerationType', itemIndex);
188
+ const headers = { 'Content-Type': 'application/json' };
189
+ try {
190
+ const credentials = await this.getCredentials('pollinationsApi');
191
+ if (credentials === null || credentials === void 0 ? void 0 : credentials.apiKey) {
192
+ headers['Authorization'] = `Bearer ${credentials.apiKey}`;
193
+ }
194
+ }
195
+ catch {
196
+ }
197
+ if (generationType === 'simple') {
198
+ const prompt = this.getNodeParameter('textPrompt', itemIndex);
199
+ const url = `https://gen.pollinations.ai/text/${encodeURIComponent(prompt)}`;
200
+ try {
201
+ const response = await this.helpers.httpRequest({
202
+ method: 'GET',
203
+ url,
204
+ headers,
205
+ });
206
+ return {
207
+ json: {
208
+ prompt,
209
+ text: response,
210
+ },
211
+ pairedItem: { item: itemIndex },
212
+ };
213
+ }
214
+ catch (error) {
215
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to generate text: ${error.message}`, { itemIndex });
216
+ }
217
+ }
218
+ else {
219
+ const model = this.getNodeParameter('textModel', itemIndex);
220
+ const messagesData = this.getNodeParameter('messages', itemIndex);
221
+ const additionalOptions = this.getNodeParameter('textAdditionalOptions', itemIndex, {});
222
+ const messages = messagesData.messageValues.map((msg) => {
223
+ if (msg.image_url) {
224
+ return {
225
+ role: msg.role,
226
+ content: [
227
+ { type: 'text', text: msg.content },
228
+ { type: 'image_url', image_url: { url: msg.image_url } },
229
+ ],
230
+ };
231
+ }
232
+ return {
233
+ role: msg.role,
234
+ content: msg.content,
235
+ };
236
+ });
237
+ const body = {
238
+ model,
239
+ messages,
240
+ };
241
+ if (additionalOptions.temperature !== undefined)
242
+ body.temperature = additionalOptions.temperature;
243
+ if (additionalOptions.max_tokens)
244
+ body.max_tokens = additionalOptions.max_tokens;
245
+ if (additionalOptions.top_p !== undefined)
246
+ body.top_p = additionalOptions.top_p;
247
+ if (additionalOptions.seed !== undefined && additionalOptions.seed !== -1) {
248
+ body.seed = additionalOptions.seed;
249
+ }
250
+ if (additionalOptions.jsonMode) {
251
+ body.response_format = { type: 'json_object' };
252
+ }
253
+ if (additionalOptions.reasoning_effort) {
254
+ body.reasoning_effort = additionalOptions.reasoning_effort;
255
+ }
256
+ if (additionalOptions.thinking_budget) {
257
+ body.thinking = {
258
+ type: 'enabled',
259
+ budget_tokens: additionalOptions.thinking_budget,
260
+ };
261
+ }
262
+ try {
263
+ const response = await this.helpers.httpRequest({
264
+ method: 'POST',
265
+ url: 'https://gen.pollinations.ai/v1/chat/completions',
266
+ headers,
267
+ body,
268
+ });
269
+ return {
270
+ json: {
271
+ model,
272
+ messages,
273
+ response: response,
274
+ text: ((_c = (_b = (_a = response.choices) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.message) === null || _c === void 0 ? void 0 : _c.content) || '',
275
+ },
276
+ pairedItem: { item: itemIndex },
277
+ };
278
+ }
279
+ catch (error) {
280
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to generate chat completion: ${error.message}`, { itemIndex });
281
+ }
282
+ }
283
+ }
284
+ //# sourceMappingURL=textGeneration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textGeneration.js","sourceRoot":"","sources":["../../../../nodes/Pollinations/operations/textGeneration.ts"],"names":[],"mappings":";;;AA0LA,sDA4HC;AArTD,+CAAkD;AAErC,QAAA,uBAAuB,GAAsB;IACzD;QACC,WAAW,EAAE,iBAAiB;QAC9B,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,SAAS;QACf,cAAc,EAAE;YACf,IAAI,EAAE;gBACL,SAAS,EAAE,CAAC,gBAAgB,CAAC;aAC7B;SACD;QACD,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,QAAQ;gBACf,WAAW,EAAE,qCAAqC;aAClD;YACD;gBACC,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,MAAM;gBAC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,IAAI,iBAAiB,CAAC,eAAe,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,GAAG;gBACf,IAAI,EAAE,SAAS;gBACf,aAAa,EAAE,iBAAiB,CAAC,eAAe;aAChD,CAAC;QACH,CAAC;QAED,IAAI,CAAC;YACJ,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;gBAC/C,MAAM,EAAE,MAAM;gBACd,GAAG,EAAE,iDAAiD;gBACtD,OAAO;gBACP,IAAI;aACJ,CAAC,CAAC;YAEH,OAAO;gBACN,IAAI,EAAE;oBACL,KAAK;oBACL,QAAQ;oBACR,QAAQ,EAAE,QAAQ;oBAClB,IAAI,EAAE,CAAA,MAAA,MAAA,MAAA,QAAQ,CAAC,OAAO,0CAAG,CAAC,CAAC,0CAAE,OAAO,0CAAE,OAAO,KAAI,EAAE;iBACnD;gBACD,UAAU,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;aAC/B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,iCAAkB,CAC3B,IAAI,CAAC,OAAO,EAAE,EACd,uCAAuC,KAAK,CAAC,OAAO,EAAE,EACtD,EAAE,SAAS,EAAE,CACb,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
2
+ export declare const videoGenerationOperation: INodeProperties[];
3
+ export declare function executeVideoGeneration(this: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData>;