
Module 10 Lesson 2: OpenAI & Anthropic
Connecting the brains. Learn how to setup your credentials for the world's most powerful AI models and how to choose the right model for your specific task.
Module 10 Lesson 2: OpenAI & Anthropic
To use AI in n8n, you need a "Model." Currently, OpenAI (GPT) and Anthropic (Claude) are the two industry leaders. n8n connects to them via API.
1. Setting up OpenAI
- Requirement: An OpenAI API Key.
- Model Choice:
- GPT-4o: Smartest, most expensive. Best for complex reasoning and reading images.
- GPT-4o-mini: Fast and very cheap. Best for simple summarization or classifying emails.
2. Setting up Anthropic
- Requirement: An Anthropic API Key.
- Model Choice:
- Claude 3.5 Sonnet: Famous for having a more "Human" writing style and being excellent at writing code.
- Claude 3 Haiku: Ultra-fast and efficient.
3. Local Models (The Private Way)
If your data is super sensitive, you can use OLlama.
- You run the AI on your own server.
- You connect it to n8n using the "Local LLM" nodes.
- Result: No data ever leaves your building.
4. Temperature and Max Tokens
- Temperature (0 to 1):
0.1= Strict and factual (Use for math or business logic).0.9= Creative and varied (Use for social media posts).
- Max Tokens: The limit on how long the AI's answer can be.
Exercise: The Mind Connector
- Create an OpenAI or Anthropic account (if you don't have one).
- Create a "Test" API Key and add it to n8n's Credentials.
- Create a workflow: Schedule -> Basic LLM Chain -> OpenAI Chat Model.
- Set the prompt:
"Tell me a joke about a developer.". - Run it. Did it work?
- Why is it better to use a "Small" model (like 4o-mini) for a workflow that runs 1,000 times a day?
Summary
Choosing your model is like choosing your "Employee." Some are experts (GPT-4), and some are fast interns (GPT-mini). By mastering the connection to these models, you provide n8n with the "Processing Power" it needs to handle complex business data.
Next Lesson: Your private expert: Building a Question-Answering Bot (RAG).