Lesson 18medium10 min

Changing the Brain: Comparing and Connecting LLMs

Connect chat model sub-nodes to the AI Agent and evaluate OpenAI, Claude, and local Ollama.

Learning Objectives

  • Connect an OpenAI or Anthropic Chat Model sub-node
  • Configure temperature, model IDs, and API credentials
  • Understand how to swap to a local Ollama model without breaking workflow structure

Changing the Brain: Comparing and Connecting LLMs

The AI Agent node requires an attached Chat Model sub-node connected to its purple Model input port.

  1. Connect the OpenAI Chat Model node to the AI Agent model port.
  2. Model: gpt-4o or gpt-4o-mini.
  3. Temperature: 0.2 (Low temperature ensures adherence to tool instructions and reduces hallucinations).
  4. Configure your OpenAI API key credentials.
Advertisement

Option B: Anthropic Chat Model

  1. Connect the Anthropic Chat Model node.
  2. Model: claude-3-5-sonnet-latest.
  3. Anthropic models excel at complex instructions and detailed report formatting.

Option C: Ollama (Local & Free)

For complete privacy:

  1. Connect the Ollama Chat Model node.
  2. Base URL: http://localhost:11434
  3. Model: llama3.1:8b or qwen2.5:7b.

Because n8n abstracts models behind standard LangChain interfaces, you can swap the model node at any time without reconfiguring your tools or prompts.