Custom embedding nodes for n8n with support for both standalone and sub-node modes
npm install n8n-nodes-custom-embedding/embed - generate embeddings for texts
/similarity - calculate similarity between two texts
embedding (special type for n8n AI integration)
ai_embedding (for AI integration)
supplyData() - provides embedding functionality to parent nodes
main (standard input)
main (standard output with embedding data)
execute() - processes input data and returns embeddings
bash
npm install n8n-nodes-custom-embedding
`
2. Restart n8n
3. Configure Credentials (see Credentials section below)
$3
1. Clone the repository:
`bash
git clone https://github.com/24auru/n8n-nodes-custom-embedding.git
cd n8n-nodes-custom-embedding
`
2. Install dependencies:
`bash
npm install
`
3. Build the project:
`bash
npm run build
`
๐ Credentials
$3
Configure connection to your API service:
- Host (required) - address of your API server (default: http://10.24.10.153)
- Port (required) - port of API server (default: 8081)
- API Key (optional) - key for authentication
๐ Node Parameters
$3
This node has no configurable parameters as it's designed to work as an embedding provider for other nodes.
$3
- Input Type - input type:
- Single Text - single text
- Multiple Texts - multiple texts (separated by newlines)
- Text - text for embedding generation (only for Single Text)
- Texts - texts for embedding generation (only for Multiple Texts)
- Endpoint - API endpoint:
- embed - generate embeddings
- similarity - calculate similarity
- Task Type - task type:
- classification - for symmetric tasks (STS, NLI, Bitext Mining)
- clustering - for thematic tasks (classification, headline search)
- search_query - for search queries
- search_document - for search documents
- default - without prefix
๐ก Usage Examples
$3
`json
{
"inputType": "single",
"text": "Hello, world!",
"endpoint": "embed",
"task": "classification"
}
`
$3
1. Add a Vector Store node (e.g., Supabase Vector Store)
2. In the Vector Store node, look for Embedding connection
3. Select Custom Embedding from the dropdown
4. Configure your credentials
5. The Vector Store will automatically use your custom embedding service
$3
`json
{
"inputType": "multiple",
"texts": "First document\nSecond document\nThird document",
"endpoint": "embed",
"task": "clustering"
}
`
$3
`json
{
"inputType": "multiple",
"texts": "First text\nSecond text",
"endpoint": "similarity",
"task": "classification"
}
`
๐๏ธ Project Structure
`
n8n-nodes-custom-embedding/
โโโ nodes/
โ โโโ Embedding/ # Embedding sub-node
โ โ โโโ Embedding.node.ts # Sub-node implementation
โ โ โโโ embedding.svg # Node icon
โ โโโ StandaloneEmbedding/ # Standalone embedding node
โ โโโ StandaloneEmbedding.node.ts # Standalone node implementation
โ โโโ embedding.svg # Node icon (shared)
โโโ credentials/
โ โโโ EmbeddingApi.credentials.ts # API credentials
โโโ dist/ # Compiled JavaScript files
โโโ examples/ # Usage examples
โโโ package.json # Project configuration
โโโ tsconfig.json # TypeScript configuration
โโโ README.md # This file
`
๐ง Development
$3
`bash
Install dependencies
npm install
Build the project
npm run build
Build with icon copying
npm run build
`
$3
The project contains two separate nodes:
1. Embedding Node (nodes/Embedding/)
- Implements INodeType interface
- Has type: 'embedding' getter for AI integration
- Uses supplyData() method for sub-node functionality
- No configurable parameters (works as provider)
2. StandaloneEmbedding Node (nodes/StandaloneEmbedding/)
- Implements INodeType interface
- Standard n8n node with execute() method
- Full parameter configuration
- Processes input data and returns embeddings
Both nodes share the same underlying embedding logic and API integration.
API Endpoints
$3
Generates embeddings for one or more texts.
Request Body:
`json
{
"texts": ["text 1", "text 2"],
"task": "classification"
}
`
Response:
`json
{
"embeddings": [[0.1, 0.2, ...], [0.3, 0.4, ...]],
"model": "sentence-transformers",
"task": "classification"
}
`
$3
Calculates similarity between two texts.
Request Body:
`json
{
"texts": ["text 1", "text 2"],
"task": "classification"
}
`
Response:
`json
{
"similarity": 0.85,
"text1": "text 1",
"text2": "text 2",
"task": "classification"
}
`
Task Types
| Type | Description | Application |
|------|-------------|-------------|
| classification | Symmetric tasks | STS, NLI, Bitext Mining |
| clustering | Thematic tasks | Classification, headline search |
| search_query | Search queries | Query-based search |
| search_document | Search documents | Document-based search |
| default | Without prefix | General tasks |
๐งช Testing
$3
1. Check API availability:
`bash
curl -X GET http://10.24.10.153:8081/health
`
2. Test embedding generation:
`bash
curl -X POST http://10.24.10.153:8081/embed \
-H "Content-Type: application/json" \
-d '{"texts": ["test"], "task": "classification"}'
`
3. Test similarity calculation:
`bash
curl -X POST http://10.24.10.153:8081/similarity \
-H "Content-Type: application/json" \
-d '{"texts": ["hello", "hi"], "task": "classification"}'
`
$3
1. Create a new workflow
2. Add "Custom Embedding" node
3. Configure Credentials
4. Test with simple text
๐ง Troubleshooting
$3
1. "Host and port are required"
- Check Credentials settings
- Ensure Host and Port are specified
2. "Connection refused"
- Check API server availability
- Ensure port is open
3. "Invalid response from API"
- Check API response format
- Ensure API returns correct structure
$3
Enable logging in n8n for debugging:
`bash
n8n start --log-level debug
``