n8n-nodes-kieai-ahmed
v1.0.10
Published
n8n community node for Kie.ai API - Image, Video, and Music generation
Maintainers
Readme
n8n-nodes-kieai
Kie.ai n8n Community Node
This is a community node for n8n that allows you to interact with the Kie.ai API for image, video, and music generation.
Features
- Image Generation: Text-to-image, Image-to-image, Upscale image with models like Midjourney, Flux, Nano Banana.
- Video Generation: Text-to-video, Image-to-video with models like Kling, Runway, Veo.
- Music Generation: Generate music from prompt with models like Suno.
- Task Status: Get task status and polling helper for asynchronous operations.
- Fetch Result: Fetch generated file URLs and download results as binary data.
Installation
To install this community node, you can use the n8n in-app installation or manually install it.
In-App Installation
- Go to Settings > Community Nodes in your n8n instance.
- Click on Install a custom community node.
- Enter
n8n-nodes-kieaias the package name. - Click Install.
Manual Installation
- Navigate to your n8n custom nodes folder (e.g.,
~/.n8n/custom). - Clone this repository:
git clone https://github.com/manus/n8n-nodes-kieai.git cd n8n-nodes-kieai - Install dependencies and build the project:
npm install npm run build - Restart your n8n instance.
npm Publish
To publish this package to npm, ensure you are logged in to npm and have the necessary permissions.
npm publishLocal Development
- Clone the repository:
git clone https://github.com/manus/n8n-nodes-kieai.git cd n8n-nodes-kieai - Install dependencies:
npm install - Start development mode (watches for changes and recompiles):
npm run dev - Link the node to your n8n instance (if running locally):
npm link # In your n8n directory npm link n8n-nodes-kieai
Testing
To run linting checks:
npm run lintTo fix linting issues automatically:
npm run lintfixScreenshots (Placeholders)
Kie.ai Credentials Setup
Image Generation Node
Video Generation Node
Music Generation Node
Task Status Node
Credentials Setup
To use the Kie.ai node, you need to provide your API Key.
- In n8n, click on Credentials in the left sidebar.
- Click New Credential.
- Search for
Kie.ai API. - Enter your
API Key(Bearer Token) obtained from Kie.ai API Key Management Page. - Click Save.
Example Workflows
Example workflows are provided in the examples/ directory:
image-generation.json: Demonstrates text-to-image generation.video-generation.json: Demonstrates text-to-video generation.music-generation.json: Demonstrates music generation from a prompt.polling-workflow.json: Demonstrates creating a task, polling its status, and downloading the result.
To import an example workflow:
- In n8n, go to Workflows.
- Click New > Import from JSON.
- Upload the desired
.jsonfile from theexamples/directory.
Polling Explanation
Kie.ai API operations are asynchronous. When you initiate a generation task (image, video, music), the API returns a taskId. You then need to poll the task status using the Task resource and Get Task Status operation. The node supports automatic polling with configurable Max Retries and Retry Interval.
- Pending/Processing: The task is still being processed.
- Success: The task completed successfully, and results are available.
- Fail/Cancelled: The task failed or was cancelled.
Supported Models
Image Generation
- Midjourney
- Flux
- Nano Banana
- Grok Imagine
Video Generation
- Kling
- Runway
- Veo
Music Generation
- Suno
Troubleshooting
- 401 Unauthorized: Ensure your API Key is correctly entered in the credentials.
- Task Failed: Check the
failMsgin the task status for details. This often indicates an issue with the input parameters. - Timeout: Increase
Max RetriesorRetry Intervalin the Task Status node if your tasks take longer to complete.
Development Scripts
npm install: Install project dependencies.npm run build: Compile TypeScript to JavaScript and copy assets.npm run dev: Watch for changes and recompile during development.npm run lint: Run ESLint to check for code style and errors.npm run lintfix: Run ESLint and automatically fix issues.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Example API Payloads from Kie.ai Docs
Get Task Details (Response Example)
{
"code": 505,
"msg": "success",
"data": {
"taskId": "task_12345678",
"model": "grok-imagine/text-to-image",
"state": "success",
"param": "{\"model\":\"grok-imagine/text-to-image\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"input\":{\"prompt\":\"Cinematic portrait...\",\"aspect_ratio\":\"3:2\"}}",
"resultJson": "{\"resultUrls\":[\"https://example.com/generated-content.jpg\"]}",
"failCode": "",
"failMsg": "",
"costTime": 15000,
"completeTime": 1698765432000,
"createTime": 1698765400000,
"updateTime": 1698765432000,
"progress": 45,
"creditsConsumed": 50
}
}Generate Music (Request Example)
{
"customMode": true,
"instrumental": true,
"model": "V4",
"callBackUrl": "https://api.example.com/callback",
"style": "Classical",
"title": "Peaceful Piano Meditation",
"negativeTags": "Heavy Metal, Upbeat Drums",
"vocalGender": "m",
"styleWeight": 0.65,
"weirdnessConstraint": 0.65,
"audioWeight": 0.65,
"personaId": "persona_123",
"personaModel": "style_persona"
}