AutomationFlowsAI & RAG › Chat with AI Models via Openrouter Using Mistral

Chat with AI Models via Openrouter Using Mistral

BySarfaraz Muhammad Sajib @sarfarazmuhammad on n8n.io

This n8n workflow demonstrates how to build an automated AI chat system using OpenRouter.ai. It includes a manual trigger, sets a model and user message, sends a POST request to the OpenRouter chat API, and summarizes the response.

Event trigger★★☆☆☆ complexity4 nodesHTTP Request
AI & RAG Trigger: Event Nodes: 4 Complexity: ★★☆☆☆ Added:

This workflow corresponds to n8n.io template #5998 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "I0kBHahzGYqCjGVg",
  "name": "Use OpenRouter.ai Chat API Workflow in n8n",
  "tags": [],
  "nodes": [
    {
      "id": "865b71c0-1571-45d1-b043-34748152efc1",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -200,
        0
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "46b00289-733d-46ec-9db4-1774d3ff9ce6",
      "name": "OpenRouter.ai",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        280,
        0
      ],
      "parameters": {
        "url": "https://openrouter.ai/api/v1/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"{{ $json.Model }}\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"{{ $json.Message }}\"\n    }\n  ]\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "8485a42f-54f5-4151-861b-30e565e0d0b6",
      "name": "Set Model & Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        40,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "230805bf-a50a-4d36-ac6d-70847bac862e",
              "name": "Model",
              "type": "string",
              "value": "mistralai/mistral-small-3.2-24b-instruct:free"
            },
            {
              "id": "c8d75446-659e-4fe6-bc88-8f24cf1a510e",
              "name": "Message",
              "type": "string",
              "value": "What is the meaning of life?"
            },
            {
              "id": "7eb8f25c-8a85-445c-9b06-0aaf66c5b719",
              "name": "",
              "type": "string",
              "value": ""
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "96a85fb6-2a8a-4417-93c7-9a6302658dfe",
      "name": "Summarize",
      "type": "n8n-nodes-base.summarize",
      "position": [
        500,
        0
      ],
      "parameters": {
        "options": {},
        "fieldsToSummarize": {
          "values": [
            {
              "field": "choices[0].message.content",
              "aggregation": "min"
            }
          ]
        }
      },
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "771a55ac-ff58-4b56-9137-b1871465b185",
  "connections": {
    "OpenRouter.ai": {
      "main": [
        [
          {
            "node": "Summarize",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Model & Prompt": {
      "main": [
        [
          {
            "node": "OpenRouter.ai",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set Model & Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This n8n workflow demonstrates how to build an automated AI chat system using OpenRouter.ai. It includes a manual trigger, sets a model and user message, sends a POST request to the OpenRouter chat API, and summarizes the response.

Source: https://n8n.io/workflows/5998/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Text to Speech (OpenAI). Uses manualTrigger, httpRequest, stickyNote. Event-driven trigger; 8 nodes.

HTTP Request
AI & RAG

This workflow sends an HTTP request to OpenAI's Text-to-Speech (TTS) model, returning an .mp3 audio recording of the provided text. This template is meant to be adapted for your individual use case, a

HTTP Request
AI & RAG

Text to Speech (OpenAI). Uses httpRequest. Event-driven trigger; 8 nodes.

HTTP Request
AI & RAG

This workflow creates an image with the new OpenAI image model "GPT-Image-1" based on a form input. Form trigger (image prompt and image size input) Generate the Image via OpenAI API. Return the image

Form Trigger, HTTP Request, Form
AI & RAG

Przykład. Uses readWriteFile, httpRequest. Event-driven trigger; 3 nodes.

Read Write File, HTTP Request