# Error connecting OpenAI API in n8n cloud – config.headers.setContentType is not a function

**URL:** <https://community.n8n.io/t/error-connecting-openai-api-in-n8n-cloud-config-headers-setcontenttype-is-not-a-function/295313>\
**Category:** Questions\
**Created:** [May 11, 2026, 9:40pm UTC](https://community.n8n.io/t/error-connecting-openai-api-in-n8n-cloud-config-headers-setcontenttype-is-not-a-function/295313 "2026-05-11T21:40:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ademilson\_assuncao](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ademilson_assuncao/32/173449_2.png) [@ademilson\_assuncao](https://community.n8n.io/u/ademilson_assuncao)\
**Post date:** [May 11, 2026, 9:40pm UTC](https://community.n8n.io/t/error-connecting-openai-api-in-n8n-cloud-config-headers-setcontenttype-is-not-a-function/295313/1 "2026-05-11T21:40:39Z")

</div>

**Title:** Error connecting OpenAI API in n8n – `config.headers.setContentType is not a function`

Hello everyone,

I’m having trouble connecting the OpenAI API in n8n.

I tested this on both versions:

- Stable version

- Latest Beta version (2.20.6)

In both cases, I get the same error when trying to save the OpenAI credentials:

```auto
Couldn't connect with these settings
config.headers.setContentType is not a function

```

What I already tried:

- Generated a new OpenAI API key

- Updated n8n to the latest beta version

- Tested with and without Organization ID

- Retried the connection multiple times

Current issue:

- I cannot register/connect the OpenAI API credentials inside n8n

- I also tried using the HTTP Request node as an alternative, but I couldn’t make it work (probably missing the correct configuration)

Has anyone experienced this issue before?  
Could someone share:

1. A possible fix for this error

2. A step-by-step example using the HTTP Request node to connect to OpenAI API

Thank you very much for any help!

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/8/4/8459d6482c227096629a8c1c20871a2abf6af9d4.png)

---

<div class="post-metadata">

**Author:** ![kjooleng](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/kjooleng/32/184045_2.png) [@kjooleng](https://community.n8n.io/u/kjooleng)\
**Post date:** [May 12, 2026, 5:43am UTC](https://community.n8n.io/t/error-connecting-openai-api-in-n8n-cloud-config-headers-setcontenttype-is-not-a-function/295313/3 "2026-05-12T05:43:04Z")

</div>

The n8n team is already aware of this [issue](https://github.com/n8n-io/n8n/issues/29471)  
Please keep a lookout for any updates

---

<div class="post-metadata">

**Author:** ![achamm](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/achamm/32/143734_2.png) [@achamm](https://community.n8n.io/u/achamm)\
**Post date:** [May 12, 2026, 10:26am UTC](https://community.n8n.io/t/error-connecting-openai-api-in-n8n-cloud-config-headers-setcontenttype-is-not-a-function/295313/4 "2026-05-12T10:26:45Z")

</div>

@ademilson_assuncao known interceptor bug (#29471), URL match on [api.openai.com](http://api.openai.com) so nothing your side will fix it. quick unblock is a tiny cloudflare worker proxy, point the HTTP Request node at it:

```auto
export default { async fetch(req) { const u = new URL(req.url); u.host = 'api.openai.com'; return fetch(new Request(u, req)); } }

```

then hit [https://yourworker.workers.dev/v1/chat/completions](https://yourworker.workers.dev/v1/chat/completions) with the Bearer header, passes through clean

---

<div class="post-metadata">

**Author:** ![nguyenthieutoan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/nguyenthieutoan/32/120924_2.png) [@nguyenthieutoan](https://community.n8n.io/u/nguyenthieutoan)\
**Post date:** [May 12, 2026, 3:38pm UTC](https://community.n8n.io/t/error-connecting-openai-api-in-n8n-cloud-config-headers-setcontenttype-is-not-a-function/295313/5 "2026-05-12T15:38:53Z")

</div>

Hey @ademilson_assuncao, welcome to the community! Really thorough first post with all the details, makes it much easier to help.

Just to add a bit more context on top of what was shared above:

This is a confirmed bug (GitHub issue #29471) in n8n 2.19.x, specifically in the axios request interceptor. When n8n detects a URL starting with `api.openai.com`, it rewrites the headers object, and that breaks the `setContentType` method. It affects the credential test, HTTP Request node, and AI nodes when they all point to OpenAI’s domain.

**The quickest workarounds while waiting for the official fix:**

1. **Just save the credential anyway** - the error shows on the credential test, but the credential itself often works fine in the actual workflow. When using the OpenAI node, pick your model “By ID” and type the model name manually (like `gpt-4o` or `gpt-4o-mini`).

2. **If you’re self-hosted on Docker** , pin to version `2.18.5` in your compose file until a patch drops.

3. **For n8n Cloud users** , you’re stuck waiting for n8n to push the fix (it’s tracked and assigned). You can subscribe to the GitHub issue for updates: [HTTP Request node fails with "config.headers.setContentType is not a function" when calling api.openai.com · Issue #29471 · n8n-io/n8n · GitHub](https://github.com/n8n-io/n8n/issues/29471)

Hope that clears things up!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/36532_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [August 10, 2026, 3:39pm UTC](https://community.n8n.io/t/error-connecting-openai-api-in-n8n-cloud-config-headers-setcontenttype-is-not-a-function/295313/6 "2026-08-10T15:39:21Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
