Overview
This node, named "Super Prompts," intelligently routes user queries to the most appropriate system prompt and language model (LLM) connection based on the content of the query. It allows configuring multiple system prompts, each tailored for specific types of queries, and uses a dedicated router model to decide which prompt and LLM to use dynamically.
Common scenarios where this node is beneficial:
- When you want to leverage different specialized prompts (e.g., technical expert, creative writer, math solver) within a single workflow.
- When you have multiple LLM connections and want to route queries intelligently to the best-suited model or prompt.
- When you need dynamic prompt selection based on user input without manual intervention.
Practical example:
You configure three system prompts:
- A math expert prompt for calculation-related queries.
- A creative writing prompt for storytelling.
- A code assistant prompt for programming questions.
When a user sends a query about solving an equation, the node routes it to the math expert prompt and its associated LLM. For a story idea, it routes to the creative writing prompt, ensuring responses are contextually relevant and optimized.
Properties
| Name | Meaning |
|---|---|
| Router Model Info | Informational notice guiding users to configure a router model in credentials to enable intelligent prompt routing based on user queries. |
| System Prompts | Collection of multiple system prompts. Each prompt includes: - Label: Name of the prompt (e.g., "Math Expert"). - When to Use This Prompt: Description of when to apply this prompt. - System Prompt: The actual prompt text sent to the LLM. - LLM Connection: Selects which connected language model (from 1 to 5) to use with this prompt. |
| Router Model | Choice of model used for routing decisions and generating final responses. Options: - GPT-4.1 Mini - GPT-4.1 Nano |
| Routing Temperature | Numeric value controlling randomness in routing decisions. Lower values make routing more deterministic; higher values increase variability. Range: 0 to 2, default 0.1. |
Output
The node outputs data through a single output named "LLM." The output structure corresponds to the response from the selected language model after applying the chosen system prompt.
- The
jsonoutput contains the chat completion result from the invoked LLM. - If multiple messages are passed in, the node filters out any existing system messages and prepends the selected system prompt before sending to the LLM.
- Binary data output is not indicated or handled by this node.
Dependencies
- Requires an API key credential for OpenAI or a compatible LLM provider configured in n8n.
- Up to five language model connections can be linked as inputs; these represent different LLM instances that the node can route queries to.
- The router model itself is an LLM (GPT-4.1 Mini or Nano) used internally to select the best prompt based on the user's latest message.
- Network access to the OpenAI API endpoint (
https://api.openai.com/v1/chat/completions) is required.
Troubleshooting
Error: "Prompt configuration requires X LLMs, but only Y are connected."
This means one or more system prompts are assigned to LLM connections that are not actually connected. Ensure you connect enough language model nodes matching the highest index used in your prompt configurations.Error: "OpenAI API credentials are required for the router model."
The node needs valid API credentials to call the router model. Verify that the API key credential is set up correctly.Error: "At least one system prompt must be configured."
You must add at least one system prompt in the node settings for it to function.Error: "No LLM connected for prompt 'X' at index Y."
The prompt references an LLM connection index that is empty. Connect the corresponding LLM node or adjust the prompt's connection index.Invalid prompt selection error
If the router returns an invalid prompt index, check the router model's response and ensure the prompt descriptions are clear and distinct to improve routing accuracy.General connectivity issues
Make sure your n8n instance has internet access and the API key is valid and not expired.
Links and References
- OpenAI Chat Completion API - Documentation for the underlying API used for routing and prompt invocation.
- n8n Custom Nodes Guide - General guide on creating and configuring custom nodes in n8n.
- Prompt Engineering Best Practices - Tips on designing effective system prompts for LLMs.
If you need further details or examples on how to configure the system prompts or connect language models, feel free to ask!