Use OpenRouter in n8n Versions <1.78

n8n AI Engineering Product

Contributed by Sabrina Ramonov 🍄. From the community directory at agents.sabrina.dev, republished with permission and full credit.

What it is:

In version 1.78, n8n introduced a dedicated node to use the OpenRouter service, which allows you to utilize a variety of different LLM models and providers, and change models on the fly in an agentic workflow.

For prior n8n versions, there's a workaround to make OpenRouter accessible by using the OpenAI node with an OpenRouter-specific BaseURL.

This trivial workflow demonstrates this for versions before 1.78, enabling you to dynamically use different LLM models with the available n8n nodes for OpenAI LLM and OpenAI credentials.

What you can do:

- Use any of the OpenRouter models

- Have the model dynamically configured or changing (by some external config, some rule, or some specific chat message)

Setup steps:

1. Import the workflow.

2. Ensure you have registered an account, purchased some credits, and created an API key for OpenRouter.ai.

3. Configure the "OpenRouter" credentials with your own credentials, using an OpenAI type credential, but making sure in the credential's config form its "Base URL" is set to **https://openrouter.ai/api/v1** so OpenRouter is used instead of OpenAI.

4. Open the "Settings" node and change the model value to any valid model ID from the OpenRouter models list or even have the model property set dynamically.

Tools used: OpenAI, Openrouter

Download the workflow template (JSON)

Original tutorial

Want this running in your business? KOBA42 builds and operates automations like this one.