Overview
The OpenAI Studio node's "Create Embeddings" operation allows you to generate vector embeddings from input text using OpenAI's embedding models. This is useful for tasks such as semantic search, clustering, recommendation systems, and other applications where representing text as high-dimensional vectors is beneficial. For example, you can use this node to convert user queries or documents into embeddings for similarity comparison or machine learning workflows.
Properties
| Name | Type | Meaning |
|---|---|---|
| Embedding Model | options | Selects the OpenAI embedding model to use (e.g., large, small, or legacy). |
| Prompt | string | The text prompt to be converted into an embedding. Required. |
| Advanced Parameters | collection | Optional advanced settings for fine-tuning the embedding process. See below for details. |
| └ Embedding Dimensions | number | (Within Advanced Parameters) Sets the number of dimensions for the output embeddings. |
Advanced Parameters (relevant for "Create Embeddings"):
- Embedding Dimensions: Number of dimensions for the resulting embedding vector (default: 1536, range: 1–3072).
Other advanced parameters listed (like Temperature, Top P, etc.) are not used in the "Create Embeddings" operation.
Output
The node outputs a JSON object that includes:
- All original input fields.
- An additional field named
openaiResponsecontaining the full response from the OpenAI API.
The structure of openaiResponse typically includes:
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [/* array of numbers */],
"index": 0
}
],
"model": "text-embedding-3-small",
"usage": {
"prompt_tokens": 5,
"total_tokens": 5
}
}
- embedding: The generated vector representation of your input text.
- model: The embedding model used.
- usage: Token usage statistics.
Dependencies
- External Service: Requires access to the OpenAI API.
- API Key: You must provide an OpenAI API key via n8n credentials (
openAiApi). - Optional: Organization ID and custom API endpoint if applicable.
Troubleshooting
Common Issues:
- Missing or Invalid API Key: Ensure your OpenAI API key is correctly set in n8n credentials.
- Invalid Input Text: The "Prompt" property must not be empty.
- Model Not Supported: Only supported embedding models can be selected; using others will result in errors.
- Dimension Out of Range: If "Embedding Dimensions" is set outside the allowed range (1–3072), the API will return an error.
Error Messages:
OpenAI API Error: <status> - <message>: Indicates an error returned by the OpenAI API. Check the message for details (e.g., invalid API key, unsupported model, bad request).Error: <message>: General error, possibly due to network issues or misconfiguration.
How to resolve:
- Double-check all required properties, especially the API key and prompt.
- Ensure the selected embedding model and dimension are valid.
- Review the detailed error description provided in the node output.