Custom Embedding (Sub-node) icon

Custom Embedding (Sub-node)

Generate text embeddings using custom embedding API (Embedding Sub-node)

Overview

This node generates text embeddings by sending input text to a custom embedding API. It is designed as a sub-node within n8n workflows to transform textual data into numerical vector representations, which are useful for tasks like semantic search, classification, or clustering.

Typical use cases include:

  • Converting user queries or documents into embeddings for similarity comparison.
  • Preparing text data for machine learning models that require vector inputs.
  • Enhancing search functionality by indexing content with embeddings.

For example, you might input a sentence describing a product and receive its embedding vector to compare against other products in a recommendation system.

Properties

Name Meaning
Node Type Fixed value "embedding" indicating the type of this sub-node

Output

The node outputs an array of embedding vectors corresponding to the input texts. Each embedding is a numeric array representing the semantic features of the input text.

  • The output is available on the json field under the output named "Embeddings".
  • No binary data is produced by this node.

Dependencies

  • Requires access to a custom embedding API endpoint specified by host and port credentials.
  • Needs an API key credential for authorization when calling the embedding service.
  • The node uses HTTP POST requests to send texts to the /embed endpoint of the API.
  • Proper configuration of the API host, port, and API key in n8n credentials is necessary.

Troubleshooting

  • Missing Host or Port: If the host or port is not set in credentials, the node will throw an error stating "Host and port are required". Ensure these are configured correctly.
  • API Request Failures: Errors during embedding generation (e.g., network issues, invalid API key) will result in a failure message "Failed to generate embeddings" with details from the API response. Verify API availability and credentials.
  • Empty or Invalid Embeddings: If the API returns unexpected data formats, embeddings may be missing or malformed. Confirm the API response structure matches expectations.

Links and References

Discussion