Literal AI icon

Literal AI

Use the Literal AI API

Overview

This node integrates with the Literal AI API to manage and interact with various AI-related resources. Specifically, for the Prompt - Create operation, it allows users to create or retrieve a prompt by specifying its name, template messages, and optional additional settings or tools. This is useful in scenarios where you want to programmatically define prompts that can be reused or managed within the Literal AI platform, such as setting up conversational templates, automating prompt versioning, or managing prompt configurations.

Practical examples include:

  • Creating a new prompt with predefined message templates for chatbot interactions.
  • Automatically retrieving an existing prompt if it already exists to avoid duplicates.
  • Configuring advanced prompt settings or integrating specific tools alongside the prompt.

Properties

Name Meaning
Name The unique name of the prompt to create or retrieve.
Template Messages JSON array representing the template messages that define the prompt's content or behavior.
Additional Fields Optional collection of extra fields:
- Description A textual description of the prompt.
- Settings JSON object containing configuration settings for the prompt.
- Tools JSON object defining any tools associated with the prompt.

Output

The node outputs a JSON object under the content field containing the response from the Literal AI API related to the created or retrieved prompt. This typically includes details about the prompt such as its ID, name, template messages, settings, tools, and other metadata returned by the API.

No binary data output is produced by this operation.

Example output structure (simplified):

{
  "content": {
    "id": "string",
    "name": "string",
    "templateMessages": [ /* array of message objects */ ],
    "settings": { /* prompt settings object */ },
    "tools": { /* tools object */ },
    "description": "string",
    // other prompt metadata
  }
}

Dependencies

  • Requires an API key credential for the Literal AI service to authenticate requests.
  • The node depends on the @literalai/client library to communicate with the Literal AI API.
  • Proper configuration of the API key credential in n8n is necessary before using this node.

Troubleshooting

  • Invalid JSON in Template Messages or Additional Fields: Since these properties expect JSON input, malformed JSON will cause errors. Ensure that JSON strings are correctly formatted.
  • Authentication Errors: If the API key is missing, invalid, or expired, the node will fail to authenticate. Verify the API key credential setup.
  • Duplicate Prompt Names: Attempting to create a prompt with a name that already exists may result in unexpected behavior unless using the get-or-create operation variant.
  • API Rate Limits or Network Issues: Temporary failures communicating with the Literal AI API might occur; consider enabling "Continue On Fail" to handle intermittent issues gracefully.

Common error messages:

  • "Invalid API key" — Check your API key credential.
  • "Malformed JSON" — Validate JSON inputs for template messages and additional fields.
  • "Prompt already exists" — Use the get-or-create operation to avoid duplication.

Links and References

Discussion