n8n-nodes-kimi-ai
v0.1.2
Published
Kimi AI (Moonshot AI) n8n custom node for chat completions, multi-turn conversations, streaming, and memory management.
Downloads
391
Maintainers
Readme
Kimi AI n8n Node
This is a custom n8n node for interacting with the Kimi AI (Moonshot AI) API, designed to provide a seamless and powerful integration for conversational AI workflows. It supports chat completions, multi-turn conversations with robust memory management, streaming responses, and advanced AI features.
Features
- Chat Completions: Engage in dynamic conversations with the Kimi AI model.
- Multi-turn Conversations: Maintain context across multiple interactions with internal memory management.
- Persistent Memory Handling: Supports session-based memory to keep track of conversation history.
- Streaming Responses: Receive responses in real-time for a more interactive user experience.
- System Prompts: Guide the AI's behavior with customizable system prompts.
- JSON Mode: Obtain structured JSON responses for easier parsing and integration.
- Tool/Function Calling Preparation: Designed with future tool/function calling capabilities in mind.
- Long Context Optimization: Handles longer conversations efficiently.
- Workflow-friendly AI Automation: Built for integration into various n8n workflows, including chatbots and autonomous agents.
- Model Listing: Easily retrieve a list of available Kimi AI models.
Installation
To install this custom node, you will need to have n8n installed and running. Follow these steps:
Clone the repository (or download the source code):
git clone https://github.com/manus-ai/n8n-nodes-kimi-ai.git cd n8n-nodes-kimi-aiInstall dependencies:
npm installBuild the node:
npm run buildLink the node to your n8n instance:
npm link # Then, in your n8n installation directory: npm link n8n-nodes-kimi-aiRestart n8n to load the new node.
Credentials
This node uses API Key authentication.
- In n8n, go to Credentials.
- Add a new credential of type
Kimi AI API. - Enter your
API Keyobtained from the Kimi Open Platform.- The API Key will be used in the
Authorization: Bearer {{API_KEY}}header.
- The API Key will be used in the
Usage
Chat Completion
- Drag and drop the Kimi AI node onto your workflow.
- Select Resource:
Chat. - Select Operation:
Chat Completion. - Provide a
User Message. - (Optional) Configure
System Promptto guide the AI. - (Optional) Choose a
Memory Mode:No Memory: Each request is independent.Session Memory: Maintains conversation history based on aSession ID.
- (Optional) Adjust
Optionssuch asTemperature,Max Tokens,JSON Mode, andStream.
Model Listing
- Drag and drop the Kimi AI node onto your workflow.
- Select Resource:
Model. - Select Operation:
List. - Execute the node to get a list of available Kimi AI models.
Memory Management
The Kimi API is stateless. This node implements internal conversation memory management to support multi-turn conversations. When Session Memory is enabled, the node will:
- Automatically manage the
messagesarray, including user and assistant history. - Implement a rolling context window to keep the conversation within the model's token limits.
- Ensure system prompts persist across turns.
Streaming Support
When the Stream option is enabled for chat completions, the node will:
- Handle SSE (Server-Sent Events) streaming.
- Process partial token streaming and aggregate chunks for progressive output.
Error Handling
The node includes robust error handling for common API issues such as:
- Invalid API keys
- Rate limits
- Token overflow
- Malformed messages
- Streaming interruptions
- Timeout errors
User-friendly n8n errors will be returned for easier debugging.
Advanced AI Features
- JSON Mode: Request responses in a structured JSON format.
- AI Agent Compatibility: Designed to work seamlessly within AI agent workflows.
- Function/Tool Calling Preparation: Architectural support for future integration of tool calling.
- Context Optimization: Strategies to manage and optimize conversation context.
Deliverables
This project provides the following files:
packages/nodes/KimiAI/KimiAI.node.ts: The main n8n node definition.packages/credentials/KimiApiCredentials.ts: API key credential definition.packages/memoryManager/MemoryManager.ts: Logic for managing conversation history.packages/streamingParser/StreamingParser.ts: Handles parsing of streaming responses.packages/utils/Transport.ts: Reusable transport layer for API requests.packages/resources/ChatResource.ts: Defines chat-related operations and fields.packages/resources/ModelResource.ts: Defines model-related operations and fields.packages/nodes/KimiAI/kimi.svg: Node icon.package.json: Project dependencies and scripts.tsconfig.json: TypeScript configuration.README.md: This documentation file.
Future Enhancements
Potential future features include:
- Conversation export/import.
- Automatic summarization of old context.
- Embedding-ready architecture and Vector DB compatibility.
- Full AI Agent mode and Tool calling abstraction layer.
- Prompt templates.
- Binary and file support (PDF context, text files, RAG ingestion, file summarization).
Author: Manus AI Homepage: https://www.manus.im Repository: https://github.com/manus-ai/n8n-nodes-kimi-ai
