Introduction
This guide shows how to connect a local LLM running in LM Studio to n8n (n8n inside Docker), how a common API mismatch looks in practice, and the simple correction that fixes it. It’s written as a zero-fluff, copy-paste friendly community post, including the exact debugging step that saved the day. One of the most significant benefits is that you can install free Local Language Models (LM) and make unlimited requests at zero cost, allowing hands-on experimentation without financial constraints.
What you will end up with
-
n8n calling your local LLM (Gemma) via LM Studio’s OpenAI-compatible endpoint
-
Stable chat completions (no “Bad request” errors)
-
Clear checklist for debugging when things go wrong
Required software (short)
-
LM Studio (installed on your host)
-
n8n (running in Docker)
-
A downloaded model in LM Studio (e.g.
google/gemma-3-4b)
Steps
1) Install LM Studio and download the model
-
Install and launch LM Studio.
-
In LM Studio, search and download the model you want (example:
google/gemma-3-4b).
2) Start the Local Server and note the details
-
Go to Local Server in LM Studio.
-
Enable “Serve on local network” (or “Start Server”).
-
Copy the server base URL (e.g.
http://<HOST_IP>:####) and the model id shown by/v1/models. -
(Optional, but required for n8n) Create an API token (Settings → Authentication → Create token) and copy it.
3) Configure n8n credentials (OpenAI node)
-
In n8n locate an OpenAI Chat credentials (or create new OpenAI credential).
-
Set Base URL to the LM Studio root including
/v1:
http://<HOST_IP>:####/v1
3\. Set the API key to the token you created (or any placeholder if LM Studio accepts it).
- In the OpenAI Chat node set Model → By ID and paste the exact model id returned by
/v1/models(for examplegoogle/gemma-3-4b).
Important: give the API root (ending with /v1), not the full path to /chat/completions. n8n will append the endpoint automatically.
4) First run — expect the error (and why)
-
Create a minimal test workflow: trigger → OpenAI Chat node with a simple system/user message.
-
Execute. You might see:
Bad request - please check your parameters.
This often happens when LM Studio and n8n disagree on which OpenAI API variant to use (Responses API vs Chat Completions API). In the field case you took the “Use Responses API” option in n8n and the request payload used the Responses format — LM Studio rejected it because it expected Chat Completions.
5) Inspect LM Studio Developer Tools (the fast debug)
-
In LM Studio open Developer Tools (or Server logs).
-
Watch incoming requests while you re-run the failing n8n node. You’ll see something like:
Received request: POST /v1/responses
body: { input: [...], model: "...", tools: [...], text: {} }
ERROR: missing_required_parameter text.format
This log proves that n8n sent a Responses API request (path /v1/responses) with a payload LM Studio did not accept.
6) The fix — disable “Use Responses API”
-
In n8n find the option “Use Responses API” (or “Enable Responses API”) .
-
Disable that option so LM Studio handles standard Chat Completions requests rather than the newer Responses format.
7) Re-run and confirm successful call
-
Re-run the same n8n test.
-
In LM Studio logs you should now see:
POST /v1/chat/completions body: { model: "google/gemma-3-4b", messages: [...] }-
n8n will show the model response (e.g., a “Hello” reply). Workflow succeeds.
Security notes (short & practical)
-
Enable authentication in LM Studio and use tokens.
-
Limit LM Studio to your LAN (don’t expose it to the public internet).
-
If you must expose it, put it behind a reverse proxy with TLS + auth.
-
Treat the model token like any API key — store it securely (n8n credentials).
-
Run n8n and LM Studio on an isolated Docker network if possible.
-
Conclusion
Setting up a local LLM and connecting it to n8n is much easier than it first appears. With LM Studio providing an OpenAI-compatible API, the process becomes almost identical to using a cloud model, but with full privacy, local control, and zero external dependency.
After a small configuration adjustment, the workflow runs smoothly, showing that local AI can be integrated into n8n in just a few steps. For automation builders, running LLMs locally is no longer complex, it’s a practical and accessible upgrade to any workflow.
-












