Overview
This node generates vector embeddings for text inputs using various embedding models available through the OpenRouter API. Embeddings are numerical representations of text that capture semantic meaning, useful in tasks like search, recommendation, clustering, and natural language understanding.
Common scenarios where this node is beneficial include:
- Converting user queries or documents into embeddings to perform semantic search.
- Generating embeddings for multiple texts at once to analyze similarity or cluster content.
- Feeding embeddings into machine learning models or downstream AI workflows.
Practical examples:
- Transforming a product description into an embedding to find similar products.
- Creating embeddings for customer feedback entries to identify common themes.
- Encoding chatbot messages to improve intent recognition.
Properties
| Name | Meaning |
|---|---|
| Model | The embedding model to use. Options: "Text Embedding Ada 002", "Text Embedding 3 Small", "Text Embedding 3 Large". |
| Input Type | Type of input to process. Options: "Text" (single string), "Array of Texts" (JSON array of strings). |
| Text | The single text string to generate embeddings for (shown if Input Type is "Text"). |
| Text Array | JSON array of texts to generate embeddings for (e.g., ["text1", "text2"]) (shown if Input Type is "Array of Texts"). |
| Dimensions | Number of dimensions for the embedding vector (only applicable for "Text Embedding 3 Small" and "Text Embedding 3 Large" models). Default is 1536. |
| Output Format | Format of the output data. Options: "Full Response" (complete API response), "Embeddings Only" (just the embedding vectors). |
Output
The node outputs JSON data containing the embeddings and related information:
If Output Format is set to "Embeddings Only":
- For single text input:
{ "embedding": [/* array of numbers representing the embedding */], "text": "original input text" } - For array input:
{ "embeddings": [ [/* embedding vector for first text */], [/* embedding vector for second text */], ... ], "texts": [/* original array of input texts */] }
- For single text input:
If Output Format is "Full Response", the entire API response is included along with the model name and input text(s).
The output can be used directly in subsequent nodes for analysis, storage, or further processing.
Dependencies
- Requires an API key credential for the OpenRouter API.
- The node makes HTTP POST requests to
https://openrouter.ai/api/v1/embeddings. - The API key must have permissions to access the embeddings endpoint.
- No additional environment variables are required beyond the API key credential.
Troubleshooting
Invalid JSON array error:
When using "Array of Texts" input type, the provided text array must be valid JSON. Common mistakes include missing quotes, trailing commas, or not providing an array structure.
Resolution: Ensure the input is a properly formatted JSON array of strings, e.g.,["text1", "text2"].API authentication errors:
If the API key is missing, invalid, or lacks permissions, the node will fail to authenticate.
Resolution: Verify the API key credential is correctly configured and has access rights.Model compatibility issues:
The "Dimensions" property only applies to certain models ("Text Embedding 3 Small" and "Large"). Using it with other models has no effect.
Resolution: Use the dimensions setting only when applicable.Network or API errors:
Temporary network issues or API downtime may cause request failures.
Resolution: Retry later or check network connectivity.Continue on Fail behavior:
If enabled, the node will continue processing remaining items even if some fail, returning error details in the output JSON.
Links and References
- OpenRouter API Documentation – Official docs for the embeddings API.
- Embedding Models Overview – General info about embedding models and their use cases.
- n8n Documentation – Guides on creating and using custom nodes and credentials.