# How to Connect an OpenAI-Compatible Model to AI Agent?

**URL:** <https://community.n8n.io/t/how-to-connect-an-openai-compatible-model-to-ai-agent/162897>\
**Category:** Questions\
**Tags:** ai\
**Created:** [August 5, 2025, 11:15pm UTC](https://community.n8n.io/t/how-to-connect-an-openai-compatible-model-to-ai-agent/162897 "2025-08-05T23:15:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddo](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@ddo](https://community.n8n.io/u/ddo)\
**Post date:** [August 5, 2025, 11:15pm UTC](https://community.n8n.io/t/how-to-connect-an-openai-compatible-model-to-ai-agent/162897/1 "2025-08-05T23:15:19Z")

</div>

I have tried with two different AI Platforms that provide **OpenAI-Compatible** API for their AI Service,  
(one of them being **OpenRouter** , to make sure this isn’t the problem with my other AI Provider)

and couldn’t create the Credentials to connect to the API using OpenAI Model Node (since its the closest node we can use for this)

this work flow works, yet when i enter the API Key and Base URL in OpenAI Credentials, it won’t work.

what am I doing wrong ? is it even possible to use OpenAI-Compatible Models with AI Agent Nodes ?

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/b/d/bd7db3a8dd91495932763aa7098949b111c04976.png)

- **n8n version:** 1.105.3
- **Database (default: SQLite):** SQLite
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):** Default
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** Docker
- **Operating system:** Ubuntu

---

<div class="post-metadata">

**Author:** ![Moses\_Otu](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/moses_otu/32/58755_2.png) [@Moses\_Otu](https://community.n8n.io/u/Moses_Otu)\
**Post date:** [August 9, 2025, 12:58pm UTC](https://community.n8n.io/t/how-to-connect-an-openai-compatible-model-to-ai-agent/162897/2 "2025-08-09T12:58:45Z")

</div>

Yes, it is possible. Confirm you aren’t using open AI keys with openrouter’s End point url.

you have to use and generate Openrouter API key with Openrouter endpoint url

---

<div class="post-metadata">

**Author:** ![withabdul](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/withabdul/32/179439_2.png) [@withabdul](https://community.n8n.io/u/withabdul)\
**Post date:** [August 9, 2025, 1:24pm UTC](https://community.n8n.io/t/how-to-connect-an-openai-compatible-model-to-ai-agent/162897/3 "2025-08-09T13:24:03Z")

</div>

Hello there, why you use OpenAI node? Since you can use Basic LLM Chain if you won’t use AI Agent.

n8n already have OpenRouter node for the model tools.

---

<div class="post-metadata">

**Author:** ![ddo](https://avatars.discourse-cdn.com/v4/letter/d/7feea3/32.png) [@ddo](https://community.n8n.io/u/ddo)\
**Post date:** [August 17, 2025, 6:48am UTC](https://community.n8n.io/t/how-to-connect-an-openai-compatible-model-to-ai-agent/162897/4 "2025-08-17T06:48:08Z")

</div>

since I’ve posted this problem i have been in contact with the other provider that I couldn’t use in OpenAI Node, and it turns out, they have implemented a bit of an unconventional API system (in comparison on OpenAI API) so that was why the n8n couldn’t connect with the API Credentials.

the only method to connect to their API was to Set the Model Name by ID Expression in OpenAI Model Node.

 ![Screenshot 2025-08-11 021724](https://europe1.discourse-cdn.com/n8n/original/3X/3/4/342e47c9d79fd6a6c4acc50b92acdcbd17bde12c.png)

thanks everybody for you’re replies

P.S: I’ve been testing with OpenRouter to check if OpenRotuer which is a OpenAI Compatible API would work with OpenAI Node or not, but clearly there was some difference that created the need for its own node.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [August 24, 2025, 6:48am UTC](https://community.n8n.io/t/how-to-connect-an-openai-compatible-model-to-ai-agent/162897/5 "2025-08-24T06:48:57Z")

</div>

Closed on August 24, 2025, 6:48am UTC

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