"config.headers.setContentType is not a function" error with OpenAI nodes
What is this error?
In n8n versions 2.19.0 through 2.20.x, a bug causes the following error when working with OpenAI:
NodeApiError: config.headers.setContentType is not a function
You may encounter this in two places:
OpenAI credentials test — the connection test shows a red error even when your API key is valid.
OpenAI node execution — the model dropdown fails to load, or the node errors on execution.
HTTP Request node targeting
api.openai.com— GET requests to any OpenAI API endpoint fail with this error.
Root cause
An internal axios interceptor in n8n assumes that request headers are an AxiosHeaders instance. However, a vendor-specific code path for OpenAI URLs replaces the headers with a plain object, which does not expose the setContentType method. This mismatch causes the error.
The bug only affects GET requests. POST requests to OpenAI work correctly.
Workarounds
1. OpenAI credentials test error
You can safely ignore the red error during the credential test. Your API key is not the problem. Click Save anyway — the credential will work correctly in your workflows.
2. OpenAI node — model dropdown not loading
Instead of using the model dropdown, select your model By ID and type the model name directly:
Open the OpenAI node.
In the Model field, click the selector and choose By ID.
Type the model name, e.g.
gpt-4o,gpt-4o-mini,o3-mini.
The node will execute correctly using the typed ID.
3. HTTP Request node targeting api.openai.com
This workaround applies to GET requests only — POST requests already work fine.
If you need to call a GET endpoint on api.openai.com (for example, to list available models or batches), the error currently has no clean workaround for the HTTP Request node. Consider using the built-in OpenAI node where possible, or temporarily pin your instance to n8n 2.18.5 if your deployment allows it.
Affected versions
Affected: 2.19.0, 2.19.2, 2.19.3, 2.19.5, 2.20.0
Not affected: 2.18.5 and earlier
Fix status
A fix is in progress and expected to be released shortly. This article will be updated once a patched version is available. follow here https://github.com/n8n-io/n8n/issues/29471