Skip to content
⌘K

"config.headers.setContentType is not a function" error with OpenAI nodes

Updated by Enzo Piccolino

What is this error?

In n8n versions 2.19.0 through 2.20.6, and 2.21.0, 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

Upgrade (recommended). Upgrade to n8n 2.20.7 or later to resolve the error (on 2.21.x, use 2.21.1 or later).

If you can't upgrade yet, for example because your instance is pinned to an older version, use the workarounds below:

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:

  1. Open the OpenAI node.

  2. In the Model field, click the selector and choose By ID.

  3. 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 through 2.20.6, and 2.21.0.

  • Not affected: 2.18.5 and earlier

Fix status

This issue was resolved in n8n 2.20.7. Upgrade to 2.20.7 or later to apply the fix (on 2.21.x, use 2.21.1 or later).

Article Last Updated At: 2026-11-10T12:53:19.156Z