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.
package/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright 2022 n8n
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7
+ of the Software, and to permit persons to whom the Software is furnished to do
8
+ so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # n8n-nodes-pollinations-ai
2
+
3
+ This is an n8n community node for [Pollinations.ai](https://pollinations.ai) - a unified platform for AI-powered image, video, text, and audio generation.
4
+
5
+ [n8n](https://n8n.io/) is a [fair-code licensed](https://docs.n8n.io/reference/license/) workflow automation platform.
6
+
7
+ ## Features
8
+
9
+ - **Image Generation**: Create images using multiple AI models (Flux, Turbo, GPT Image, Kontext, and more)
10
+ - **Video Generation**: Generate videos from text or images (Veo, Seedance models)
11
+ - **Text Generation**: Use 20+ language models including OpenAI, Claude, Gemini, Mistral, and more
12
+ - **Audio Generation**: Convert text to speech with 13 different voices and 5 audio formats
13
+ - **OpenAI-Compatible**: Chat completions endpoint compatible with OpenAI API format
14
+ - **Vision Support**: Analyze and describe images using multimodal models
15
+
16
+ ## Installation
17
+
18
+ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes/installation/) in the n8n community nodes documentation.
19
+
20
+ ### Manual Installation
21
+
22
+ 1. Go to **Settings** > **Community Nodes**
23
+ 2. Select **Install**
24
+ 3. Enter `n8n-nodes-pollinations-ai` in **Enter npm package name**
25
+ 4. Agree to the risks and select **Install**
26
+
27
+ ## Credentials
28
+
29
+ To use this node, you'll need a Pollinations API key:
30
+
31
+ 1. Visit [enter.pollinations.ai](https://enter.pollinations.ai)
32
+ 2. Sign up or log in
33
+ 3. **Create a Secret Key (sk\_)** - Required for n8n server-side use
34
+ 4. Add the API key to your n8n credentials
35
+
36
+ ### API Key Types
37
+
38
+ Pollinations offers two types of API keys:
39
+
40
+ - **Secret Keys (`sk_`)** ⭐ **Recommended for n8n**
41
+ - Server-side only, no rate limits
42
+ - Keep secret - never expose publicly
43
+ - Perfect for n8n workflows
44
+
45
+ - **Publishable Keys (`pk_`)** ⚠️ **Not recommended for n8n**
46
+ - Beta - not ready for production
47
+ - IP rate-limited (1 pollen per IP per hour)
48
+ - For client-side apps only
49
+ - Will consume your Pollen if exposed in public code
50
+
51
+ **Important**: Always use **Secret Keys (sk\_)** in n8n for unlimited, server-side access.
52
+
53
+ ## Operations
54
+
55
+ ### Image Generation
56
+
57
+ Generate images from text prompts using various AI models.
58
+
59
+ **Models Available**:
60
+
61
+ - Flux (default) - High-quality image generation
62
+ - Turbo - Fast image generation
63
+ - GPT Image - GPT-powered images
64
+ - Kontext - Supports image-to-image transformation
65
+ - Seedream - Creative generation
66
+ - Nanobanana / Nanobanana Pro - Lightweight models
67
+
68
+ **Parameters**:
69
+
70
+ - Prompt (required)
71
+ - Model selection
72
+ - Width & Height (16-2048px)
73
+ - Seed (for reproducibility)
74
+ - **Advanced Options**:
75
+ - Image Count (1-4 for premium models)
76
+ - Negative Prompt (exclude content)
77
+ - Quality Level (for `gptimage` model)
78
+ - Transparent Background (for `gptimage` model)
79
+ - Content Filters (Safe Mode)
80
+ - Prompt Enhancement
81
+ - Input image URL (for image-to-image/edit)
82
+
83
+ ### Video Generation
84
+
85
+ Create videos from text descriptions or images.
86
+
87
+ **Models Available**:
88
+
89
+ - Veo - Text-to-video (4-8 seconds)
90
+ - Seedance - Text-to-video and image-to-video (2-10 seconds)
91
+
92
+ **Parameters**:
93
+
94
+ - Prompt (required)
95
+ - Model selection
96
+ - Width & Height
97
+ - Seed
98
+ - **Advanced Options**:
99
+ - Aspect Ratio (16:9, 9:16)
100
+ - Duration (2-10 seconds)
101
+ - Enable Audio (for `veo` model)
102
+ - Negative Prompt
103
+ - Safe Mode Filtering
104
+ - Input image URL (for image-to-video or frame interpolation)
105
+
106
+ ### Text Generation
107
+
108
+ Generate text using advanced language models.
109
+
110
+ **Generation Types**:
111
+
112
+ 1. **Simple Text**: Quick text generation from a prompt
113
+ 2. **Chat Completion**: OpenAI-compatible chat with conversation history
114
+
115
+ **Models Available**: OpenAI, Claude, Gemini, Mistral, DeepSeek, Grok, Qwen Coder, Perplexity, and more (20+ models)
116
+
117
+ **Parameters**:
118
+
119
+ - Messages (for chat completion)
120
+ - Temperature, Max Tokens, Top P
121
+ - Seed for reproducibility
122
+ - **Advanced Options**:
123
+ - JSON Mode (returns structured data)
124
+ - Reasoning Effort (for thinking models)
125
+ - Thinking Budget Tokens (for o1/o3/R1 models)
126
+
127
+ ### Audio Generation
128
+
129
+ Convert text to speech with multiple voices and formats.
130
+
131
+ **Voices Available**: Alloy, Echo, Fable, Onyx, Nova, Shimmer, Coral, Verse, Ballad, Ash, Sage, Amuch, Dan
132
+
133
+ **Audio Formats**: WAV, MP3, FLAC, Opus, PCM16
134
+
135
+ ## Usage Examples
136
+
137
+ ### Generate an Image
138
+
139
+ 1. Add the Pollinations node to your workflow
140
+ 2. Select **Image Generation** operation
141
+ 3. Enter your prompt: "A beautiful sunset over mountains"
142
+ 4. Choose model (e.g., Flux)
143
+ 5. Set dimensions (e.g., 1024x1024)
144
+ 6. Execute the node
145
+
146
+ The generated image will be available as binary data.
147
+
148
+ ### Create a Video
149
+
150
+ 1. Add the Pollinations node
151
+ 2. Select **Video Generation** operation
152
+ 3. Enter prompt: "A cat playing with a ball"
153
+ 4. Choose model (Veo or Seedance)
154
+ 5. Execute the node
155
+
156
+ ### Generate Text with Chat
157
+
158
+ 1. Add the Pollinations node
159
+ 2. Select **Text Generation** operation
160
+ 3. Choose **Chat Completion** type
161
+ 4. Select model (e.g., OpenAI, Claude, Gemini)
162
+ 5. Add messages with roles (system, user, assistant)
163
+ 6. Execute the node
164
+
165
+ ### Text-to-Speech
166
+
167
+ 1. Add the Pollinations node
168
+ 2. Select **Audio Generation** operation
169
+ 3. Enter text to convert
170
+ 4. Choose voice (e.g., Nova, Alloy)
171
+ 5. Select audio format (MP3, WAV, etc.)
172
+ 6. Execute the node
173
+
174
+ ## Resources
175
+
176
+ - [n8n community nodes documentation](https://docs.n8n.io/integrations/community-nodes/)
177
+ - [Pollinations.ai Official Site](https://pollinations.ai)
178
+ - [Pollinations API Documentation](https://enter.pollinations.ai/api/docs)
179
+ - [GitHub Repository](https://github.com/isaacgounton/n8n-nodes-pollinations)
180
+
181
+ ## Version History
182
+
183
+ See [CHANGELOG.md](CHANGELOG.md) for version history.
184
+
185
+ ## License
186
+
187
+ [MIT](LICENSE.md)
@@ -0,0 +1,10 @@
1
+ import type { IAuthenticateGeneric, ICredentialTestRequest, ICredentialType, Icon, INodeProperties } from 'n8n-workflow';
2
+ export declare class PollinationsApi implements ICredentialType {
3
+ name: string;
4
+ displayName: string;
5
+ icon: Icon;
6
+ documentationUrl: string;
7
+ properties: INodeProperties[];
8
+ authenticate: IAuthenticateGeneric;
9
+ test: ICredentialTestRequest;
10
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PollinationsApi = void 0;
4
+ class PollinationsApi {
5
+ constructor() {
6
+ this.name = 'pollinationsApi';
7
+ this.displayName = 'Pollinations API';
8
+ this.icon = 'file:../nodes/Pollinations/pollinations.svg';
9
+ this.documentationUrl = 'https://pollinations.ai';
10
+ this.properties = [
11
+ {
12
+ displayName: 'API Key',
13
+ name: 'apiKey',
14
+ type: 'string',
15
+ typeOptions: { password: true },
16
+ default: '',
17
+ description: 'Your Pollinations Secret Key (sk_). Get one at https://enter.pollinations.ai. Use Secret Keys for server-side n8n workflows, not Publishable Keys (pk_).',
18
+ },
19
+ ];
20
+ this.authenticate = {
21
+ type: 'generic',
22
+ properties: {
23
+ headers: {
24
+ Authorization: '=Bearer {{$credentials.apiKey}}',
25
+ },
26
+ },
27
+ };
28
+ this.test = {
29
+ request: {
30
+ baseURL: 'https://gen.pollinations.ai',
31
+ url: '/account/balance',
32
+ method: 'GET',
33
+ },
34
+ };
35
+ }
36
+ }
37
+ exports.PollinationsApi = PollinationsApi;
38
+ //# sourceMappingURL=PollinationsApi.credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PollinationsApi.credentials.js","sourceRoot":"","sources":["../../credentials/PollinationsApi.credentials.ts"],"names":[],"mappings":";;;AAQA,MAAa,eAAe;IAA5B;QACC,SAAI,GAAG,iBAAiB,CAAC;QAEzB,gBAAW,GAAG,kBAAkB,CAAC;QAEjC,SAAI,GAAG,6CAAqD,CAAC;QAE7D,qBAAgB,GAAG,yBAAyB,CAAC;QAE7C,eAAU,GAAsB;YAC/B;gBACC,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAC/B,OAAO,EAAE,EAAE;gBACX,WAAW,EAAE,0JAA0J;aACvK;SACD,CAAC;QAEF,iBAAY,GAAyB;YACpC,IAAI,EAAE,SAAS;YACf,UAAU,EAAE;gBACX,OAAO,EAAE;oBACR,aAAa,EAAE,iCAAiC;iBAChD;aACD;SACD,CAAC;QAEF,SAAI,GAA2B;YAC9B,OAAO,EAAE;gBACR,OAAO,EAAE,6BAA6B;gBACtC,GAAG,EAAE,kBAAkB;gBACvB,MAAM,EAAE,KAAK;aACb;SACD,CAAC;IACH,CAAC;CAAA;AApCD,0CAoCC"}
@@ -0,0 +1,12 @@
1
+ import type { IExecuteFunctions, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class Pollinations implements INodeType {
3
+ description: INodeTypeDescription;
4
+ methods: {
5
+ loadOptions: {
6
+ getImageModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
7
+ getVideoModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
8
+ getTextModels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]>;
9
+ };
10
+ };
11
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
12
+ }
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pollinations = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const imageGeneration_1 = require("./operations/imageGeneration");
6
+ const videoGeneration_1 = require("./operations/videoGeneration");
7
+ const textGeneration_1 = require("./operations/textGeneration");
8
+ const audioGeneration_1 = require("./operations/audioGeneration");
9
+ class Pollinations {
10
+ constructor() {
11
+ this.description = {
12
+ displayName: 'Pollinations',
13
+ name: 'pollinations',
14
+ icon: 'file:pollinations.svg',
15
+ group: ['transform'],
16
+ version: 1,
17
+ subtitle: '={{$parameter["operation"]}}',
18
+ description: 'Generate images, videos, text, and audio using Pollinations.ai',
19
+ defaults: {
20
+ name: 'Pollinations',
21
+ },
22
+ usableAsTool: true,
23
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
24
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
25
+ credentials: [
26
+ {
27
+ name: 'pollinationsApi',
28
+ required: false,
29
+ displayOptions: {
30
+ show: {
31
+ '@version': [1],
32
+ },
33
+ },
34
+ },
35
+ ],
36
+ properties: [
37
+ {
38
+ displayName: 'Operation',
39
+ name: 'operation',
40
+ type: 'options',
41
+ noDataExpression: true,
42
+ options: [
43
+ {
44
+ name: 'Image Generation',
45
+ value: 'imageGeneration',
46
+ description: 'Generate images from text prompts',
47
+ action: 'Generate an image',
48
+ },
49
+ {
50
+ name: 'Video Generation',
51
+ value: 'videoGeneration',
52
+ description: 'Generate videos from text or images',
53
+ action: 'Generate a video',
54
+ },
55
+ {
56
+ name: 'Text Generation',
57
+ value: 'textGeneration',
58
+ description: 'Generate text using AI language models',
59
+ action: 'Generate text',
60
+ },
61
+ {
62
+ name: 'Audio Generation',
63
+ value: 'audioGeneration',
64
+ description: 'Generate audio/speech from text',
65
+ action: 'Generate audio',
66
+ },
67
+ ],
68
+ default: 'imageGeneration',
69
+ },
70
+ ...imageGeneration_1.imageGenerationOperation,
71
+ ...videoGeneration_1.videoGenerationOperation,
72
+ ...textGeneration_1.textGenerationOperation,
73
+ ...audioGeneration_1.audioGenerationOperation,
74
+ ],
75
+ };
76
+ this.methods = {
77
+ loadOptions: {
78
+ async getImageModels() {
79
+ const models = (await this.helpers.httpRequest({
80
+ method: 'GET',
81
+ url: 'https://gen.pollinations.ai/image/models',
82
+ }));
83
+ return models
84
+ .filter((m) => { var _a; return (_a = m.output_modalities) === null || _a === void 0 ? void 0 : _a.includes('image'); })
85
+ .map((m) => ({
86
+ name: m.name.charAt(0).toUpperCase() + m.name.slice(1),
87
+ value: m.name,
88
+ }))
89
+ .sort((a, b) => a.name.localeCompare(b.name));
90
+ },
91
+ async getVideoModels() {
92
+ const models = (await this.helpers.httpRequest({
93
+ method: 'GET',
94
+ url: 'https://gen.pollinations.ai/image/models',
95
+ }));
96
+ return models
97
+ .filter((m) => { var _a; return (_a = m.output_modalities) === null || _a === void 0 ? void 0 : _a.includes('video'); })
98
+ .map((m) => ({
99
+ name: m.name.charAt(0).toUpperCase() + m.name.slice(1),
100
+ value: m.name,
101
+ }))
102
+ .sort((a, b) => a.name.localeCompare(b.name));
103
+ },
104
+ async getTextModels() {
105
+ const response = (await this.helpers.httpRequest({
106
+ method: 'GET',
107
+ url: 'https://gen.pollinations.ai/v1/models',
108
+ }));
109
+ return response.data
110
+ .map((m) => ({
111
+ name: m.id.charAt(0).toUpperCase() + m.id.slice(1).replace(/-/g, ' '),
112
+ value: m.id,
113
+ }))
114
+ .sort((a, b) => a.name.localeCompare(b.name));
115
+ },
116
+ },
117
+ };
118
+ }
119
+ async execute() {
120
+ const items = this.getInputData();
121
+ const returnData = [];
122
+ const operation = this.getNodeParameter('operation', 0);
123
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
124
+ try {
125
+ let result;
126
+ switch (operation) {
127
+ case 'imageGeneration':
128
+ result = await imageGeneration_1.executeImageGeneration.call(this, itemIndex);
129
+ break;
130
+ case 'videoGeneration':
131
+ result = await videoGeneration_1.executeVideoGeneration.call(this, itemIndex);
132
+ break;
133
+ case 'textGeneration':
134
+ result = await textGeneration_1.executeTextGeneration.call(this, itemIndex);
135
+ break;
136
+ case 'audioGeneration':
137
+ result = await audioGeneration_1.executeAudioGeneration.call(this, itemIndex);
138
+ break;
139
+ default:
140
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Unknown operation: ${operation}`, { itemIndex });
141
+ }
142
+ returnData.push(result);
143
+ }
144
+ catch (error) {
145
+ if (this.continueOnFail()) {
146
+ returnData.push({
147
+ json: this.getInputData(itemIndex)[0].json,
148
+ error,
149
+ pairedItem: { item: itemIndex },
150
+ });
151
+ }
152
+ else {
153
+ throw error;
154
+ }
155
+ }
156
+ }
157
+ return [returnData];
158
+ }
159
+ }
160
+ exports.Pollinations = Pollinations;
161
+ //# sourceMappingURL=Pollinations.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pollinations.node.js","sourceRoot":"","sources":["../../../nodes/Pollin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E,SAAS,EAAE;qBAC/B,CAAC,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACP,MAAM,KAAK,CAAC;gBACb,CAAC;YACF,CAAC;QACF,CAAC;QAED,OAAO,CAAC,UAAU,CAAC,CAAC;IACrB,CAAC;CACD;AA/JD,oCA+JC"}
@@ -0,0 +1,3 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
2
+ export declare const audioGenerationOperation: INodeProperties[];
3
+ export declare function executeAudioGeneration(this: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData>;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.audioGenerationOperation = void 0;
4
+ exports.executeAudioGeneration = executeAudioGeneration;
5
+ const n8n_workflow_1 = require("n8n-workflow");
6
+ exports.audioGenerationOperation = [
7
+ {
8
+ displayName: 'Text',
9
+ name: 'audioText',
10
+ type: 'string',
11
+ default: '',
12
+ required: true,
13
+ displayOptions: {
14
+ show: {
15
+ operation: ['audioGeneration'],
16
+ },
17
+ },
18
+ description: 'Text to convert to speech',
19
+ typeOptions: {
20
+ rows: 4,
21
+ },
22
+ },
23
+ {
24
+ displayName: 'Voice',
25
+ name: 'voice',
26
+ type: 'options',
27
+ displayOptions: {
28
+ show: {
29
+ operation: ['audioGeneration'],
30
+ },
31
+ },
32
+ options: [
33
+ { name: 'Alloy', value: 'alloy' },
34
+ { name: 'Amuch', value: 'amuch' },
35
+ { name: 'Ash', value: 'ash' },
36
+ { name: 'Ballad', value: 'ballad' },
37
+ { name: 'Coral', value: 'coral' },
38
+ { name: 'Dan', value: 'dan' },
39
+ { name: 'Echo', value: 'echo' },
40
+ { name: 'Fable', value: 'fable' },
41
+ { name: 'Nova', value: 'nova' },
42
+ { name: 'Onyx', value: 'onyx' },
43
+ { name: 'Sage', value: 'sage' },
44
+ { name: 'Shimmer', value: 'shimmer' },
45
+ { name: 'Verse', value: 'verse' },
46
+ ],
47
+ default: 'alloy',
48
+ description: 'Voice to use for text-to-speech',
49
+ },
50
+ {
51
+ displayName: 'Audio Format',
52
+ name: 'audioFormat',
53
+ type: 'options',
54
+ displayOptions: {
55
+ show: {
56
+ operation: ['audioGeneration'],
57
+ },
58
+ },
59
+ options: [
60
+ { name: 'FLAC', value: 'flac' },
61
+ { name: 'MP3', value: 'mp3' },
62
+ { name: 'Opus', value: 'opus' },
63
+ { name: 'PCM16', value: 'pcm16' },
64
+ { name: 'WAV', value: 'wav' },
65
+ ],
66
+ default: 'mp3',
67
+ description: 'Audio output format',
68
+ },
69
+ ];
70
+ async function executeAudioGeneration(itemIndex) {
71
+ var _a, _b, _c, _d, _e, _f, _g, _h;
72
+ const text = this.getNodeParameter('audioText', itemIndex);
73
+ const voice = this.getNodeParameter('voice', itemIndex);
74
+ const format = this.getNodeParameter('audioFormat', itemIndex);
75
+ const headers = { 'Content-Type': 'application/json' };
76
+ try {
77
+ const credentials = await this.getCredentials('pollinationsApi');
78
+ if (credentials === null || credentials === void 0 ? void 0 : credentials.apiKey) {
79
+ headers['Authorization'] = `Bearer ${credentials.apiKey}`;
80
+ }
81
+ }
82
+ catch {
83
+ }
84
+ const body = {
85
+ model: 'openai-audio',
86
+ messages: [
87
+ {
88
+ role: 'user',
89
+ content: text,
90
+ },
91
+ ],
92
+ modalities: ['text', 'audio'],
93
+ audio: {
94
+ voice,
95
+ format,
96
+ },
97
+ };
98
+ try {
99
+ const response = await this.helpers.httpRequest({
100
+ method: 'POST',
101
+ url: 'https://gen.pollinations.ai/v1/chat/completions',
102
+ headers,
103
+ body,
104
+ });
105
+ const audioData = (_d = (_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.audio) === null || _d === void 0 ? void 0 : _d.data;
106
+ if (!audioData) {
107
+ throw new Error('No audio data in response');
108
+ }
109
+ const audioBuffer = Buffer.from(audioData, 'base64');
110
+ const binaryData = await this.helpers.prepareBinaryData(audioBuffer, `audio_${itemIndex}.${format}`, `audio/${format}`);
111
+ return {
112
+ json: {
113
+ text,
114
+ voice,
115
+ format,
116
+ transcript: ((_h = (_g = (_f = (_e = response.choices) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.message) === null || _g === void 0 ? void 0 : _g.audio) === null || _h === void 0 ? void 0 : _h.transcript) || text,
117
+ },
118
+ binary: {
119
+ data: binaryData,
120
+ },
121
+ pairedItem: { item: itemIndex },
122
+ };
123
+ }
124
+ catch (error) {
125
+ throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Failed to generate audio: ${error.message}`, { itemIndex });
126
+ }
127
+ }
128
+ //# sourceMappingURL=audioGeneration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audioGeneration.js","sourceRoot":"","sources":["../../../../nodes/Pollinations/operations/audioGeneration.ts"],"names":[],"mappings":";;;AAoEA,wDA2EC;AA9ID,+CAAkD;AAErC,QAAA,wBAAwB,GAAsB;IAC1D;QACC,WAAW,EAAE,MAAM;QACnB,IAAI,EAAE,WAAW;QACjB,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,2BAA2B;QACxC,WAAW,EAAE;YACZ,IAAI,EAAE,CAAC;SACP;KACD;IACD;QACC,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,OAAO,EAAE;YACR,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YACjC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;YACjC,EAAE,IAAI,EAAE,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AS,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC9C,CAAC;QAGD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,iBAAiB,CACtD,WAAW,EACX,SAAS,SAAS,IAAI,MAAM,EAAE,EAC9B,SAAS,MAAM,EAAE,CACjB,CAAC;QAEF,OAAO;YACN,IAAI,EAAE;gBACL,IAAI;gBACJ,KAAK;gBACL,MAAM;gBACN,UAAU,EAAE,CAAA,MAAA,MAAA,MAAA,MAAA,QAAQ,CAAC,OAAO,0CAAG,CAAC,CAAC,0CAAE,OAAO,0CAAE,KAAK,0CAAE,UAAU,KAAI,IAAI;aACrE;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 imageGenerationOperation: INodeProperties[];
3
+ export declare function executeImageGeneration(this: IExecuteFunctions, itemIndex: number): Promise<INodeExecutionData>;