AIConnect icon

AIConnect

Use OpenAI-compatible API functions

Overview

The node "AIConnect" provides access to OpenAI-compatible API functions, specifically supporting operations on Chat, Image, and Audio resources. Focusing on the Chat - Complete operation, this node generates chat completions based on a sequence of input messages using a specified language model.

This operation is useful for scenarios such as:

  • Building conversational agents or chatbots that respond dynamically to user inputs.
  • Generating assistant replies in customer support workflows.
  • Creating interactive storytelling or role-playing applications.
  • Automating content generation where context-aware text completion is needed.

For example, you can provide a series of messages with roles like "system" (to set behavior), "user" (user input), and "assistant" (previous responses), and the node will generate the next assistant message completing the conversation.

Properties

Name Meaning
Model The language model used to generate the chat completion. Options are dynamically loaded from available chat models.
Prompt A collection of messages forming the conversation history. Each message has:
• Role: one of Assistant, System, or User.
• Content: the text content of the message. Multiple messages can be added and sorted.
Max Tokens Maximum number of tokens to generate in the completion response. Controls the length of the output.
Temperature Controls randomness of the output. Lower values make output more deterministic; higher values increase creativity and variability. Range: 0 to 2.
Top P Controls diversity via nucleus sampling. Values between 0 and 1 determine the cumulative probability threshold for token selection.
Frequency Penalty Penalizes new tokens based on their existing frequency in the generated text to reduce repetition. Range: -2 to 2.
Presence Penalty Penalizes new tokens based on whether they appear in the text so far to encourage talking about new topics. Range: -2 to 2.
Simplify Output Boolean flag indicating whether to return a simplified version of the API response instead of the full raw data. Defaults to true.

Output

The node outputs JSON data representing the chat completion result from the API. When Simplify Output is enabled, the output is a streamlined object containing the essential completion text and related metadata, making it easier to use in subsequent workflow steps.

If binary data were involved (not applicable here), it would be summarized accordingly, but this operation deals purely with JSON text completions.

Dependencies

  • Requires an API key credential for an OpenAI-compatible service configured in n8n.
  • The node dynamically loads available chat models from the API.
  • Network connectivity to the API endpoint is necessary.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication errors.
    • Specifying an unsupported model name may result in API errors.
    • Providing malformed or empty prompt messages can lead to unexpected or empty completions.
    • Exceeding token limits (max_tokens) might truncate output unexpectedly.
  • Error messages:

    • "The resource \"chat\" is not supported!" — indicates a misconfiguration of the resource parameter.
    • API error messages returned in the error field when continueOnFail is enabled, e.g., rate limit exceeded, invalid parameters.
  • Resolutions:

    • Verify API credentials and permissions.
    • Ensure the selected model is valid and available.
    • Provide well-formed prompt messages with appropriate roles and content.
    • Adjust max_tokens and other parameters within allowed ranges.

Links and References

Discussion