AI Chatbot Integration using OpenRouter.ai - n8n Workflow

Use this foundational n8n workflow to integrate diverse AI models, like Mistral, through OpenRouter.ai. Learn how to configure the n8n HTTP Request node for custom LLM automation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation engineers seeking flexible LLM access.
Users who need to test multiple AI models (e.g., Mistral, Llama) without changing providers.
Developers building custom chatbots or AI services within an n8n workflow.
Anyone looking for advanced n8n templates for AI integration.

Overview

This powerful n8n workflow provides a streamlined method for accessing the vast library of large language models available through OpenRouter.ai. Instead of relying solely on dedicated n8n nodes for specific providers, this n8n template uses the universal HTTP Request n8n node to communicate directly with the OpenRouter API. This allows for unparalleled flexibility in model choice (currently configured for Mistral) and prompt engineering. If you are looking to build robust, model-agnostic AI solutions, this foundational n8n workflow is essential. It demonstrates a clean pattern for setting input parameters and processing the resulting JSON from external AI services, making it a highly useful starter for complex AI automation.

How it Works

The n8n workflow initiates with a manual n8n trigger, designed for easy testing and deployment.


  1. Initialize Parameters: The flow immediately proceeds to a Set n8n node, which defines two key variables: the AI Model ID (pointing to a free Mistral model on OpenRouter) and the user Message (the prompt).

  2. API Call: The OpenRouter.ai HTTP Request n8n node takes these variables and constructs a standard Chat Completion API request. Crucially, this n8n node uses HTTP Bearer Authentication, requiring an OpenRouter API key. The JSON body is dynamically generated, ensuring the model and message are passed correctly.

  3. Response Handling: Once the AI returns the result, the workflow uses the Summarize n8n node. While its name suggests aggregation, in this context, it is expertly configured to extract the core response content (choices[0].message.content) from the complex API JSON structure, providing a clean, final output.

Installation Guide

To deploy this n8n workflow effectively, follow these steps:


  1. Import: Copy the provided JSON and import it into your n8n instance as a new workflow.

  2. OpenRouter Credentials: You must obtain an API Key from OpenRouter.ai.

  3. Configure Authentication: Navigate to the 'OpenRouter.ai' HTTP Request n8n node. In the Authentication section, select 'Generic Credential Type' and 'HTTP Bearer Auth'. Create a new credential using your OpenRouter API Key.

  4. Customize: Edit the 'Set Model & Prompt' n8n node to change the AI model or the starting message. Note that some premium models may require payment via OpenRouter.

  5. Execution: Click the 'Execute workflow' n8n trigger manually to test the integration. Once confirmed, you can replace the manual n8n trigger with a webhook or schedule.

Node Details

This n8n workflow relies on core n8n nodes to achieve seamless integration:

When clicking ‘Execute workflow’ (Manual Trigger): This serves as the starting n8n trigger for immediate manual execution and testing of the n8n workflow.
Set Model & Prompt (Set Node): A critical n8n node used to define the LLM model identifier (mistralai/mistral-small-3.2-24b-instruct:free) and the user's prompt (What is the meaning of life?). This separation simplifies future modifications of the n8n template.
OpenRouter.ai (HTTP Request Node): The central n8n node responsible for communication. It is configured to send a POST request to the OpenRouter chat completions endpoint. It dynamically builds the JSON request payload using variables defined in the previous n8n node and uses HTTP Bearer authentication.
Summarize (Summarize Node): Used here not for standard aggregation, but specifically configured to drill down into the complex JSON response and extract the clean text output from the AI, specifically from the path choices[0].message.content.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by
Sarfaraz Muhammad Sajib
Sarfaraz Muhammad Sajib

Featured*