Overview
This node integrates with the Literal AI API to generate chat completions based on predefined prompts and user-supplied variables. It fetches a prompt by name from the Literal AI service, validates that all required variables are provided, and then sends a formatted message to OpenAI's chat completion endpoint using the model and settings defined in the prompt.
Common scenarios for this node include:
- Automating conversational AI responses tailored by dynamic variables.
- Using pre-configured prompt templates stored in Literal AI to standardize interactions.
- Enhancing workflows with AI-generated text based on contextual input.
For example, you might define a prompt named "CustomerSupportResponse" in Literal AI with variables like "customerName" and "issueDescription". This node would take those variables as input, retrieve the prompt, and produce a customized response message.
Properties
| Name | Meaning |
|---|---|
| Prompt | The name of the prompt to use from Literal AI. |
| Variables | A collection of key-value pairs representing variables to substitute into the prompt. |
| Notice | Informational notice stating that tools defined in Literal AI will be ignored; connect tools directly instead. |
Output
The node outputs an array of items where each item contains a json object with the following structure:
{
"text": "string"
}
text: The generated chat completion content returned from the OpenAI API after formatting the prompt with the provided variables.
If an error occurs during execution and the node is configured to continue on failure, the output item will contain:
{
"error": "string"
}
indicating the error message.
The node does not output binary data.
Dependencies
- Requires access to the Literal AI API with a valid API key credential.
- Requires access to the OpenAI API with a valid API key credential.
- The node uses the Literal AI client library (
@literalai/client) and the OpenAI SDK (openai). - Credentials must provide:
- Literal AI API key (and optionally base URL).
- OpenAI API key (and optionally base URL).
Troubleshooting
- Missing or invalid API keys: The node throws an error if the Literal AI API key is missing or invalid. Ensure credentials are correctly set up.
- Prompt not found: If the specified prompt name does not exist in Literal AI, an error is thrown. Verify the prompt name is correct.
- Missing required variables: If any variable required by the prompt is not provided, the node throws an error listing the missing variables. Provide all required variables.
- Model not specified in prompt: The prompt must specify a model for OpenAI chat completion. If missing, an error is raised.
- API errors from OpenAI: Errors from the OpenAI API (e.g., rate limits, invalid parameters) will propagate unless "continue on fail" is enabled.
- Notice about tools: Tools defined inside Literal AI are ignored by this node; users should connect tools directly in n8n.
Links and References
- Literal AI Documentation (hypothetical link)
- OpenAI Chat Completion API
- n8n Node Development