Skip to content

Basic LLM Chain#

Use the Basic LLM Chain node to set the prompt that the model will use along with setting an optional parser for the response.

On this page, you'll find the node parameters for the Basic LLM Chain node, and links to more resources.

Examples and templates

For usage examples and templates to help you get started, refer to n8n's Basic LLM Chain integrations page.

Node parameters#

Prompt#

This is the prompt that the model uses. For example:

1
Tell me a joke about {{ $json.input }}

Chat Messages#

Use this when using a chat model to set a message. n8n ignores these options if you don't connect a chat model.

  • AI: provide a response. The model will try to respond in the same way in its messages.
  • System: set a system message to accompany the user input. Use this for things like defining tone. For example "Always respond talking like a pirate."
  • User: provide a sample user input. Using this with the AI option can help improve the output of the agent. Using both together provides a sample of an input and expected response (the AI message) for the model to follow.

Templates and examples#

Chat with PDF docs using AI (quoting sources)

by David Roberts

View template details
Use an open-source LLM (via HuggingFace)

by n8n Team

View template details
Suggest meeting slots using AI

by n8n Team

View template details
Browse Basic LLM Chain integration templates, or search all templates

Refer to LangChain's documentation on Basic LLM Chains for more information about the service.

View n8n's Advanced AI documentation.

  • completion: Completions are the responses generated by a model like GPT.
  • hallucinations: Hallucination in AI is when an LLM (large language model) mistakenly perceives patterns or objects that don't exist.
  • vector database: A vector database stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.
  • vector store: A vector store, or vector database, stores mathematical representations of information. Use with embeddings and retrievers to create a database that your AI can access when answering questions.