How to Run Free AI Models Locally with LM Studio and n8n

Running local AI models eliminates dependency on paid cloud services while maintaining powerful functionality. Here’s how to install and integrate open-source LLMs like DeepSeek or Llama directly into n8n workflows without API fees.

Key Steps

1. Install LM Studio on Your Computer

  • LM Studio (download here) is a desktop app that lets you run open-source LLMs locally.
  • Works on Windows, macOS, and Linux.

2. Download a Local AI Model

  • LM Studio’s Discover tab includes models like DeepSeek, Llama, and Mistral.
  • For workflow automation, DeepSeek is ideal for coding and reasoning tasks.
  • Once downloaded, models appear in “My Models” and can be loaded instantly.

3. Test the Local Model in LM Studio

  • Select the model in the Chat tab and send a prompt to verify it’s functional.
  • Responses depend on your system hardware (faster with a dedicated GPU).

4. Connect LM Studio to n8n

  • Go to LM Studio’s Developer tab and confirm the local API server is running (`http://localhost:1234`).
  • In n8n, replace OpenAI’s chat node with a custom configuration:
    • Base URL: `http://host.docker.internal:1234` (required if n8n runs in Docker)
    • API Key: Enter any placeholder (e.g., abc123).
    • Model Selection: Choose the installed LLM (e.g., DeepSeek).

5. Test the Integration

  • Send a test prompt from n8n to verify responses.
  • If using Docker, ensure host.docker.internal routes requests to your host machine.

Benefits of Running Local AI

No API Costs – Avoid subscription fees from OpenAI or similar services.
Full Privacy – Data stays on your machine, never sent to third parties.
Complete Flexibility – Modify models, prompts, or workflows offline.

Further Resources

  • n8n – Open-source automation tool.
  • LM Studio – Desktop LLM management.

This approach unlocks self-hosted AI automation while keeping costs at zero. Experiment with different models to optimize performance for your needs.

Leave a Reply

Your email address will not be published. Required fields are marked *