CustomOpenAi icon

CustomOpenAi

Custom Open AI

Actions2

Overview

This node provides an interface to generate chat completions using OpenAI's GPT models. It allows users to send a series of messages with roles (system, user, assistant) as prompts and receive AI-generated responses based on those inputs. This is useful for building conversational agents, chatbots, or any application requiring natural language generation in a dialogue format.

Common scenarios include:

  • Creating customer support chatbots that respond dynamically.
  • Generating creative writing or brainstorming ideas through interactive chat.
  • Automating conversational workflows where context is maintained across multiple messages.

For example, you can send a system message setting the behavior ("You are a helpful assistant") followed by user messages asking questions, and the node will return the assistant's replies.

Properties

Name Meaning
Model The GPT model used to generate the completion. Options are dynamically loaded from available models starting with "gpt-".
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.
Simplify Whether to return a simplified version of the response containing only the relevant choices data instead of the full raw API response. Defaults to true.
Options Additional parameters to customize the completion:
- Echo Prompt: Whether to include the prompt in the output.
- Frequency Penalty: Penalizes repeated tokens.
- Maximum Number of Tokens: Limits output length.
- Number of Completions: How many completions to generate.
- Presence Penalty: Encourages new topics.
- Sampling Temperature: Controls randomness.
- Top P: Controls diversity via nucleus sampling.

Output

The node outputs JSON data representing the completion results from the OpenAI API. If "Simplify" is enabled (default), the output contains a data field which holds an array of choice objects returned by the API. Each choice typically includes the generated message content and metadata.

If binary data were involved (not applicable here), it would be summarized accordingly, but this node focuses on textual chat completions.

Dependencies

  • Requires an API key credential for authenticating requests to the OpenAI service.
  • The base URL for the API is configurable via credentials.
  • The node depends on OpenAI's /v1/models endpoint to dynamically load available GPT models.
  • No other external dependencies are indicated.

Troubleshooting

  • Common issues:

    • Invalid or missing API key: Ensure the API key credential is correctly configured.
    • Model not found: The selected model must start with "gpt-"; verify model availability.
    • Token limits exceeded: The maximum number of tokens should respect model context length.
    • Network or API errors: Check connectivity and API status.
  • Error messages:

    • Authentication errors usually indicate invalid credentials.
    • Rate limit errors suggest too many requests; consider reducing frequency or request size.
    • Validation errors may occur if input properties are malformed or missing required fields.

Resolving these generally involves verifying credentials, adjusting parameters, and ensuring proper input formatting.

Links and References

Discussion