I am experiencing a critical and highly persistent issue when attempting to generate OpenAI embeddings using the HTTP Request node in n8n Cloud. Despite extensive and exhaustive troubleshooting, the problem remains unresolved, and the error message directly contradicts the request body shown in n8n’s own error logs.
Environment:
- n8n Cloud Version: 1.98.1
- Node in Question: HTTP Request (used for OpenAI Embeddings API call)
- OpenAI Model:
text-embedding-3-large
Problem Description: My workflow aims to:
- Extract text and add metadata (
documentID_clean
,tags
). - Generate embeddings for this text using OpenAI’s
/v1/embeddings
endpoint. - Store the embeddings and metadata in a Qdrant vector store.
The workflow consistently fails at the HTTP Request node responsible for calling the OpenAI embeddings API. The error received is: "Bad request - please check your parameters [item 0] you must provide a model parameter"
or sometimes: "We could not parse the JSON body of your request. (HTTP) This likely means you aren't using your HTTP library correctly. The OpenAI API expects a JSON payload, but what was sent was not valid JSON."
Crucial Contradiction: The most perplexing aspect is that the Request
field within the error details consistently shows a perfectly valid JSON body being sent, which explicitly includes the model
parameter (e.g., "model": "text-embedding-3-large"
) and the input
text. This directly contradicts the error message from OpenAI.
Detailed Troubleshooting Steps Performed (All have failed to resolve the issue):
- OpenAI API Key Validation:
- Confirmed the OpenAI API key is valid and works flawlessly in other n8n workflows (e.g., successfully calling
https://api.openai.com/v1/models
using the same credential ). This rules out general API key or account issues. - Confirmed n8n can establish a connection to OpenAI.
- JSON Body Preparation (Code Node):
- Implemented a dedicated Code node (
Prepare OpenAI Request Body (Code)
) to meticulously construct the exact JSON payload required by OpenAI ({"model": "...", "input": "..."}
). - This Code node then
JSON.stringify()
's this object into a single string (requestBodyString
). - Confirmed the output of this Code node is a perfectly valid, correctly escaped JSON string (e.g.,
"{\"model\":\"text-embedding-3-large\",\"input\":\"Your document text...\"}"
). This was verified by inspecting the node’s output and using external JSON validators.
- HTTP Request Node Configuration (Extensive Permutations):
- Body Content Type: Raw, Raw Body Type: JSON: This configuration, with
Body: {{$json.requestBodyString}}
andContent-Type: application/json
header, is the standard and most robust method. It previously worked to the extent of getting a “token limit exceeded” error (proving the JSON was parsed), but now fails with the “model parameter missing” error after switching totext-embedding-3-large
. - Body Content Type: JSON, Specify Body: Expression: Attempted
JSON.parse($json.requestBodyString)
. This resulted in “JSON parameter needs to be valid JSON” errors, indicating n8n’s UI was not correctly evaluating the expression in this context. - Body Content Type: JSON, Specify Body: Using JSON: Attempted to build the JSON via n8n’s form. This consistently failed, either stripping expressions or complaining about invalid JSON.
- Hardcoding the Body: As a final diagnostic, the perfectly stringified JSON output from the Code node was copied and pasted directly into the HTTP Request node’s
Raw
body field (replacing the expression). This also failed with the same “model parameter missing” error. This strongly suggests the issue is not with the JSON content itself or the expression evaluation, but with the transmission.
- OpenAI Model:
- Switched from
text-embedding-ada-002
totext-embedding-3-large
to address token limit issues. The error persists with the new model.
- Code Node for Direct API Call (Bypassing HTTP Request Node UI):
- Attempted to make the OpenAI API call directly from a Code node using
n8n.getCredentials()
andn8n.httpRequest( )
. - Encountered
n8n is not defined
andCannot find module
errors due to environment-specificrequire
paths andthis
context. - Even after correcting the Code node structure to use
async execute(n8n)
andn8n.getCredentials
/n8n.httpRequest
, the node either returned nothing or failed with internal errors, indicating the Code node environment itself might be problematic for direct HTTP calls in this version.
Conclusion: Given that the request body is demonstrably correct within n8n’s own logs, the API key is valid and works elsewhere, and all standard troubleshooting methods (including direct hardcoding and attempting programmatic calls ) have failed, it strongly suggests a deeper, environmental issue. This could be a bug in n8n Cloud (v1.98.1) related to how HTTP requests are transmitted, or a very specific interaction with OpenAI’s API that is not apparent from the user-facing configuration.
I am seeking urgent assistance to resolve this critical bottleneck in my workflow. Any insights or direct solutions would be greatly appreciated.
Thank you for your time and support.
Start agent
Describe the problem/error/question
What is the error message (if any)?
Please share your workflow
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: