OneApi icon

OneApi

多个大模型集中调度 OneApi

对话 → Complete

AI-generated

Overview

This node provides an interface to generate chat completions using a large language model API. It allows users to send a sequence of messages with roles (user, assistant, system) as prompts and receive generated text completions in response. This is useful for building conversational AI applications, chatbots, or any scenario where natural language generation based on context is needed.

Practical examples include:

  • Creating a customer support chatbot that responds to user queries.
  • Generating creative writing or story continuation based on user input.
  • Summarizing or rephrasing text by providing instructions in the system role.
  • Interactive assistants that maintain conversation context.

Properties

Name Meaning
Model / chatModel The specific language model used to generate the completion. Options are dynamically loaded from the API's available models.
Prompt A collection of messages forming the conversation history or prompt. Each message has a Role (Assistant, System, User) and Content (text). Multiple messages can be added and sorted.
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.
Echo Prompt If enabled, the prompt messages will be echoed back along with the generated completion.
Frequency Penalty Penalizes new tokens based on their existing frequency in the text so far, reducing repetition. Range: -2 to 2.
Maximum Number of Tokens Limits the maximum number of tokens generated in the completion. Most models support up to 2048 tokens, newer ones up to 32768.
Number of Completions How many completions to generate per prompt. Higher values consume more quota.
Presence Penalty Penalizes new tokens based on whether they appear in the text so far, encouraging discussion of new topics. Range: -2 to 2.
Sampling Temperature Controls randomness of output. Lower values make output more deterministic; higher values increase randomness. Range: 0 to 1.
Top P Controls diversity via nucleus sampling. Values between 0 and 1, where lower values limit token selection to a smaller probability mass.

Output

The node outputs JSON data representing the completion results from the API. By default (when "Simplify" is enabled), the output contains a data field which holds an array of completion choices returned by the model. Each choice typically includes generated text and metadata such as finish reason.

If binary data were supported (not indicated here), it would represent media or files related to the completion, but this node focuses on textual completions only.

Dependencies

  • Requires an API key credential for authentication with the external large language model service.
  • Needs network access to the API endpoint specified in credentials.
  • The node dynamically fetches available models from the API /v1/models endpoint.
  • No other external dependencies are indicated.

Troubleshooting

  • Common issues:

    • Invalid or missing API key credential will cause authentication errors.
    • Exceeding token limits or quota may result in request failures.
    • Incorrectly formatted prompt messages (e.g., missing role or content) may cause API errors.
    • Using unsupported model names or versions can lead to errors.
  • Error messages:

    • Authentication errors: Verify API key validity and permissions.
    • Rate limit exceeded: Reduce request frequency or check subscription plan.
    • Invalid request body: Ensure all required fields like messages and model are correctly set.
    • Token limit exceeded: Adjust max tokens or prompt length accordingly.

Links and References

Discussion